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

export { MyType } from 'module' causes error #21194

Closed
pmunin opened this issue Jan 16, 2018 · 2 comments
Closed

export { MyType } from 'module' causes error #21194

pmunin opened this issue Jan 16, 2018 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@pmunin
Copy link

pmunin commented Jan 16, 2018

TypeScript Version: 2.6.2

Code

//module1.ts
export type MyModule1Type = {
   prop1:string;
}

//module2.exportAll.ts
export * from './module1.ts'   
       //works fine

//module2.exportSelectedTypes.ts
export {MyModule1Type as MyModule2Type} from './module1.ts'
       //Cannot re-export a type when the '--isolatedModules' flag is provided


//module2.exportSelectedTypes.UglyWorkaround.ts
import {MyModule1Type} from './module1.ts'
export type MyModule2Type=MyModule1Type
       //works fine

Expected behavior:
module2.exportSelectedTypes.ts compiles successfully, so we don't have to use ugly workaround

Actual behavior:
module2.exportSelectedTypes.ts causes compilation error:
Cannot re-export a type when the '--isolatedModules' flag is provided

@ghost
Copy link

ghost commented Jan 16, 2018

We can't compile export {MyModule1Type as MyModule2Type} from './module1.ts' without knowing whether MyModule1Type is a type. If it is, we compile to nothing. If it isn't, we compile to exports.MyModule1Type = module1_1.MyModule2Type;.
The --isolatedModules flag is intended to prevent writing code that can't be transpiled without information about other modules, so it's working as intended in this case.

@ghost ghost added the Working as Intended The behavior described is the intended behavior; this is not a bug label Jan 16, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants