Does intellij IDEA need index.d.ts to import from package?
I've created an Angular typescript project (named common) and added it as package to a private npm repository. The package has an index.ts file from which all files are exported which can be used from outside the package.
export { I18nModule } from './src/app/i18n/i18n.module';
export { I18nService } from './src/app/i18n/i18n.service';
From another Angular project this package is included in the package.json dependencies.
...
"dependencies": {
...
"common": "^1.0.0"
}
...
When I use Visual Studio Code as IDE the exports can be imported inside a module/component inside the project.
import { I18nModule } from 'common';
But when I use Intellij IDEA the message Cannot resolve symbol 'I18nModule' is displayed. Does Intellij IDEA need an index.d.ts file to resolve exports from the common dependency?
Please sign in to leave a comment.
No, it doesn't necessary need index.d.ts. But you have to make sure that your index.ts file is specified in your 'common' module package.json as either "typings" or "types" value. See https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/declaration%20files/Publishing.md#including-declarations-in-your-npm-package
I've tried your solution Elena, but it doesn't work.
The types element, as stated on the github page, also contains a definition file.
My question is about resolving imports from the common package without the definition file, as possible within Visual Studio Code.