Material-ui: [Typings] TypeScript typings for 1.x branch

Created on 24 Jul 2017  路  8Comments  路  Source: mui-org/material-ui

Hey!

We're using the 1.x branch for a while now and have written typings for the components/API of material-ui we're using. We only switched to material-ui a month ago, so the API is not yet completely covered (~700 LOC).

For the 0.x branch the typings reside at @types/material-ui. While this is the "official" way, libs like redux come with their typings included. This has some benefits:

  • No extra package to install
  • Typings match the installed version (we had issues with that in the past ...)
  • Typings are official maintained

Downside of this approach is that there may be updated to the lib only concerning the typings.

tl;dr; Are you interesting in moving TS typings into the material-ui repo for version 1.x and above, since flow typings are (obviously) also part of the repo?

discussion

Most helpful comment

We definitely would do our best to maintain the typings (because we have products in development, which are using material-ui and need to be maintained for a long time).

Just wanted to reach out and see what model the maintainers would prefer 馃檪

All 8 comments

We had an earlier conversation on the topic with #7386. The conclusion was unless we have someone how step up to maintaine those definitions, we would rather let the community handle it outside of the repository.

We definitely would do our best to maintain the typings (because we have products in development, which are using material-ui and need to be maintained for a long time).

Just wanted to reach out and see what model the maintainers would prefer 馃檪

To confirm with @rosskevin, but I think that we can try. We can give you access right to the repository to do so. Then, in x months from now, we can reevaluate the situation. Asking ourselves the question, does that worth it? Do we want to continue? I think that it's a really a matter of time prioritization. We have limited ressources. It's undeniable that having typescript support is a good thing. Thanks for your potential help here! For instance, the project wouldn't have flowtype coverage without @rosskevin.

Absolutely get that. It's our way to give back to this project, since we're not (yet) very familiar with the code base, but we can at least try to help other devs using TypeScript.

We also can start by doing PRs. No need to give access rights I guess :)

Just disovered this PR https://github.com/styled-components/polished/pull/215
Maybe this would even be a better option?!

Flow and TS typings are very similar today. Most of the work (when Flow types are available) is copy/pasting them into an .d.ts file. I Wonder how tsgen is treating things like Element<*> and similar constructs.

The downside of this would definitely be that some handler, like onChange can be type very explicit in TS:

interface SomeInput {
  onChange?: React.EventHandler<React.ChangeEvent<any>>;
}

Convert flow types to typescript types, automatically

tsgen

That's what I have been looking for in the past! That looks experimental. Sounds like the best solution if you are looking for a rough working solution. I guess it will improve over time.

@ForbesLindesay out of curiosity, would you say that tsgen is stable enough to be tested on the repository?

@oliviertassinari absolutely, in the sense that if you find issues and submit pull requests to fix them I will aim to merge promptly. Beyond it being used on more projects, in order to uncover potential issues, there's not much more I can do to "stabalise" it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattmiddlesworth picture mattmiddlesworth  路  3Comments

ryanflorence picture ryanflorence  路  3Comments

ghost picture ghost  路  3Comments

chris-hinds picture chris-hinds  路  3Comments

sys13 picture sys13  路  3Comments