-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Changes declaration
to true.
#4403
Conversation
In order for this library to be usable in a TypeScript project, declaration files need to be generated. This is trivially easy for a TS project, you just need to set this flag to true and they will be generated automatically on compile. No idea why this wasn't set before, but it should basically always be set for libraries.
This is a much less aggressive dupe of #4375. #4375 tries to emit for JS files and tries to fix this issue across all packages. This PR, on the other hand, only generates Recommend merging this PR ASAP, and iterate on #4375 until it is ready. Also, probably worth considering breaking #4375 up into multiple smaller PRs, it feels like a pretty big undertaking all at once. For example, you could just enable |
Also just saw #4115, where someone claims that this change will "break all projects using TypeScript". I would like to see a much deeper explanation why this is believed to be true, because on the surface that claim suggests a bug in TypeScript! At the moment, any TS project using |
The same comment as in #4375 applies here:
This is because the types present in the code were never tested in a real app. Testing them on a real world app (like the demo example) is necessary before publishing them, because I'm 100% sure that some of these types are wrong (e.g. required prop that is actually optional, but that prevents the TypeScript compilation). If you want to speed up TypeScript in react-admin, please focus on migrating the demo example. |
@fzaninotto I don't actually use this package, so don't care enough to work on migrating the demo app. Someone came into the TypeScript channel asking for help and seeing a TS project that doesn't ship Is the issue here that you are migrating a JS project to a TS project from the outside in, which means everything at the core is just (essentially) |
Due to the use of very dynamic JS features, children cloning, and props injection, what you describe isn't feasible with our code base. We need an example app to test the types before publishing them. |
Alternatively, you could add
to the react-admin's package.json. I did it and my VSCode stopped complaining. |
superseded by #5291 |
In order for this library to be usable in a TypeScript project, declaration files need to be generated. This is trivially easy for a TS project, you just need to set this flag to true and they will be generated automatically on compile. No idea why this wasn't set before, but it should basically always be set for libraries.