Skip to content
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

Migrate to TypeScript #15984

Closed
2 tasks done
cyberhck opened this issue May 31, 2019 · 48 comments
Closed
2 tasks done

Migrate to TypeScript #15984

cyberhck opened this issue May 31, 2019 · 48 comments

Comments

@cyberhck
Copy link

cyberhck commented May 31, 2019

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Hi according to roadmap, there'd be a possibility of discussion for migrating to typescript, as currently maintaining separately doesn't seem to be ideal, migrating the whole project into typescript would mean a huge task, but that'd make project much more maintainable.

Any plans on that front?


Edit by maintainers. We are progressively moving the codebase to TypeScript, as we write new modules or refactor existing ones. This started in 2019 and will likely take a while (and expected to), see this timeline:

  • 02/2019: TypeScript: 1.6%
  • 03/2020: TypeScript: 3.2%
  • 07/2020: TypeScript: 5.3%
  • 10/2020: TypeScript: 25.4%
  • 11/2020: TypeScript: 34.7%
  • 04/2021: TypeScript: 35%
  • 07/2021: TypeScript: 35.4%
  • 09/2021: TypeScript: 36.1%
  • 03/2022: TypeScript: 40.5%
  • 06/2022: TypeScript: 38.4% (we moved the pickers written in TS to MUI X)
  • 09/2023: TypeScript: 50.9%
  • 03/2024: TypeScrip: 56.4%
@oliviertassinari
Copy link
Member

oliviertassinari commented May 31, 2019

@cyberhck What do you expect for with such migration, as a user of Material-UI?

My counter-argument is with the opportunity cost it creates for us when committing with this effort. What else can we work on? From my perspective, the priorities are: 1. More components (more time saving) 2. Isolate the styling solution, have JSS has optional, make styled-components the default engine (broader reach). Do we have room for any other major effort?

@eps1lon
Copy link
Member

eps1lon commented Jun 1, 2019

as currently maintaining separately doesn't seem to be ideal

How did you come to this conclusion?

@cyberhck
Copy link
Author

cyberhck commented Jun 3, 2019

I think I might have given the wrong impression on my issue, please let me clarify

In no way I wish to pause the feature development for material UI and only work on typescript migration, I'd never ask any project to pause their own development. Then there'd be no v5 release, release without any new feature doesn't make any sense.

currently we're maintaining javascript files, and keeping definition files on the side, which may not be in sync all the time, and they might not reflect the true types, changing one js file and forgetting to change type definition might also be a problem or rushing through changing a component but forgetting to update types might also be a real problem,

That's what I meant when I said maintaining separately doesn't seem to be ideal.

The way I proposed to do is the following,
Add typescript to project, then interop with javascript, make sure test files are NOT changed when you change the component initially, for a few releases, you can work in parallel with JavaScript.

Say there's a bug fix for button or (someone interested from community), will start working on migrating that 1 component and make sure the tests pass (without converting tests to typescript initially), once the button is merged, we can come back to tests later to convert those as well.

This way you keep your development steady, and if you're touching some component any way, then you can convert that particular component into typescript because we already have so many components with good type definition, it should be easy to convert components one by one.

What do you hope for with such migration, as a user of Material-UI?

As a user of material-ui I might not be getting very tiny benefit where I can be confident that the typedefinition provided are actually in sync with project (because code is source of truth), but I'd argue benefits which will indirectly influence me.

after the migration is done, the codebase might have less potential problems and development might be a bit faster, I could contribute more easily if I wanted to.

It's more of a confidence thing I guess.

@yordis
Copy link
Contributor

yordis commented Jun 3, 2019

@oliviertassinari sharing something from Jest migration to TypeScript experience.

  1. Set up the tooling upfront for all the packages and request help from the community. I am talking this about https://github.com/mui-org/material-ui/blob/21582fd3afb38ed4da036f453f3bf56b27d14c91/packages/material-ui-lab/package.json#L25-L35

  2. List all the packages under Mui for visibility.

  3. Be available for support understanding the edge cases.

The 3rd bullet point stopped me completely from actually giving you a hand, I tried to migrate material/styles and then I found out that the typespec was wrong and I will require some support from the core team.

