mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-10 13:40:56 -06:00
Merge pull request #11605 from Microsoft/vladima/convert-enums-to-const
convert all enums to const enums when building protocol.d.ts
This commit is contained in:
parent
a09f00bb11
commit
6417dab60b
1
.gitignore
vendored
1
.gitignore
vendored
@ -41,6 +41,7 @@ tests/cases/**/*.js.map
|
||||
scripts/debug.bat
|
||||
scripts/run.bat
|
||||
scripts/word2md.js
|
||||
scripts/buildProtocol.js
|
||||
scripts/ior.js
|
||||
scripts/buildProtocol.js
|
||||
scripts/*.js.map
|
||||
|
||||
@ -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