I tried to export an interface in a NgModule-declaration and export and getting this error already in the editor (Visual Studio Code): [ts] 'MyInterface' only refers to a type, but is being used as a value here.
Here is the example code Edit-1:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { MaterialModule } from '@angular/material';
import { MyInterface } from './my.interface';
import { MyService } from './my.service';
@NgModule({
imports: [ CommonModule, FormsModule, MaterialModule.forRoot() ],
declarations: [ MyInterface],//<- this is causing the message
exports: [ MyInterface],
providers: [ MyService ]
})
export class MyModule { }
One part of an explanation I found in the answer to this post: "since interfaces are erased at runtime in TypeScript". I'm currently refactoring my app to feature modules, so I cannot test it right now: Can I use the interfaces only by import from './mypathto/my.interface'?
I tried to export an interface in a NgModule-declaration
what do you mean?