fix: build error roperty 'mt' does not exist on type 'IntrinsicAttrib… #2343
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…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
It works now.
![image](https://private-user-images.githubusercontent.com/120135417/401351288-a443c4c5-bb1a-4189-927b-0524b92d2655.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NzQ1NzIsIm5iZiI6MTczOTQ3NDI3MiwicGF0aCI6Ii8xMjAxMzU0MTcvNDAxMzUxMjg4LWE0NDNjNGM1LWJiMWEtNDE4OS05MjdiLTA1MjRiOTJkMjY1NS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxM1QxOTE3NTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jOWU4YjAyNTI0MThjYTUwY2ZlYmIwNjJlZWQ0ZGMwNWM2ZTA4ZDIyZWEwOWM0ZTcwOGQxMTFkZDRjNmM4ZGIxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.vTNyJLGrhhzWHa1DNMbABskTKTeoBALgqfrv17mKYA4)
This is the investigation:
IntrinsicAttributes: Provided by React, it contains:
When TypeScript resolves component props, it combines
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
Steps needed to test