Skip to content

typescriptServices.js in the official npm package should be generated with preserveConstEnums on #1104

Closed
@Arnavion

Description

@Arnavion

The tsc.js should not suppress const enums, otherwise enums like ModuleKind and SyntaxKind are not present in the generated JavaScript. As a result, compiler wrappers, etc. not written in TypeScript cannot use those enums and must resort to hard-coding their values in their source.

Code that worked before:

this._options = {
    module: ts.ModuleKind.None,
    out: "output.js",
...

must now be written like this:

this._options = {
    module: 0 /* ts.ModuleKind.None */,
    out: "output.js",
...

Only wrappers themselves written in TypeScript will not have a problem, since the compiler will do this transformation for them.

I understand that you may not want to disable this optimization for tsc.js itself. If the intent is to have a separate file to export the API (#372) instead of exporting it from tsc.js, then that file should be compiled with preserveConstEnums on.

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions