Jump to content

Typescript exporting imported interfaces

vorticalbox

so i am having a problem that I can't seem to work out.

 

foo.ts

export interface Foo {
  foo: string
}

 

interfaces.ts

export { Foo } from './foo';

 

and then the over all export 

export * as interfaces from './interfaces';

 

if you try import interfaces from the index 

 

import { interfaces } from './index';

interfaces contains nothing

 

I can, however, import Foo from the interfaces file, which is what I want to avoid

 

import { Foo } from './interfaces';
const foo: Foo = {foo: '',}

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Running tsc on that code gives a slightly better error - the

export * as interfaces from './interfaces';

isn't allowed. You can work around it by changing your index file to import interfaces, then reexport it separately

import * as interfaces from './interfaces';
export { interfaces };

 

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×