Monday, 29 May 2017

Export 'default' using index.ts

I've got the following project structure:

build/
    build.ts
config/
    config.ts
    index.ts
...

The config.ts contains a default exported type like this:

export default {
    myProp: {
        someProp: "someValue"
    }
}

And the index.ts within config/ looks like this:

export * from './config';

Now I'd like to import the config type within build.ts like this:

import config from '../config';

But when using it (e.g. with config.myProp), it tells me that myProp doesn't exist on index.ts.

According to the official module documentation here, this should work perfectly fine. Am I missing something here?



via null null

No comments:

Post a Comment