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

Type checking of props #121

Open
DanWebb opened this issue Apr 18, 2023 · 2 comments
Open

Type checking of props #121

DanWebb opened this issue Apr 18, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@DanWebb
Copy link
Member

DanWebb commented Apr 18, 2023

Typescript isn't checking the validity of props.

This causes issues where storybook examples can use invalid props and errors leak out into projects.

Example with the slider component

In the project we get an error for invalid props:

Screenshot 2023-04-18 at 13 29 33
Screenshot 2023-04-18 at 13 33 03

In the story no error is present:

Screenshot 2023-04-18 at 13 29 23

We can even pass a typed prop using a completely incorrect type without receiving an error:

Screenshot 2023-04-18 at 13 35 34

I've played around with the 3 tsconfigs and compared against the setup in the project but haven't been able to get to the bottom of it.

@DanWebb DanWebb added the bug Something isn't working label Apr 18, 2023
@DanWebb
Copy link
Member Author

DanWebb commented Apr 18, 2023

This SliderProps also extends FormControl which has a [key: string]: any; so it should have never errored on the id but it doesn't make its way into the export.

Screenshot 2023-04-18 at 13 52 34

@DanWebb
Copy link
Member Author

DanWebb commented Apr 18, 2023

The props issue is:

  1. The path for the Slider component isn't relative (src/ instead of ../)
  2. forwardRef uses Pick with keyof Props under the hood which completely messes up the type when [key: string]: unknown is present

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant