Export multiple interfaces from a Typescript file

Viewed 1286

There are multiple interfaces in my typescript file which I need to export. Something like:

interface A {
 ...
}

interface B {
 ...
}

Then in another file I need to use

const var : A

I have searched and tried multiple things, but till not only export default works for me. But export default only works for one interface. I can't export multiple. Is there a workaround for this?

2 Answers

Should work:

export interface A {
 ...
}

export interface B {
 ...
}
import type { A, B } from '...';

const var1: A = ...

I had the same problem :D... In one (generated) ts file i had multiple exported interfaces, and including multiple interfaces worked. In another file it didn't. I am having a vue3 project. Recompiling the project / restarting the development server resolved the issue in the end. (i swear i tried that multiple times and it did not work at first ;)

Related