-
Notifications
You must be signed in to change notification settings - Fork 645
Description
Describe the bug
Type definitions for Button are not being exported correctly in the transpiled output.
E.g:
variant is being reported as a string type, rather than the VariantType union it should report.
This may be happening with other props, but hasn't been verified.
Due to this incorrect typing, the migration from the v34 Button to v35 becomes challenging as the v34 Button also had a variant prop that was used for size, so the TypeScript compiler assumes the size was valid and shows the following error (rather than one related to invalid discriminated unions).
<Button
variant="small"
onClick={() => onCreate(minimumStartDate, defaultDuration)}
leadingIcon={PlusIcon}
{...testIdProps('add-default-iteration-button')}
>
Add iteration
</Button>leads to this error:
Error: Uncaught [TypeError: Cannot convert undefined or null to object]
This can also be reproduced on StackBlitz:
To Reproduce
Steps to reproduce the behavior:
- Go to StackBlitz https://stackblitz.com/edit/primer-react-v35?file=index.tsx
- Hover over the variant prop on Button
- See error

Expected behavior
variant should show 'default' | 'primary' | 'invisible' | 'danger' | 'outline'
Additional context
Possibly related? #1948