Be prepare, do not hunt the perfect typespec, sometimes a simple any is enough and you can always circle back on it, just don't hunt for perfection where there is a little reward on it.

I am more than happy to help you, but since I tried this myself, I know I will require some support from the Core team.

@eps1lon
Copy link
Member

eps1lon commented Jun 3, 2019

The problem is not converting JavaScript to TypeScript. The problem consists of many issues of TypeScript in the JSX domain. We would need to any so many things that there would hardly be any benefit left.

Yes sometimes types are outdated but that's usually just a missing prop or CSS class key. It's very rare that those stay unfixed for more than one patch version.

Then we have to migrate all the internal tooling: lint, mocha test, karma vrtest etc. This is nowadays less of a hassle thanks to @babel/preset-typescript or eslint supporting tsx files but it still has potential for maintainer churn.

Which leads to the last point: Not every maintainer has experience with typescript. And this may be egoistic but I don't want to be the guy that has to review every PR because there's some issue with TypeScript. I like that we have the ability to move implementation and and interface separately which is what TypeScript is for us now: A interface description. Bugs that could've been caught by TypeScript are very rare as far as I can tell (didn't investigate this; just a feeling I have).

So far I could only identify that we would eliminate issues regarding outdated props. I don't think that justifies the amount of effort involved.

@yordis
Copy link
Contributor

yordis commented Jun 3, 2019

Yes sometimes types are outdated but that's usually just a missing prop or CSS class key. It's very rare that those stay unfixed for more than one patch version.

@eps1lon being a TypeScript user myself this is my pain https://github.com/straw-hat-team/react-admin/blob/1352d6c56d777e094febd652472d5dadf7387fe8/src/administrator/AppBar.tsx#L15

I keep adding, @ts-ignore Mui needs to fix this because the typespec is secondary. If you are taking the effort to maintain .d.ts files I don't see why you wouldn't use TypeScript then.

which is what TypeScript is for us now: A interface description.

Keep it like that then, you don't have to use strict rules and force yourself to do things that are almost no value, this is one thing I am trying to explain to people, there is nothing wrong with any type or simply omit the typespec.

You would argue the value of TypeScript then, but I would say that I would prefer to have correct typespec than having all the typespec.

I don't believe that we should be using TypeScript for capturing bugs, but I would encourage for documentation, faster understanding of the internals since you have more static types that you could analyze.

Use it when you need it 🤷‍♂

@eps1lon
Copy link
Member

eps1lon commented Jun 3, 2019

@eps1lon being a TypeScript user myself this is my pain straw-hat-team/react-admin:src/administrator/AppBar.tsx@1352d6c#L15

The issue you linked it not caused by an outdated type spec. I would encourage you to submit issues or search through them or read the docs. As a typescript user you should be aware that the error messages are not always helpful i.e. point in the right direction.

@oliviertassinari oliviertassinari changed the title Migration to typescript for v5 Migration to TypeScript for v5? Jun 3, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 3, 2019

I agree with @eps1lon, I think that we would be better off (from a fundamental point of view) completing #14897 and spending our time of the existing reported TypeScript issues before even considering a migration of the codebase to TypeScript.

The main value I see in a TypeScript migration is a marketing one. We can turn the users' psychology in our favor without changing the core product value. It works as follow: "the codebase is written in TypeScript, it must have great support, let's use this library. Oh, there is a bug here, well it must be a bug in TypeScript itself or this library that doesn't use TypeScript, not Material-UI".
Most people think that marketing is cheating, I don't think so, it's quite the opposite, it's brilliant!

@rosskevin
Copy link
Member

I believe 1. demos in typescript, then 2. tests migrated to typescript would yield the biggest benefit. Moving the source files there would be great from a ts-user standpoint (and generally understanding the codebase), but I also understand the non-ts user perspective so I am not strongly advocating either way. Certainly my personal perspective is pro-ts.

I do believe that tests in ts/tsx would very much help surface ts issues, similar to getting demos to ts/tsx.

@eps1lon
Copy link
Member

eps1lon commented Jun 21, 2019

I do believe that tests in ts/tsx would very much help surface ts issues, similar to getting demos to ts/tsx.

