question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Typescript types

See original GitHub issue

Context

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.

  1. ✔️ Migrate all .js files to .ts files in the example demo (https://github.com/marmelab/react-admin/tree/master/examples/demo).
  2. ✔️ Migrate all ra-ui-materialui JS files to TypeScript. Publish the compiled types in the next ra-ui-material-ui release.
  3. ✔️ Convert the rest of react-admin dependencies (ra-language-english, etc) to typeScript, publish their types
  4. ✔️ 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,
  5. ✔️ Release react-admin types officially
  6. ???
  7. 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:closed
  • Created 4 years ago
  • Reactions:145
  • Comments:28 (14 by maintainers)

github_iconTop GitHub Comments

59reactions
fzaninottocommented, Sep 23, 2020

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 npm next 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!

37reactions
fzaninottocommented, May 28, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Advanced Types - TypeScript
This page lists some of the more advanced ways in which you can model types, it works in tandem with the Utility Types...
Read more >
TypeScript: Adding Custom Type Definitions for Existing ...
In these circumstances, you have to add your own custom type definitions for the libraries. This article will show you how to that....
Read more >
How do I add TypeScript types to a JavaScript module without ...
I have an npm module that is written in JavaScript, not TypeScript. Some of the users of this module are using TypeScript, so...
Read more >
How To Create Custom Types in TypeScript - DigitalOcean
This tutorial will show you how to use custom types with TypeScript, how to compose those types together with unions and intersections, and...
Read more >
@types/typescript | Yarn - Package Manager
This is a stub types definition for TypeScript (https://github.com/Microsoft/TypeScript). TypeScript provides its own type definitions, so you don't need ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found