Skip to content

Compile-on-save does not honour const enums when declaration is in an external file #1880

@NoelAbrahams

Description

@NoelAbrahams

Hi,

TS: 1.4

To reproduce.

  • Create a TypeScript project in Visual Studio with "Compile on save" set to on.

  • Add file enums.d.ts with code:

    declare module enums {
      const enum Bar {
          one = 0,
          two = 1,
      }
    }
  • Add file foo.ts with code:

    /// <reference path="enums.d.ts" />
    var foo = enums.Bar.one;
  • Compile the project and check that the output foo.js is correct:

    /// <reference path="enums.d.ts" />
    var foo = 0 /* one */;
  • Now trigger compile-on-save by saving foo.ts.

  • The output in foo.js is now broken:

    /// <reference path="enums.d.ts" />
    var foo = enums.Bar.one;

The following point is relevant: If the enum declaration is moved to foo.ts then things work correctly.

This is a significant issue because the code fails with a runtime error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions