Skip to content

Certain resolution-dependent enum emit isn't correctly flagged as an error under isolatedModules #56153

Description

@magic-akari

🔎 Search Terms

  • isolatedModules
  • enum
  • cross module
  • export

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ______ and _______
  • This changed in commit or PR _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

Test on Playground with version 3.9.7 and version 5.2.2, got the same incorrect result.

⏯ Playground Link

Workbench Repro

💻 Code

// @showEmit// @isolatedModules: true// @filename: foo.tsexportenumFoo{A=10}// @filename: index.tsimport{Foo}from"./foo";exportenumBar{B=Foo.A,C}

Workbench Repro

🙁 Actual behavior

Please notice the value of Bar.C

import{Foo}from"./foo";exportvarBar;(function(Bar){Bar[Bar["B"]=10]="B";Bar[Bar["C"]=11]="C";})(Bar||(Bar={}));

🙂 Expected behavior

Emit a warning or an error, and generate code that does not rely on other imports.

Example:

import{Foo}from"./foo";exportvarBar;(function(Bar){Bar[Bar["B"]=Foo.A]="B";Bar[Bar["C"]=void0]="C";})(Bar||(Bar={}));

The Bar.C is void 0, since it cannot be refered.

Additional information about the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions