Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export submodule #4795

Closed
unional opened this issue Sep 14, 2015 · 3 comments
Closed

Re-export submodule #4795

unional opened this issue Sep 14, 2015 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@unional
Copy link
Contributor

unional commented Sep 14, 2015

file1.ts

export function A() {}
export function B() {}

Currently, if I want to export file1.ts as a sub module, I have to do:
file2.ts

import * as subModule from "./file1.ts";

export var subModule = subModule;  // or,
export { subModule }

Is there an easier way such as:

export { * from subModule } from "./file1.ts"

Would it be ES6/ES7 compatible I didn't see any sample regarding this usage.

One question need to solve is how to handle any default export in the sub module.

@basarat
Copy link
Contributor

basarat commented Sep 15, 2015

Recommended

export * from "./file1.ts"

or an even older syntax (pre es6):

export import subModule = require('./file1.ts');

Note : They are not exactly equivalent 🌹

@mhegazy
Copy link
Contributor

mhegazy commented Sep 15, 2015

there is an ES7 proposal for this: https://github.com/leebyron/ecmascript-more-export-from#proposed-additions

Once this reaches Stage 3, TypeScript will need to support it.

@mhegazy
Copy link
Contributor

mhegazy commented Sep 15, 2015

i have filed #4813 to track this work.

@mhegazy mhegazy closed this as completed Sep 15, 2015
@mhegazy mhegazy added the Duplicate An existing issue was already created label Sep 15, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants