Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2017 RTM Painfully Slow While Typing Typescript Imports/Exports

As the title suggests, I'm looking for help on what features/extensions I might look to disable in order to resolve a specific issue with the Visual Studio 2017 IDE (Windows).

When I'm working in Typescript the following will cause a node.js process to spike CPU usage and make the IDE lock up for several seconds with each keystroke. It happens when filling in the paths for import and export statements, e.g.:

import { foo } from 'app/file/bar';
export { foo } from 'app/file/bar';

Once I start typing 'app/file/bar' everything goes to hell. Windows resource monitor shows Node.exe spiking to almost 100% cpu. Its almost like it is scanning my entire project with each keystroke so that it can try and suggest auto-complete options (but nothing ever shows up, everything just chokes).

I've made sure my tsconfig excludes node_modules.

Please help - I have so much work to get done!

like image 429
josh-sachs Avatar asked Mar 19 '17 03:03

josh-sachs


People also ask

How do I enable imports in TypeScript?

Use import myFunction from "./myModule" to bring it in. More commonly, TypeScript modules say export myFunction in which case myFunction will be one of the properties on the exported object. Use import { myFunction } from "./myModule" to bring it in.

What is import and export in TypeScript?

Export in TypeScript There is a simple design/compile time tool that you can use to stop your TypeScript code from accessing things it should not. With the export keyword, JavaScript adds a line to include the exported item to the module. There are two types of export statements: export default and normal export .

Can we export type in TypeScript?

TypeScript supports export = to model the traditional CommonJS and AMD workflow. The export = syntax specifies a single object that is exported from the module. This can be a class, interface, namespace, function, or enum.

How do I use ES module in TypeScript?

To use TypeScript with ES Modules, the TypeScript compiler configuration in tsconfig. json can be updated to process code in ES Module format. Additionally, Babel can be used for TypeScript compilation, and the TypeScript compiler will be used for type checking, as Babel can not type check TypeScript code.


1 Answers

Try installing Typescript 2.4.1 which was released 2 days ago.

This commit to the Typescript repository indicated that it would optimise the module resolution process, which should affect performance when modifying imports. After installing it I have found the performance to be much better.

I had the same issue as you (~20-30 second lag when modifying imports) but now the lag is minimal.

like image 177
Xcalibur Avatar answered Oct 15 '22 04:10

Xcalibur