Merge pull request #18660 from Microsoft/globalAugmentationPrinter
Correctly print global augmentations
This commit is contained in:
Коммит
92b7dcf20a
|
@ -1863,7 +1863,9 @@ namespace ts {
|
|||
|
||||
function emitModuleDeclaration(node: ModuleDeclaration) {
|
||||
emitModifiers(node, node.modifiers);
|
||||
write(node.flags & NodeFlags.Namespace ? "namespace " : "module ");
|
||||
if (~node.flags & NodeFlags.GlobalAugmentation) {
|
||||
write(node.flags & NodeFlags.Namespace ? "namespace " : "module ");
|
||||
}
|
||||
emit(node.name);
|
||||
|
||||
let body = node.body;
|
||||
|
|
|
@ -110,6 +110,29 @@ namespace ts {
|
|||
createSourceFile("source.ts", "", ScriptTarget.ES2015)
|
||||
));
|
||||
|
||||
|
||||
printsCorrectly("emptyGlobalAugmentation", {}, printer => printer.printNode(
|
||||
EmitHint.Unspecified,
|
||||
createModuleDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ [createToken(SyntaxKind.DeclareKeyword)],
|
||||
createIdentifier("global"),
|
||||
createModuleBlock(emptyArray),
|
||||
NodeFlags.GlobalAugmentation),
|
||||
createSourceFile("source.ts", "", ScriptTarget.ES2015)
|
||||
));
|
||||
|
||||
printsCorrectly("emptyGlobalAugmentationWithNoDeclareKeyword", {}, printer => printer.printNode(
|
||||
EmitHint.Unspecified,
|
||||
createModuleDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
createIdentifier("global"),
|
||||
createModuleBlock(emptyArray),
|
||||
NodeFlags.GlobalAugmentation),
|
||||
createSourceFile("source.ts", "", ScriptTarget.ES2015)
|
||||
));
|
||||
|
||||
// https://github.com/Microsoft/TypeScript/issues/15971
|
||||
printsCorrectly("classWithOptionalMethodAndProperty", {}, printer => printer.printNode(
|
||||
EmitHint.Unspecified,
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
declare global { }
|
|
@ -0,0 +1 @@
|
|||
global { }
|
Загрузка…
Ссылка в новой задаче