Add Typescript types
See original GitHub issueContext
We want to migrate react-admin to TypeScript and release types with the library.
That doesn’t mean that you won’t be able to use react-admin if you’re not using TypeScript. React-admin will still publish both JS files (as today) and .d.ts files (ignored by non-typescript users). So if you don’t use TypeScript, that won’t change anything for you.
We’ve started a migration effort a year ago. As of writing, 70% of the codebase is in already TypeScript. We use these types internally during development. We’ve only released the types for ra-core
publicly.
We’re working on migrating the rest of the codebase. It’s a long and tedious job. It’s not the core team priority. Your help is welcome.
Risk
We don’t want to emit bad types, because it would break existing TS applications. Therefore, we need to test the types thoroughly.
Roadmap
Migrating the demo should be the priority, as it allows us to validate our types internally before publishing them.
- ✔️ Migrate all .js files to .ts files in the example demo (https://github.com/marmelab/react-admin/tree/master/examples/demo).
- ✔️ Migrate all
ra-ui-materialui
JS files to TypeScript. Publish the compiled types in the next ra-ui-material-ui release. - ✔️ Convert the rest of react-admin dependencies (ra-language-english, etc) to typeScript, publish their types
- ✔️ Locally, emit the types from react-admin in development. This is when things will break. Test the demo, test on as many existing TS apps as possible. Once all the types are checked, and only then,
- ✔️ Release
react-admin
types officially - ???
- Profit
All these changes must be done on the next
branch (master
is only for bug fixes).
How you can help
If you know and understand the react-admin internals, and if you are an experienced TypeScript developer, please help us migate .js files to .ts in the order described above.
This is not an easy task. If you don’t have enough knowledge of the react-admin internals, then please leave it to people more knowledgeable. Otherwise, the core team will spent more time answering your questions than doing the migration themselves.
What to do in the meantime
Some community packages for react-admin types can be found here and there. They are outdated. Disable TypeScript checking on the react-admin modules.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:145
- Comments:28 (14 by maintainers)
React-admin now emits TypeScript types - this task is done 🥳 . Starting with 3.9.0, you will have IDE autocompletion in react-admin projects, and a stricter syntax check if you use TypeScript. Of course, you can still use react-admin in pure JS, without TypeScript.
These types aren’t complete or perfect, and any TypeScript app using react-admin will probably reveal bugs in our types. That’s why I’ve released version
3.9.0-beta.1
in the npmnext
channel: We need volunteers to test these types and report any problem they find in real-world usage by opening a new issue here.Please don’t open issues for missing types yet - only the ones that break current code.
Thanks in advance!
Thanks to an awesome work from several community developers, we’ve now reached the first step in the roadmap: the example demo is now 100% Typescript. Let’s continue this collective effort and focus on the
ra-ui-materialui
types.