That is work that's up for grabs. You can add a // @ts-check to the unit test files in core/src and see if it type checks. See https://github.com/mui-org/material-ui/pull/16187/files#diff-4e15af19bc6a128de4ce036cdc12b862

@rosskevin
Copy link
Member

I'd rather try changing to tsx and add the @babel/preset-typescript. If I get some time I'll try one and we can see what the changeset entails.

@eps1lon
Copy link
Member

eps1lon commented Jun 21, 2019

What would be the benefit of that?

@rosskevin
Copy link
Member

Builds with Babel and type checking with tsc?

@eps1lon
Copy link
Member

eps1lon commented Jun 21, 2019

We get type checking by adding @ts-check. An additional build pipeline is always a downside.

@rosskevin
Copy link
Member

We are already running tsc with the script typescript in material-ui/package.json and run in ci with

      - run:
          name: Tests TypeScript definitions
          command: yarn typescript

so it is not an additional build step but an existing one. Further, are people more likely to know jsdoc(?) annotations or typescript annotations?

@eps1lon
Copy link
Member

eps1lon commented Jun 21, 2019

Further, are people more likely to know jsdoc(?) annotations or typescript annotations?

the jsdoc annotations are parsed by typescript just as regular typescript types. There's no difference there.

so it is not an additional build step but an existing one.

I thought we were talking about our unit tests. It's not strictly speaking a new build step but an additional preset that has to be configured.

We are already running tsc with the script typescript

Yes I know our CI setup quite well considering I build most of steps concerned with type checking.

To further clarify: That step already type checks Typography.test.js. If you want to include more tests you can add @ts-check to the files and add missing types (and potentially fix existing issues).

@rosskevin
Copy link
Member

rosskevin commented Jun 21, 2019

I'm not sure how @ts-check checks usage without running in tsc (I'm not familiar).

I get the sense that things like #16315 would more likely be surfaced by quite simply switching tests to tsx and including them in the tsconfig while using the standard tooling (tsc). This seems very simple, no need to annotate - just change the extension and we get better coverage.

I'm not sure doing something non-standard makes sense. Either we go towards ts, or not. My preference is clear that moving tests to tsx would be a positive:

  • it would be familiar to ts users (@ts-check and jsdoc use is not as familiar as tsx)
  • it would not be an extra step to ci
  • it would increase coverage

@cyberhck
Copy link
Author

Everyone knows we can easily do a partial migration and move slowly, but if maintainers don't want to give TypeScript a try, simply listing benefits won't do anything. As some of us already said we'll help migrate and do a gradual migration. I'm getting sense that they just don't want to do it. There's no point on arguing benefits or tradeoffs.

Issue title clearly says for v5 which means you can have breaking changes, some fixes which needs to be made for typescript can be done as a breaking change, and once we pass the initial friction, migrating the rest should be very easy. You don't have to turn on all the strict rules initially, you can get there gradually.

Arguing over things is just waste of time, I think the original request was we're willing to help, are you interested?

@eps1lon
Copy link
Member

eps1lon commented Jun 22, 2019

Arguing over things is just waste of time, I think the original request was we're willing to help, are you interested?

Sure. You can add @ts-check to files in ./packages/material-ui/src/**/*.test.js. This is a gradual migration strategy. I'm not sure how you get the impression we're not interested in improving types. It's a bit unfair to make these claims without being involved with the project.

@cyberhck
Copy link
Author

The point was to start doing actual conversion, without only using @ts-check, but rather starting to change from js files to jsx files,

@eps1lon
Copy link
Member

eps1lon commented Jun 23, 2019

The point was to start doing actual conversion, without only using @ts-check, but rather starting to change from js files to jsx files,

I thought adding @ts-check would be the same as changing the extension. Is type-checking different for those two? Could you elaborate on the difference?

@cyberhck
Copy link
Author

cyberhck commented Jun 23, 2019

no, if you were to change extensions, you can inline your type definition, you can't have a javascript file like this:

const something = (): boolean => {
  return true;
}

If we start moving everything to proper typescript, the type checking will also increase, and will find potential bugs.

I'm advocating the complete move to typescript, not just type checking, which includes build system, linting and what not.

@joshwooding
Copy link
Member

@cyberhck I don't think anyone is against the long term vision of potentially moving to TypeScript. @ts-check allows for us to start gradually migrating as @eps1lon said. I, for one, am grateful for the slower move since it allows me more time to get more comfortable with TypeScript.

@eps1lon
Copy link
Member

eps1lon commented Jun 23, 2019

Yeah I don't understand what's being proposed here. We are increasing our type coverage, we are using tslint. If the argument for ts extension is only a stylistic one then I think we don't have to put effort into it.

Also advocating for a move to linting with typescript (I guess you mean tslint?) is backwards. tslint will soon be deprecated. If anything we should look into moving to eslint 6 (released yesterday) and how we deal with dtslints expect rule in the future.

I would appreciate if the people arguing for a typescript migration would familiarize themselves with the codebase (I'm always eager to answer question and to get more people to contribute to the ts related code) before making such strong statements here.

It's easy for outside readers to get the impression that we don't test our types. Maybe something is lost in translation but I still don't understand what the difference in type checking is between .ts and @ts-check. An example would be appreciated.

@cyberhck
Copy link
Author

cyberhck commented Jun 24, 2019

Maybe I missed something, on your JS files, can you show me an instance, where you define a return type?

About the migrating to tslint, I understand your position, tslint isn't getting deprecated tomorrow, and we can always switch to eslint-typescript instead.

Changing extension is about the cognitive load when I read your js files, I don't exactly know what type your function is supposed to get by looking at your code, I've to open yet another file just to do that,

When I'm contributing, having ts files and having parameter type, return types right there gives me a knowledge of what's supposed to happen.

And also can you also mention what'd be the downside of changing the extension to tsx/ts if you're so sure with @ts-check is the same?

Like in my previous comment, you can't have a js file like this:

const something = (): boolean => {
  return true;
}

if it were a ts file, just by looking at code, I know I'm supposed to return a boolean

@yordis
Copy link
Contributor

yordis commented Oct 3, 2019

@eps1lon I am annoyed by that person, laughing at your response because it got under your skin, and also worry about you because you let that happen.

We love, cheer up, and support you.

Having patience, and understanding people's emotions are the cost of popularity and OSS.

I want you and OSS maintainers to be happy. But we can't do anything about these situations other than understanding their childish and emotional behaviors and focus on what matter.

We signed off for these comments, please don't let this affect you.

@oliviertassinari oliviertassinari changed the title Migration to TypeScript for v5? Migration to TypeScript Feb 2, 2020
@oliviertassinari oliviertassinari changed the title Migration to TypeScript Migration to TypeScript? Feb 2, 2020
@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 2, 2020

An update on our progress toward TypeScript

What we have done

  • We have migrated all our demos to TypeScript. This change seems to be the one that yields the most benefit. For instance (lead by @eps1lon):

https://github.com/mui-org/material-ui/blob/7994e11de8c02b9480efb927a8042939ad05ac5c/docs/src/pages/components/autocomplete/ControllableStates.tsx#L7-L8

  • We have moved all source of truth of all the props from prop-types comments to TypeScript comments (lead by @eps1lon). This is valuable as it forces us to think about the TypeScript public interface first.

https://github.com/mui-org/material-ui/blob/7994e11de8c02b9480efb927a8042939ad05ac5c/packages/material-ui-lab/src/Autocomplete/Autocomplete.d.ts#L151-L157

  • We have fixed a bunch of TypeScript issues.

Observations

Capture d’écran 2020-08-09 à 20 35 41

What we are working on

Improving our component infrastructure to support sources in TypeScript. For instance #21758.

Future?

  • Should we have TypeScript as the default toggled language for the demos?
  • Should we migrate our existing tests to TypeScript?
  • Any proposal?

At this point, it doesn't seem that we need to willingly dedicate time to the problem. TypeScript is organically gaining usage in our codebase. It seems that we can sleep on it, and focus on other problems 🤔.

@yordis
Copy link
Contributor

yordis commented Aug 2, 2020

Should we migrate our existing tests to TypeScript?

This could be a way to validate the experience of the typespec but can get really annoyed and full of @ts-ignore in some test cases where you mock things.

Should we have TypeScript as the default toggled language for the demos?

I wouldn't, TypeScript has a cost, and most developers out there are not being taught in TypeScript as the first language. Personally, has been few years in TypeScript and I know I am not the norm (compared with the entire Front End ecosystem not just React) so I don't mind toggling.

That being said, use local storage, and save the configuration there, most likely if I switched is because I am interested in TypeScript over JavaScript.

At this point, it doesn't seem that we need to willingly dedicate time to the problem. TypeScript is organically gaining usage in our codebase. It seems that we can sleep on it, on focus on other problems 🤔.

Is there any process on wich I could find the series of steps to convert the codebase or help in any way?

I haven't look much but having a process that you could share with everyone outside the core team could open the door for more streamed line collaboration.

@dtassone
Copy link
Member

dtassone commented Aug 7, 2020

I believe that we all want to build the best and most reliable set of react components ever written.
And one of the tools that can help us achieve this is Typescript, due to its type safety feature primarily.
So the goal would be to bring type safety in components and also support all teams that use typescript with properly generated declaration files (very important for all the TS teams out there).

As part of the core team today, we now have 2 big components written in typescript, date-pickers and the data-grid.
As well as all future development, part of the X project will be written in typescript.

Therefore it seems to me that now would be the right time to handle the pain and migrate every component in core and lab to typescript.
From my experience, a migration is always a bit of a pain and for this reason, things are easier to do on a short term big bang conversion than trying to support a half and half transition period. That makes things even more painful and does not really work well on the long term.
If you do short term, you can ditch the old tools straight away, and start from fresh after the migration and you end up in a much better situation at the end of the migration.
Secondly, when you migrate, 1 component, then 2 and 3, you get faster and faster so big bang migration are actually pretty efficient from my experience.

Also Typescript is very well supported by all the tools we use and it's pretty mature now, so the risk is limited.

@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 7, 2020

I wouldn't, TypeScript has a cost, and most developers out there are not being taught in TypeScript as the first language.

@yordis Agree, I think that we can reevaluate this TS vs JS demo default decision in one year, with the 2021 developer survey results and with how the usage of the TypeScript demos grows. Yes, the choice of TypeScript vs JavaScript demos is persisted between sessions on the documentation, with a cookie: 15% (TS) vs 75% (JS).

Is there any process on wich I could find the series of steps to convert the codebase or help in any way?

We don't have any steps to perform the migration as we don't have any components yet fully written in TypeScript in the core infrastructure. The challenges that are left to be solved for doing such, cc @dmtrKovalenko:

  • Writing the tests in TypeScript. There are a few changes in the configuration to move from material-ui-x to material-ui repository in order to have tests like XGrid.test.tsx work, nothing major. I recall 1, 2, and 3
  • Have the logic that generates the prop-types object, handle the type definitions from .tsx input, not .d.ts input. (we miss the prop-types generation in material-ui-x)
  • Have the logic that generates the API pages of the documentation handle the extraction of the information from the types, not the prop-types. (we miss the API generation in material-ui-x from the types, there is some early exploration but nothing in production). I believe @eps1lon is working on it, starting with the main repository.

Once we have that, we can do the migration as a background task, and ideally engage the community to do it, I have no doubt they will be happy to help, so the core team might just have to focus on reviewing migration pull requests from the community. During the JavaScript demos to TypeScript demos migration era, I believe the majority of the migration was done by the community, once Sebastian put the infrastructure in place to support it.

I believe that we all want to build the best and most reliable set of react components ever written.
And one of the tools that can help us achieve this is Typescript

@dtassone We have discussed this a bit in the past, at this point, for instance, if we look at the current open TypeScript issues or the problem we face, or even what people ask from us in the user-survey, the value of migration to TypeScript wouldn't be most about its intrinsic value but more about the perceived one by the community, where people wrongly approximate written in TypeScript with great to be used in a TypeScript codebase and higher code quality (I would argue that higher code quality is not strongly correlated, especially when we add defensive logic instead of @ts-ignore).

At this point, I think that the main incentive we can have for migration to TypeScript is:

  1. Because it helps us with the logic that involves manipulating objections from a bunch of different directions, why we have the DatePicker and DataGrid uses TypeScript or even why [docs] Port buildApi to TypeScript #22055.
  2. Because it has marketing and perceived value. Because of people associate TypeScript sources with higher-quality code and easier to use in a TypeScript codebase.

If you do short term, you can ditch the old tools straight away, and start from fresh after the migration and you end up in a much better situation at the end of the migration.

IMHO this wouldn't be the best option. I think that we should only do "big bang" when no other progressive approaches are sustainable. In this case, we are lucky to have TypeScript as an optional enhancement, that we can deploy progressively, so should we.

What do you have in mind with "ditch"?


Going back to the marketing value, there is one metric we might want to optimize for, this one:

Capture d’écran 2020-08-07 à 15 28 55

GitHub determines the % by looking at the number of files, no matter how many lines there are (at least it seems). We have 8792 JavaScript files and 472 TypeScript files. So TypeScript is 5% (=472/(8792+472)). However, if you look closer, you will find that among all these JavaScript files there are 6578 generated icons, which are very small files and arguably we could consider having them written in TypeScript as there are generated types definitions and type tests. For instance, with this diff, using https://github.com/github/linguist:

diff --git a/packages/material-ui-icons/src/.gitattributes b/packages/material-ui-icons/src/.gitattributes
new file mode 100644
index 000000000..282f21f32
--- /dev/null
+++ b/packages/material-ui-icons/src/.gitattributes
@@ -0,0 +1 @@
+*.js linguist-language=TypeScript

we would go up to:

Capture d’écran 2020-08-07 à 16 31 22

which seems more accurate to the state of the codebase. Thoughts?

@dtassone
Copy link
Member

dtassone commented Aug 7, 2020

progressive approaches are sustainable. In this case, we are lucky to have TypeScript as an optional enhancement, that we can deploy progressively.

If you think about it there is no point in being progressive on this one. It's not like converging towards a certain API
Converting one component in JS to TS can all be done in one go. No big breaking changes, yes some issue here and there...
Then we can align all repo and build every libraries with rollup (preferred tool for libs) & typescript, so replace the current builder
Work towards a better release pipeline, unified. No need to maintain this, that and common... => the cost of being progressive comes from maintaining the transition. We need to do this before we can do that. Slower migration as we merge one component, do other things (forget) then merge another.

@oliviertassinari
Copy link
Member

Converting one component in JS to TS can all be done in one go

@dtassone What's the smallest unit of codes we can incrementally migrate? I believe it's each .js file, individually, the ones that are behind each .d.ts file. So, we should be able to migrate each file one after the other. Considering we have over 100 d.ts files, I would expect that we can do the TypeScript migration with over 100 iterations (pull requests), iterations we can empower the community with.

There is no point in being progressive on this one

Taking a step back, I think that progressiveness should be our default answers to problems until we see strong values for not applying it. The value of progressiveness or working with small iterations is about all about: shorter feedback loop (the most important IMHO, to hit reality as fast as possible), delivering value to production more often, more flexibility. A core principle of Agile software development.

I don't fully understand the problem you are referring to by maintaining different build steps during the transition. Do you have more details? I don't see what needs to be maintained.

Then we can align all repo and build every library with rollup (preferred tool for libs) & typescript, so replace the current builder

I don't see the direct link between the TypeScript migration and the build step. Shouldn't we discuss the two individually? Do you want to open a new issue? Maybe you would like to engage in #18447?
Also, don't forget that Babel in the equation, it's an important part of the build. We leverage a couple of Babel plugins to optimize the published files on npm. I wrote about some of the Babel plugins we use a long time ago.

@mbrookes
Copy link
Member

mbrookes commented Aug 8, 2020

Since migration of core components to TS isn't a priority right now, further discussion is somewhat moot; so I'd rather we didn't spend more time on it.

@dmtrKovalenko

This comment has been minimized.

@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 9, 2020

further discussion is somewhat moot

If we go back to the user-survey of 2020, we have almost half the respondents that mention using TypeScript, we also have "TypeScript integration" ranking at position 4 in the question: What are your key criteria when choosing a UI library? So the broader TypeScript topic is important (I'm not saying that migration is important, current metrics suggest it shouldn't be in the top of our priorities).

Should we close this issue?

  • We are working on this problem, as a background task, at a priority level, that seems to match with what has a higher ROI and lower opportunity cost. Right now, it has a relatively low priority level. We can ask the community to contribute once we are ready.
  • Many developers have upvoted the issue, I think that we can communicate that we are interested in feedback from the community, by keeping it open.
  • I don't think that suppressing voices will resolve underlying issues (flawed thought process, inaccurate information, etc). I think that it will delay things that, usually, make the situation worse. Quite the opposite, I think that it's healthy to keep hearing constructive argumentation around the topic, especially if it can lead to more clarity in the thought process and agreed on facts of the core team.

@cyberhck
Copy link
Author

I had unsubscribed from this issue, but wow, a lot has changed since I first asked for this.
First off a huge thanks to maintainers for looking into this, and moving forward.

I didn't even think this many people would be favoring migration to TypeScript.

For the people who just want the typing, I believe the current state of typing provided is very good, and more and more codebase is being written in TypeScript, so this definitely has good TypeScript support.

I want to state one more time, the issue was created in spirit of helping maintainers and new contributors, the end users already have it pretty good (except there's more possibility of having typing bugs, but that barely happens and when it does, creating one issue is all it takes for maintainers to fix it)

I do want to add a few things which got lost in conversation.

  • I do not want maintainers to invest too much time doing a big bang migration, that'll make the feature release slower (I mean, I'm not expecting them to do this for our sakes)
  • I do believe changing as we go (gradual change) is the way to go.
  • About tests, till all the source files are converted I think keeping tests in JS is I think more fruitful because in case we introduce a bug, existing test will catch it, and once we know we've migrated source files, then we can convert tests to typescript as well :)

Huge thanks to @eps1lon for his contribution :)

