Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
102
rated 0 times [  106] [ 4]  / answers: 1 / hits: 18677  / 7 Years ago, mon, may 29, 2017, 12:00:00

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?


More From » node.js

 Answers
42

In config/index.ts re-export config as such:



export {default as config} from './config';


Then in build/build.ts:



import {config} from '../config;

[#57631] Thursday, May 25, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ibrahimgilbertoz

Total Points: 420
Total Questions: 112
Total Answers: 92

Location: Bonaire
Member since Sat, May 1, 2021
3 Years ago
;