Uh oh!
There was an error while loading. Please reload this page.
Speed up TypeScript projects - #5903
Conversation
facebook-github-bot
commented
Nov 26, 2018
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
facebook-github-bot
commented
Nov 26, 2018
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
😞 AppVeyor failed with: I'm assuming that it is not related to this PR. |
Timer
commented
Nov 27, 2018
That error actually occurs on purpose and is caught. :-) |
@Timer I'm not sure if I understand. AppVeyor is failing as test is NOT expecting that it should fail on purpose. |
Timer
commented
Nov 27, 2018
Hm, it should be running this code: Ensuring the build fails but tests continue: Is this not working correctly? |
Deploy preview for gallant-davinci-8f9bd9 failed. Built with commit 75400fd https://app.netlify.com/sites/gallant-davinci-8f9bd9/deploys/5c06a1e2e470852f41aa6c16 |
TypeScript formatter now supports messages from TSLint. (@ianschmitz Should make master...ianschmitz:tslint easier) |
deftomat
commented
Dec 4, 2018
|
deftomat
commented
Dec 4, 2018
Not sure how to fix the failing checks as AppVeyor is failing due to 60 minutes limit for this repo and Netlify details just redirects to the 404. Anyway, I think that PR is ready for a review. |
iansu
commented
Dec 4, 2018
Appveyor has been broken for a while so don't worry about that. And Netlify is just to preview docs changes. |
I'm taking a short break from open source to finish my project so hopefully another person can review this |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ianschmitz
commented
Dec 7, 2018
Hey @deftomat. Thanks for the PR! It's looking really good so far. I'm hoping I'll have time to give it a spin this weekend. |
deftomat
commented
Jan 26, 2019
@mikew Just to be sure, are you testing it with |
Timer
commented
Jan 26, 2019
We need to make sure this works with |
Yes, definitely. I just discovered that for me, it works for 80% of times with @mikew I really appreciate that you are trying to fix this but could you explain to us what needs to be changed and why. Just a information that your branch has a correct behavior is not really helpful. Anyway, I thing that we need to add more tests 🤔 |
I am using plain old What my changes do is notify the hot dev client that async type checking is happening, which tells it to not hide the error overlay after hot changes have been applied. This has a downside of not clearing the errors when everything has been fixed. So another message is sent when that happens to explicitly hide the error overlay. Those changes are in mikew@f0e1b1b and mikew@a32a163. The rest of the commits are less important but deal with handling console output better from the two log streams. |
@mikew What about this 321d960 ? Turns out that there is already the This actually makes sense as we are handling dev-server messages in an async way with no queue. Unfortunately, until now, this "issue" sleeping in CRA for a months didn't show up. (I'm "blaming" you @johnnyreilly 😉 You guys just make it too fast 👍) |
Timer
commented
Jan 28, 2019
If it's really that fast now, should we add this async complexity? |
johnnyreilly
commented
Jan 28, 2019
I'll take that! 😊 |
@Timer Well, we will never be sure that it is always that fast. As mentioned by @johnnyreilly, for him, it could still took 2 seconds in large project. I think that when we have an opportunity to be sure, that TypeScript will not slow down anyone, then I think we should do it. Also, after 2 months, it turns out that the added complexity is just 2 IFs in |
Timer
commented
Jan 28, 2019
So does it work "perfectly now", or is there still an edge case? If this is ready, I can give it a test. |
deftomat
commented
Jan 28, 2019
I think that it finally works as expected. |
mikew
commented
Jan 28, 2019
As @deftomat mentioned, it's not a lot of complexity. And it opens the door for these async errors / warnings for other plugins, which might be a win down the line. But yeah, the real gains are from using the incremental API, which works without
It's working as expected for me. |
johnnyreilly
commented
Feb 6, 2019
I'd ❤️ this to be merged.... |
ianschmitz
commented
Feb 7, 2019
I'll give it another spin tomorrow night, and barring any glaring issues we will get it in. Thanks for your patience! |
ianschmitz
commented
Feb 8, 2019
Thanks everyone for your help! I gave it a spin with a couple of my projects and it seems to be working really nice. TypeScript is now super fast! I'll see if we can cut a release in the next day or two. 🎉 |
ianschmitz
commented
Feb 10, 2019
v2.1.4 is now out! |
This reverts commit 5ce09db.
johnnyreilly
commented
Feb 11, 2019
Hey @johnnyreilly. Yes that's correct we've temporarily reverted this PR. I mistakenly published The best short term solution was to publish a newer patch version to revert these changes so downstream consumers of |
johnnyreilly
commented
Feb 11, 2019
Great - thanks for clarifying! |
timothyallan
commented
Feb 12, 2019
My day today: Typescript compiling slooooow..... Typescript compiling fast!!!.... Typescript compiling slooooow. |
This reverts commit 544a594.
jakobthomasson-zz
commented
Feb 12, 2019
So when is this PR gonna be merged into master again :( |
deftomat
commented
Feb 12, 2019
@jakobthomasson See #6406 for any progress |

As a lot of people is complaining about TypeScript performance in CRA, I decided to enable
asyncmode in TypeScript checker.These changes basically brings the JS compilation times to TS projects. So, recompilation took less than 1 second instead of 3 seconds in medium size project.
The problem with async mode is that type-errors are reported after Webpack ends up recompilation as TypeScript could be slower than Babel. PR allows to emit files compiled by Babel immediately and then wait for TS and show type errors in terminal later. Also, if there was no compilation errors and any type error occurs, we trigger a hot-reload with new errors to show error overlay in browser.
Also, I wanted to start a discussion about
skipLibCheck: falseoption in defaulttsconfig.json. This makes recompilations really slow and we should consider to set it totrueor at least give users a big warning to let them know that it could be really slow.The following video is showing the updated workflow with a forced 2.5 second delay for type-check to give you an idea how it works.
I'm pretty sure that PR needs some polishing and improvements but it should works as it is. Especially a "hack" with reloading the browser after type-check looks ugly to me.
cc @brunolemos as he is an initiator of an original TypeScript PR.
Should fix#5820