diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index 825bfddbb4a..2bbc19881a3 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -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, diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentation.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentation.js new file mode 100644 index 00000000000..2a8c3b88e16 --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentation.js @@ -0,0 +1 @@ +declare module global { } \ No newline at end of file diff --git a/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentationWithNoDeclareKeyword.js b/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentationWithNoDeclareKeyword.js new file mode 100644 index 00000000000..4cc10f41f8f --- /dev/null +++ b/tests/baselines/reference/printerApi/printsNodeCorrectly.emptyGlobalAugmentationWithNoDeclareKeyword.js @@ -0,0 +1 @@ +module global { } \ No newline at end of file