SillyQuestion
SillyQuestion

Reputation: 113

Are there any downsides of using 'export * from' in an index.ts file?

We are using index.ts to export all the symbols in that folder, that are exported by files in that folder.

Are there any risks to using export * from <filename>;?

Currently we use export {item1, item2, item3} from <filename>; which makes for extra manual effort to keep index.ts updated.

Upvotes: 1

Views: 696

Answers (1)

Dimava
Dimava

Reputation: 10841

// a.ts
export const x = 123

// b.ts
export const x = 'qwe'

// c.ts
export * from './a.ts'
export * from './b.ts'
// ^ Module './a' has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity.ts(2308)

is the only possible problem, and it errors, so there's none

Upvotes: 1

Related Questions