Skip to content

[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

Merged
merged 11 commits into from
Aug 21, 2020

Conversation

rothbart
Copy link
Contributor

@rothbart rothbart commented Aug 20, 2020

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:

  • Forms weren't graying out when submitted
  • Snackbar wasn't animating in for 'receive offers' section

@mui-pr-bot
Copy link

mui-pr-bot commented Aug 20, 2020

Details of bundle changes

Generated by 🚫 dangerJS against 20d8678

@oliviertassinari oliviertassinari changed the title Onepirate typescript [docs] Migrate Onepirate to TypeScript Aug 20, 2020
@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label Aug 21, 2020
return (
<MuiTextField
InputProps={{
...disableUnderline,
Copy link
Member

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?

Copy link
Contributor Author

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"'.

Copy link
Member

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

Copy link
Member

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

@oliviertassinari oliviertassinari merged commit c6f65bc into mui:next Aug 21, 2020
@oliviertassinari
Copy link
Member

@rothbart Great job, thanks

rothbart added a commit to rothbart/onepirate-typescript that referenced this pull request Aug 21, 2020
rothbart added a commit to rothbart/onepirate-typescript that referenced this pull request Aug 21, 2020
eps1lon pushed a commit to eps1lon/material-ui that referenced this pull request Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants