-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
[docs] Migrate Onepirate to TypeScript #22295
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
Conversation
docs/src/pages/premium-themes/onepirate/modules/views/AppFooter.tsx
Outdated
Show resolved
Hide resolved
docs/src/pages/premium-themes/onepirate/modules/components/Paper.tsx
Outdated
Show resolved
Hide resolved
docs/src/pages/premium-themes/onepirate/modules/components/TextField.tsx
Outdated
Show resolved
Hide resolved
return ( | ||
<MuiTextField | ||
InputProps={{ | ||
...disableUnderline, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why introducing an intermediary variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I introduced the intermediary because otherwise typescript gives an unexpected error that I haven't been able to diagnose:
src/pages/premium-themes/onepirate/modules/components/TextField.tsx(95,6): error TS2322: Type '{ required?: boolean | undefined; disabled?: boolean | undefined; error?: boolean | undefined; hidden?: boolean | undefined; dir?: string | undefined; label?: ReactNode; select?: boolean | undefined; ... 276 more ...; SelectProps: { ...; }; }' is not assignable to type '(IntrinsicAttributes & StandardTextFieldProps) | (IntrinsicAttributes & FilledTextFieldProps) | (IntrinsicAttributes & OutlinedTextFieldProps)'.
Type '{ required?: boolean | undefined; disabled?: boolean | undefined; error?: boolean | undefined; hidden?: boolean | undefined; dir?: string | undefined; label?: ReactNode; select?: boolean | undefined; ... 276 more ...; SelectProps: { ...; }; }' is not assignable to type 'OutlinedTextFieldProps'.
Types of property 'variant' are incompatible.
Type '"standard" | "filled" | "outlined" | undefined' is not assignable to type '"outlined"'.
Type 'undefined' is not assignable to type '"outlined"'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me think of #15697
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually a combination of props where we do want type-checking to fail. You pass disableUnderline
which is only supported for the standard
textfield but the props are defined in way that would accept filled
or outlined
.
Spreading is just a common mechanism to defeat excess property checks: microsoft/TypeScript#29883
@rothbart Great job, thanks |
Add typescript version of onepirate theme. This is based on my create-react-app and typescript implementation here: https://github.com/rothbart/onepirate-typescript
This also fixes a few small bugs in the onepirate theme: