Skip to content

No error using imports/exports with --module=none and --target=es2015+ #39603

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

Open
andrewbranch opened this issue Jul 14, 2020 · 3 comments
Open
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Rescheduled This issue was previously scheduled to an earlier milestone
Milestone

Comments

@andrewbranch
Copy link
Member

andrewbranch commented Jul 14, 2020

TypeScript Version: 4.0.0-dev.20200713

Search Terms: module none target

Code

// @module: none
// @target: es2015
export class Foo {}

Expected behavior:

TS1148 Cannot use imports, exports, or module augmentations when '--module' is 'none' and emits export class Foo {}

Actual behavior:

No error, and emits as CommonJS.

Playground Link: https://www.typescriptlang.org/play/?module=0#code/KYDwDg9gTgLgBAYwDYEMDOa4DEITgbwF8AoIA

Related issues: #39597

@andrewbranch andrewbranch added Bug A bug in TypeScript Breaking Change Would introduce errors in existing code labels Jul 14, 2020
@andrewbranch andrewbranch added this to the TypeScript 4.1 milestone Jul 14, 2020
@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Dec 11, 2020
@DetachHead
Copy link
Contributor

this section of the documentation should also be updated to state that it's not valid to have imports/exports when module is none

@DetachHead
Copy link
Contributor

additionally if you set "outFile", not only is there no error but it also doesn't emit

@ethan-xd
Copy link

“+1 I also experiencing same issue ….”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests

4 participants