Reputation: 6301
I created a new Angular project and a new module inside that project using the CLI. If I try to import the newly created module in app.module.ts
the Intellisense doesn't work and it can't find the module to auto-import it. I didn't change anything inside the tsconfig.json
files.
Any idea what could cause it?
EDIT: A manual import works fine, but I'm asking about the auto-import functionality.
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
declarations: [],
imports: [
CommonModule
]
})
export class TestModule { }
Upvotes: 3
Views: 1899
Reputation: 164
I found the source of the problem in the tsconfig.json
inside the project's root folder.
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
If you just change it to this
{
"extends": "./tsconfig.base.json"
}
VS Code auto-import starts working
As I understand it the main problem is "files": [], typescript stops seeing all files that are not included in the project.
github.com/microsoft/TypeScript/issues/39632
https://github.com/angular/vscode-ng-language-service/issues/876
People offer the same solution
Upvotes: 4
Reputation: 93
Try exporting child components inside Testmodule like this
@NgModule({
declarations: [],
imports: [CommonModule],
exports: [components]
})
export class TestModule { }
Upvotes: -1