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

es6 modules without imports or nontrivial exports compile to ambiguous output #28890

Closed
dgoldstein0 opened this issue Dec 7, 2018 · 3 comments
Labels
Bug A bug in TypeScript Domain: ES Modules The issue relates to import/export style module behavior
Milestone

Comments

@dgoldstein0
Copy link

TypeScript Version: 3.2.2

Search Terms:
ambiguous es6 modules

Code

// asdf.ts
export {};

compile with tsc --module ES6 asdf.ts

Expected behavior:

compiles to something that is obviously a module, e.g. preserves the export {}.

Actual behavior:

output is an empty file which could be a script instead of a module.

This causes issues in complex build pipelines - e.g. if we then try to put the output through tsc --module amd, the output differs from if we had only done tsc --module amd in the first place.

Playground Link: http://www.typescriptlang.org/play/#src=export%20%7B%20%7D%3B

I can't get es6 output in the playground for this

Related Issues: n/a

@dgoldstein0 dgoldstein0 changed the title es6 modules without imports or exports compile to ambiguous output es6 modules without imports or nontrivial exports compile to ambiguous output Dec 7, 2018
@weswigham weswigham added the Bug A bug in TypeScript label Dec 7, 2018
@weswigham
Copy link
Member

I agree, if --module es6 is set, we aughta be preserving export {};.

@dgoldstein0
Copy link
Author

this probably deserves a Domain: ES Modules tag? don't know how to add that

@weswigham weswigham added the Domain: ES Modules The issue relates to import/export style module behavior label Dec 9, 2018
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 14, 2019
@BPScott
Copy link

BPScott commented Feb 15, 2021

Fixed in #38696

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: ES Modules The issue relates to import/export style module behavior
Projects
None yet
Development

No branches or pull requests

4 participants