I am using JSPM and Typescript for an Angular2 project and Webstorm 11 seems confused about the import paths of the TS classes.
The first import is the correct one:
import {Component} from "angular2/core";
But the other two are referencing directly from the jspm_packages
folder importing this two paths incorectly:
import {Component} from "../../jspm_packages/npm/[email protected]/src/core/metadata";
import {Component} from "../../jspm_packages/npm/[email protected]/ts/src/core/metadata";
I have ignored both node_modules
and jspm_packages
in tsconfig.json
as Webstorm seems to recognize it, but no luck so far.
Is there any way i can configure Webstorm to automatically import the correct module and ignore the other two?
With WebStorm, you can run and debug client-side TypeScript code and TypeScript code running in Node. js. Learn more from Running and debugging TypeScript.
If we want to go a step further and sort the imports, we can go to Preferences / Settings | Editor | Code Style | JavaScript or TypeScript and select Sort imports by modules on the Imports tab.
In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | General | Auto Import. On the Auto Import page that opens, use the checkboxes in the TypeScript/JavaScript area to enable or disable import generation on code completion.
Quickly remove any unused imports and more. With the Optimize imports action (Ctrl+Alt+O), you can quickly remove any unused imports, merge imports from the same module, and optionally sort the import statements.
jspm is currently not supported by Webstorm. But node.js is. If you install angular2 via npm the imports work:
npm i [email protected] es6-promise@^3.0.2 es6-shim@^0.33.3 [email protected] [email protected] [email protected] --save
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With