@rajzik
Copy link
Contributor

rajzik commented Aug 28, 2020

Hello, guys Airbnb just released a new tool for migration huge javascript basis to typescript:
https://github.com/airbnb/ts-migrate

Couldn't this help with the migration?

@eps1lon
Copy link
Member

eps1lon commented Aug 28, 2020

Couldn't this help with the migration?

Not really since the little nuances that this tool doesn't cover are why we wouldn't gain anything from the migration.

@eps1lon
Copy link
Member

eps1lon commented Sep 1, 2020

We have the infrastructure in place to write modules and tests in TypeScript and already have some tests and modules (public and private) written in TypeScript and we'll continue porting JS files to TypeScript where appropriate.

Components are not considered appropriate currently. On one hand because we don't think writing components in TypeScript solves an actual issue. If you disagree please refer to an existing issue (and we'll try to resolve it separately) or open a new one. This keeps the discussion focused. On the other hand TypeScript has some limitations that make this task hard. I've created a playground with a minimal component written in JS. If you're able to convert it to TypeScript please let us know. Changing type-tests is reasonable if a strong argument is made for your implementation. Playground: Minimal Material-UI component in TypeScript base

@akashshyamdev
Copy link
Contributor

akashshyamdev commented Sep 29, 2021

@oliviertassinari @eps1lon can you assign a beginner friendly component to me?

@oliviertassinari
Copy link
Member

@akashshyamdev We can't. So far, we don't work on TypeScript migration for the sake of it. Instead, we wait for natural adoption, writing new modules in TS or when we need to touch a specific area of the codebase.

I think that once the adoption rate it really high, like 80%, then we could give it a final push, only to get a consistent experience when developing in the codebase (always TS).

@mbrookes mbrookes changed the title Migration to TypeScript? Migrate to TypeScript May 7, 2022
@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 12, 2024

In light of the issue's description:

SCR-20240312-pkcr

I think we are good, TypeScript is pretty much integrated now. And the last example for this is #41073 moving from prop-types naming conventions to TypeScript for the API docs.

Now, it's about making sure any new modules continues to be written in TypeScript and we occasionally migrate JavaScript files to TypeScript anytime we feel the need for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests