2

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?

3
  • What's wrong with qualified export? Commented Jul 27, 2020 at 5:11
  • @majkrzak I have tried export, export type, export instance and a bunch of others, none of them compiles Commented Jul 27, 2020 at 5:12
  • what exactly is not working, the export or the import? Commented Jul 27, 2020 at 5:19

2 Answers 2

4

Should work:

export interface A {
 ...
}

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

const var1: A = ...
Sign up to request clarification or add additional context in comments.

1 Comment

According to OP it does not ¯\_(ツ)_/¯
0

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 ;)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.