Skip to content

Invalid emit for class+namespace using module=commonJs in TS 3.9 #37118

Description

@mjbvz

TypeScript Version: 3.9.0-dev.20200228

Search Terms:

  • export
  • namespace

Code
With target = ES2017, module = commonJS

exportclassColor{staticreadonlyx=newColor();}exportnamespaceColor{exportconsta=1}

Expected behavior:
In TS 3.8, this emits:

Object.defineProperty(exports,"__esModule",{value: true});classColor{}exports.Color=Color;Color.x=newColor();(function(Color){Color.a=1;})(Color=exports.Color||(exports.Color={}));

Actual behavior:
In TS 3.9, this emits:

Object.defineProperty(exports,"__esModule",{value: true});constColor=/** @class */(()=>{classColor{}Color.x=newColor();returnColor;})();exports.Color=Color;(function(Color){Color.a=1;})(Color=exports.Color||(exports.Color={}));exports.Color=Color;

Which is not valid since it tries to reassign a constant value: Color = exports.Color

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions