mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
convert all enums into const enums
This commit is contained in:
parent
67ac2d5ff9
commit
d27bfccb79
1
.gitignore
vendored
1
.gitignore
vendored
@ -39,6 +39,7 @@ tests/cases/**/*.js.map
|
||||
scripts/debug.bat
|
||||
scripts/run.bat
|
||||
scripts/word2md.js
|
||||
scripts/buildProtocol.js
|
||||
scripts/ior.js
|
||||
scripts/*.js.map
|
||||
scripts/typings/
|
||||
|
||||
@ -42,7 +42,14 @@ class DeclarationsWalker {
|
||||
return;
|
||||
}
|
||||
// splice declaration in final d.ts file
|
||||
const text = decl.getFullText();
|
||||
let text = decl.getFullText();
|
||||
if (decl.kind === ts.SyntaxKind.EnumDeclaration && !(decl.flags & ts.NodeFlags.Const)) {
|
||||
// patch enum declaration to make them constan
|
||||
const declStart = decl.getStart() - decl.getFullStart();
|
||||
const prefix = text.substring(0, declStart);
|
||||
const suffix = text.substring(declStart + "enum".length, decl.getEnd() - decl.getFullStart());
|
||||
text = prefix + "const enum" + suffix;
|
||||
}
|
||||
this.text += `${text}\n`;
|
||||
|
||||
// recursively pull all dependencies into result dts file
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user