You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One super-frustrating thing about libraries that don't ship TypeScript types themselves (i.e. React) is that they don't bother documenting their types.
In React, super important types like ComponentProps aren't in the official docs, and a lot of devs don't know about them 🤯
When we did a survey of /r/reactjs in 2019, about 48% of respondents said they were using TS with React, and all the anecdata I've read since then says that percentage is now way higher.
It would be extremely helpful if the docs had some kind of official page on React+TS usage.
The current de-facto React+TS reference is https://react-typescript-cheatsheet.netlify.app/ , which has numerous pages on setup, basic usage, and advanced usage, as well as an abbreviated page listing some of the utility types such as ComponentProps.
There's enough material there that I don't expect all of it to get added to the React docs. But, at a minimum, there ought to be at least one "TS Usage" page that covers things like:
Setup and needing to install the @types/react* packages
Typing function components
Signatures for the major hooks
Typing event handlers
and then points over to the React+TS Cheatsheet for further reference.
I could see potential for having more than one page, such as splitting it across "Setup", "Basic Usage", "Advanced Usage", and "TS Types API Reference", but that would be a stretch goal. It would also be nice to have TS information on the individual API reference pages at some point as well, but that's also somewhat of a stretch goal.
Would the React team be open to accepting a PR adding a "TS Usage" page along these lines?
Note As anecdata, I just pulled up download stats for React, ReactDOM, and their types:
Somehow @types/react is being downloaded 9% more than react. I have no explanation for this 🤷♂️ :)
But I do think it's realistic that @types/react-dom is 75% of react-dom downloads.
The text was updated successfully, but these errors were encountered:
Per https://twitter.com/mattpocockuk/status/1650611319312113665 , the new React docs currently do not provide any information on using React with TypeScript:
When we did a survey of /r/reactjs in 2019, about 48% of respondents said they were using TS with React, and all the anecdata I've read since then says that percentage is now way higher.
It would be extremely helpful if the docs had some kind of official page on React+TS usage.
The current de-facto React+TS reference is https://react-typescript-cheatsheet.netlify.app/ , which has numerous pages on setup, basic usage, and advanced usage, as well as an abbreviated page listing some of the utility types such as
ComponentProps
.There's enough material there that I don't expect all of it to get added to the React docs. But, at a minimum, there ought to be at least one "TS Usage" page that covers things like:
@types/react*
packagesand then points over to the React+TS Cheatsheet for further reference.
I could see potential for having more than one page, such as splitting it across "Setup", "Basic Usage", "Advanced Usage", and "TS Types API Reference", but that would be a stretch goal. It would also be nice to have TS information on the individual API reference pages at some point as well, but that's also somewhat of a stretch goal.
Dan mentioned that at some point the React team might want to do cleanup on the TS types to better reflect the React team's view of those concepts. That can be done later, but I strongly think that there needs to be some TS usage material added to the React docs today to provide guidance to the community on how to use React+TS properly.
Would the React team be open to accepting a PR adding a "TS Usage" page along these lines?
The text was updated successfully, but these errors were encountered: