CRA typescript is compiling slow

twitter logo github logo ・1 min read

CRA with typescript is bit slow even after "skipLibCheck": true. Mostly I find hitting F5 better than waiting for the page to auto reload.

Also the intellisense and error detection just stop working many times. I need to close the VS Code to get it fixed.

Is there any config, extensions or anything can help for this?

Thanks

CC: @swyx

twitter logo DISCUSS (8)
markdown guide
 

You can try ctrl+shift+p and searching for restart typescript server. That's much faster than restarting VSCode. It's frustrating that you have to do this sometimes, but I do find that it occurs more often when I have plugins that are interfering.

So you can also try:
1) Making sure you don't have the deprecated version of the TsLint plugin
2) removing all of your plugins if that doesn't work
3) try running Madge to see if you have a circular dependency

 

I think, I am good with 1 and 2. I should give a try to Madge.

 

Hey @cubiclebuddha , how to you manage the context to avoid circular dependencies.

For example:
The way we generally do, I have context declared and provided in app.tsx. The app.tsx have dependency of let say page-one.tsx and I want to consume the context in page-one.tsx. (obviously in such scenario passing the props itself enough but consider a deep hierarchy that needs context) Such scenarios will create circular dependency. Do you suggest declaring the context variable in altogether separate file?

Also, I want to test some good production application(not library) built using CRA typescript with mine. So that I can compare and better understand. Do you have any such opensource application in mind?

If I have a circular dependency between a.ts and b.ts, I pull out the shared code into c.ts and use that in a and b. It shouldn’t matter if it’s function or a function component because it’s all just references.

And sadly, no I don’t know of a good example of a create React app in TypeScript. I’m only just beginning on React myself. Sadly I was stuck in Angular 1 for a long time. 🤮

Haha Welcome buddy. And we are beginner with TypeScript in React.

I tried Madge and solved all circular dependencies but still there is no significant improvement with that. So not sure if there is something else to check or it's just the way it will be.

Thanks :)

 

create-react-app v2.1.8 had a nice improvement of emitting files right away and checking the types in background asynchronously.

 

I'm having the same issue. Not sure which version of Typescript you're on, but I'm on 3.4.1. It appears to be a known issue – see Issue #30663 on GitHub.

I've temporarily downgraded to 3.1.1 and it seems to now be compiling at a reasonable speed.

 

The newest version said that it had a speed enhancement. That might help. Also, that issue (30663) has been fixed.

Classic DEV Post from Jan 29

CSS and JS Are at War, Here’s How to Stop It

There are a lot of people who love both JS and UX/CSS. If we stop labeling people just as “JS developers” or “UX developers”, we can achieve a ceasefire in the current “JS vs. CSS” war and achieve a mutually benefiting peace.

Sanket Patel profile image
Parenting, Coding, Traveling, Snapping | Co-owner @ https://redsoftware.in/ | Developer @ https://templato.com, | Maintainer @ https://github.com/reactjs/gu.reactjs.org

👋 Hey dev.to reader.

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❤️