From 102718e83719b205087f5ba97bee0e6fbd6f2fac Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 29 Mar 2023 11:00:12 -0700 Subject: [PATCH 1/2] Emit 'export as namespace ts' in our bundled d.ts output --- scripts/dtsBundler.mjs | 1 + tests/baselines/reference/api/tsserverlibrary.d.ts | 3 ++- tests/baselines/reference/api/typescript.d.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/dtsBundler.mjs b/scripts/dtsBundler.mjs index 305172d3199e1..a318675f9ff9a 100644 --- a/scripts/dtsBundler.mjs +++ b/scripts/dtsBundler.mjs @@ -400,6 +400,7 @@ function emitAsNamespace(name, moduleSymbol) { emitAsNamespace("ts", moduleSymbol); write("export = ts;", WriteTarget.Both); +write("export as namespace ts;", WriteTarget.Both); const copyrightNotice = fs.readFileSync(path.join(__dirname, "CopyrightNotice.txt"), "utf-8"); const publicContents = copyrightNotice + publicLines.join(newLine); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 760a948efc21a..5d427bd0961e2 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -11064,4 +11064,5 @@ declare namespace ts { */ function transform(source: T | T[], transformers: TransformerFactory[], compilerOptions?: CompilerOptions): TransformationResult; } -export = ts; \ No newline at end of file +export = ts; +export as namespace ts; \ No newline at end of file diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 85d2a5b10a201..f485ed0db82fb 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -7194,4 +7194,5 @@ declare namespace ts { */ function transform(source: T | T[], transformers: TransformerFactory[], compilerOptions?: CompilerOptions): TransformationResult; } -export = ts; \ No newline at end of file +export = ts; +export as namespace ts; \ No newline at end of file From 87f103c710a0eb83559fd6f6445998e6eafdf05b Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 29 Mar 2023 11:06:26 -0700 Subject: [PATCH 2/2] Fix missing ending newline --- scripts/dtsBundler.mjs | 4 ++-- tests/baselines/reference/api/tsserverlibrary.d.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/dtsBundler.mjs b/scripts/dtsBundler.mjs index a318675f9ff9a..b17d32ead8b18 100644 --- a/scripts/dtsBundler.mjs +++ b/scripts/dtsBundler.mjs @@ -403,8 +403,8 @@ write("export = ts;", WriteTarget.Both); write("export as namespace ts;", WriteTarget.Both); const copyrightNotice = fs.readFileSync(path.join(__dirname, "CopyrightNotice.txt"), "utf-8"); -const publicContents = copyrightNotice + publicLines.join(newLine); -const internalContents = copyrightNotice + internalLines.join(newLine); +const publicContents = copyrightNotice + publicLines.join(newLine) + newLine; +const internalContents = copyrightNotice + internalLines.join(newLine) + newLine; if (publicContents.includes("@internal")) { console.error("Output includes untrimmed @internal nodes!"); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5d427bd0961e2..1c385ae2ce029 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -11065,4 +11065,4 @@ declare namespace ts { function transform(source: T | T[], transformers: TransformerFactory[], compilerOptions?: CompilerOptions): TransformationResult; } export = ts; -export as namespace ts; \ No newline at end of file +export as namespace ts; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index f485ed0db82fb..b80d7c269bc82 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -7195,4 +7195,4 @@ declare namespace ts { function transform(source: T | T[], transformers: TransformerFactory[], compilerOptions?: CompilerOptions): TransformationResult; } export = ts; -export as namespace ts; \ No newline at end of file +export as namespace ts;