Encountered a similar issue recently and after conducting some thorough research and referring to various resources, I found the solution. In your case, it's essential to ensure correct import statements. For example, in order to import {head, Util} from "../../brat/brat"; make sure to use import {head, Util} from "../../brat/brat.d";
When importing modules, remember not to include the file extension while your module is named brat.d.ts.
In my scenario, there was a conflict with a file/module named item.ts which included the exported class 'Item'.
export class Item {
public reference: string;
public name: string;
constructor( name: string, reference: string) {
this.reference = reference;
this.name = name;
}
get getReference(): string {
return this.reference;
}
get getName(): string {
return this.name;
}
set setName(newName: string) {
this.name = newName;
}
}
Upon importing with
import { Item } from './models/item';
in the component where the class is used, and saving (Ctrl+s), an error message appeared stating
ERROR in src/app/app.component.ts(2,20): error TS2306: File 'D:/PROJET/Personal Resoruces/Angular2/DuckFowl/src/app/Models/item.ts' is not a module.
.
By changing the filename to
item.models.ts without altering the class itself, the issue was resolved. Keeping the module name distinct from the exported element can be beneficial, but the choice of names is flexible.
Remember to save both the file containing the exported element and the Component using Ctrl + s to refresh Angular CLI.
This approach successfully resolved the problem for me.
Screen shot of project component and model
My Configuration Details:
Angular CLI: 8.3.6
Node: 10.16.0
OS: win32 x64
Angular: 8.2.8
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.803.6
@angular-devkit/build-angular 0.803.6
@angular-devkit/build-optimizer 0.803.6
@angular-devkit/build-webpack 0.803.6
@angular-devkit/core 8.3.6
@angular-devkit/schematics 8.3.6
@angular/cli 8.3.6
@ngtools/webpack 8.3.6
@schematics/angular 8.3.6
@schematics/update 0.803.6
rxjs 6.4.0
typescript 3.5.3
webpack 4.39.2
Spread Love & Lead On!