Search code examples
angulartypescriptecmascript-6

Cannot import exported interface - export not found


I reduced the issue to this example:

test.model.ts

export class A {
    a: number;
}

export interface B {
    b: number;
}

test.component.ts

import { Component, Input } from '@angular/core';
import { A, B } from './test.model';

@Component({
    selector: 'test',
    template: '<h1>test</h1>'
})
export class TestComponent {

    //This works fine
    @Input() foo: A;

    //Does NOT work - export 'B' was not found in './test.model'
    @Input() bar: B;

}

When I want to use an interface I get following warning:

WARNING in ./src/app/.../test.component.ts
21:76 export 'B' was not found in './test.model'

However, using a class is OK. Any hint?

UPDATE: It seems to be somehow related to this issue: https://github.com/webpack/webpack/issues/2977


Solution

  • Yesterday I found another question here and the solution it to declare the exported interface it a separate file. With one interface per file, it works for me without any warnings.