Open oliviertassinari opened 3 months ago
Related: We could update our javascript codesandboxes to check types. Nothing about using javascript prevents us from type checking. Even just adding // @ts-check
on top of that file already makes the warning appear: https://codesandbox.io/p/sandbox/youthful-lalande-dk6h7m?file=%2Fsrc%2FDemo.js
This improves the DX by a landslide IMO. We can likely just add a tsconfig.json
to our JS sandboxes to accomodate for this.
Possible simple solution with a new helper:
Perhaps we can automate this in the prop types generation script?
@Janpot The counter-argument is:
we won't get them with TypeScript, and yet we still need those errors. I'm convinced we need those ones. I would expect without those errors, we will see a flow of support questions, and because as support engineers, we want to have the least amount of work possible, we will actively prioritize adding those checks back for React 19.
@atomiks for example for https://github.com/mui/base-ui/blob/fa9f3fa71320d40a409d0318229ec6521fe52e54/packages/mui-base/src/Popover/Positioner/usePopoverPositioner.types.ts#L15, is there a error in case developers provide a DOM node that isn't mounted into the DOM anymore? This used to be a recurring annoying (for me, a support engineer) support question on Material UI. I'm curious to see if developers will complain about this again.
Now, do we need all the warnings, I mean for all the props? Yeah, I doubt it. I have added the "waiting for upvotes"s flag, it will help us gather data on this.
Oh, interesting:
https://github.com/facebook/prop-types
We might need to create a simpler version of prop-types to solve those DX issues.
Steps to reproduce
Link to live example: https://codesandbox.io/s/frosty-snowflake-zjl49r?file=/src/Demo.js
Steps:
Toggle the switch
Check the errors
but nothing tells you how to fix it.
Current behavior
No information on what is wrong.
You could argue that TypeScript will let you know ahead of time, but what if you get the type wrong? At least, from this issue, we can collect upvotes from developers who faced the same challenge.
Expected behavior
A clear error message.
Context
Your environment