Cannot import exported interface - export not found Cannot import exported interface - export not found angular angular

Cannot import exported interface - export not found


The root cause is in Typescript and transpilation. Once TypeScript code is transpiled, interfaces/types are gone. They don't exist anymore in the emitted files.

While the types are erased, the imports/exports aren't necessarily. The reason is that there are ambiguities and that the compiler doesn't always know for sure whether something that is exported is a type or a value.

When using TypeScript 3.8 and up, all you need to do in your test.component.ts is simply this:

import { A } from './test.model';import type { B } from './test.model';


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.


You might also be able to fix that by using a new feature in Typescript 3.8 called Type-Only Imports and Exports.

So it means you can import the problematic type A like this:

import { B } from './test.model';import type { A } from './test.model';

Also be aware that Angular only seems to support Typescript 3.8 from Angular 9.1 and above.

I also recommend reading this "Leveraging Type-Only imports and exports with TypeScript 3.8" post for more details.