Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build error roperty 'mt' does not exist on type 'IntrinsicAttrib… #2343

Conversation

vanessatran-ddi
Copy link
Collaborator

…utes & component props' on react

Before (the change)

We have a build issue with React app when using alpha version. Example build error is:
5:17:57 PM: src/components/component-properties/ComponentProperties.tsx(66,62): error TS2322: Type '{ children: Element; heading: string; mt: string; mb: string; }' is not assignable to type 'IntrinsicAttributes & GoabAccordionProps'.
5:17:57 PM: Property 'mt' does not exist on type 'IntrinsicAttributes & GoabAccordionProps'.
5:17:57 PM: src/components/sandbox/SandboxProperties.tsx(126,13): error TS2322: Type '{ name: string; checked: boolean; onChange: (event: GoabCheckboxOnChangeDetail) => void; mt: string; text: string; }' is not assignable to type 'IntrinsicAttributes & GoabCheckboxProps'.
5:17:57 PM: Property 'mt' does not exist on type 'IntrinsicAttributes & GoabCheckboxProps'.
5:17:57 PM: src/examples/accordion/AccordionExamples.tsx(333,37): error TS2322: Type '{ children: string; type: string; mb: string; onClick: () => void; }' is not assignable to type 'IntrinsicAttributes & GoabButtonProps'.

....

After (the change)

Combine with this update on React app:
GovAlta/ui-components-docs@dc0dad9#diff-b55cdbef4907b7045f32cc5360d48d262cca5f94062e353089f189f4460039e0R26

image

It works now.
image

This is the investigation:

IntrinsicAttributes: Provided by React, it contains:

  • key: for React element keys.
  • ref: for React ref forwarding.

When TypeScript resolves component props, it combines

IntrinsicAttributes & GoabAccordionProps

If mt and mb aren’t part of GoabAccordionProps, TypeScript defaults to assuming IntrinsicAttributes is the problem.

Build tools like Vite might strip or mishandle the mt and mb props in the build step.

Fixing the build vite config.

Make sure that you've checked the boxes below before you submit the PR

  • I have read and followed the setup steps
  • I have created necessary unit tests
  • I have tested the functionality in both React and Angular.

Steps needed to test

@ArakTaiRoth ArakTaiRoth merged commit 10889b7 into GovAlta:alpha Jan 9, 2025
1 check passed
@tzuge
Copy link
Collaborator

tzuge commented Jan 9, 2025

🎉 This issue has been resolved in version 6.0.0-alpha.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tzuge tzuge added the released on @alpha Released into alpha. label Jan 9, 2025
@tzuge
Copy link
Collaborator

tzuge commented Jan 14, 2025

🎉 This issue has been resolved in version 1.17.0-alpha.131 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @alpha Released into alpha.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants