From a80cdfb24223fb46fd696472c1e2b4d26653831e Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 26 Sep 2022 14:43:00 -0700 Subject: [PATCH 1/2] Fix APISample tests to not depend on the existence of the ts namespace The way we pull in the types for typescript in these tests only works when we include typescriptServices.d.ts into the project, which declares a global namespace, which then is reexported as the typescript package. This reexport is already what the current typescript.d.ts does, but now that we don't have the namespace at all, we can't do this. Instead, simulate the typescript package directly and point it at the correct d.ts file. This is a good chagne regardless of the module transform, and could be cherry-picked back to main early. --- tests/baselines/reference/APISample_Watch.js | 7 ++++--- .../baselines/reference/APISample_WatchWithDefaults.js | 7 ++++--- .../reference/APISample_WatchWithOwnWatchHost.js | 7 ++++--- tests/baselines/reference/APISample_compile.js | 7 ++++--- tests/baselines/reference/APISample_jsdoc.js | 7 ++++--- tests/baselines/reference/APISample_linter.js | 10 ++++++---- tests/baselines/reference/APISample_parseConfig.js | 10 ++++++---- tests/baselines/reference/APISample_transform.js | 10 ++++++---- tests/baselines/reference/APISample_watcher.js | 7 ++++--- tests/cases/compiler/APISample_Watch.ts | 8 ++++---- tests/cases/compiler/APISample_WatchWithDefaults.ts | 8 ++++---- .../cases/compiler/APISample_WatchWithOwnWatchHost.ts | 8 ++++---- tests/cases/compiler/APISample_compile.ts | 8 ++++---- tests/cases/compiler/APISample_jsdoc.ts | 8 ++++---- tests/cases/compiler/APISample_linter.ts | 10 +++++----- tests/cases/compiler/APISample_parseConfig.ts | 10 +++++----- tests/cases/compiler/APISample_transform.ts | 10 +++++----- tests/cases/compiler/APISample_watcher.ts | 8 ++++---- 18 files changed, 81 insertions(+), 69 deletions(-) diff --git a/tests/baselines/reference/APISample_Watch.js b/tests/baselines/reference/APISample_Watch.js index e675f2ec4eb47..5c9ad996f7f4e 100644 --- a/tests/baselines/reference/APISample_Watch.js +++ b/tests/baselines/reference/APISample_Watch.js @@ -1,8 +1,9 @@ //// [tests/cases/compiler/APISample_Watch.ts] //// -//// [index.d.ts] -declare module "typescript" { - export = ts; +//// [package.json] +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } //// [APISample_Watch.ts] diff --git a/tests/baselines/reference/APISample_WatchWithDefaults.js b/tests/baselines/reference/APISample_WatchWithDefaults.js index 63bfa4965e51e..3961a1367eae5 100644 --- a/tests/baselines/reference/APISample_WatchWithDefaults.js +++ b/tests/baselines/reference/APISample_WatchWithDefaults.js @@ -1,8 +1,9 @@ //// [tests/cases/compiler/APISample_WatchWithDefaults.ts] //// -//// [index.d.ts] -declare module "typescript" { - export = ts; +//// [package.json] +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } //// [APISample_WatchWithDefaults.ts] diff --git a/tests/baselines/reference/APISample_WatchWithOwnWatchHost.js b/tests/baselines/reference/APISample_WatchWithOwnWatchHost.js index 75444a614f952..56286921e77d7 100644 --- a/tests/baselines/reference/APISample_WatchWithOwnWatchHost.js +++ b/tests/baselines/reference/APISample_WatchWithOwnWatchHost.js @@ -1,8 +1,9 @@ //// [tests/cases/compiler/APISample_WatchWithOwnWatchHost.ts] //// -//// [index.d.ts] -declare module "typescript" { - export = ts; +//// [package.json] +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } //// [APISample_WatchWithOwnWatchHost.ts] diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index b19bc06d1e63a..3dfec01fc8f4d 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -1,8 +1,9 @@ //// [tests/cases/compiler/APISample_compile.ts] //// -//// [index.d.ts] -declare module "typescript" { - export = ts; +//// [package.json] +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } //// [APISample_compile.ts] diff --git a/tests/baselines/reference/APISample_jsdoc.js b/tests/baselines/reference/APISample_jsdoc.js index 50288c1237ea5..4763a59736202 100644 --- a/tests/baselines/reference/APISample_jsdoc.js +++ b/tests/baselines/reference/APISample_jsdoc.js @@ -1,8 +1,9 @@ //// [tests/cases/compiler/APISample_jsdoc.ts] //// -//// [index.d.ts] -declare module "typescript" { - export = ts; +//// [package.json] +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } //// [APISample_jsdoc.ts] diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 65e03d339e611..185a346d3abef 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -1,8 +1,9 @@ //// [tests/cases/compiler/APISample_linter.ts] //// -//// [index.d.ts] -declare module "typescript" { - export = ts; +//// [package.json] +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } //// [APISample_linter.ts] @@ -68,7 +69,8 @@ fileNames.forEach(fileName => { // delint it delint(sourceFile); -}); +}); + //// [APISample_linter.js] "use strict"; diff --git a/tests/baselines/reference/APISample_parseConfig.js b/tests/baselines/reference/APISample_parseConfig.js index e9dc119417cfe..422ac5c188a55 100644 --- a/tests/baselines/reference/APISample_parseConfig.js +++ b/tests/baselines/reference/APISample_parseConfig.js @@ -1,8 +1,9 @@ //// [tests/cases/compiler/APISample_parseConfig.ts] //// -//// [index.d.ts] -declare module "typescript" { - export = ts; +//// [package.json] +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } //// [APISample_parseConfig.ts] @@ -40,7 +41,8 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string): return undefined; } return ts.createProgram(rootFiles, settings.options); -} +} + //// [APISample_parseConfig.js] "use strict"; diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index db25c1bd1dd06..12f2f4ca12b81 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -1,8 +1,9 @@ //// [tests/cases/compiler/APISample_transform.ts] //// -//// [index.d.ts] -declare module "typescript" { - export = ts; +//// [package.json] +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } //// [APISample_transform.ts] @@ -20,7 +21,8 @@ const source = "let x: string = 'string'"; let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); -console.log(JSON.stringify(result)); +console.log(JSON.stringify(result)); + //// [APISample_transform.js] "use strict"; diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index d86eb60e6777b..a66fb1cc3ffdf 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -1,8 +1,9 @@ //// [tests/cases/compiler/APISample_watcher.ts] //// -//// [index.d.ts] -declare module "typescript" { - export = ts; +//// [package.json] +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } //// [APISample_watcher.ts] diff --git a/tests/cases/compiler/APISample_Watch.ts b/tests/cases/compiler/APISample_Watch.ts index 154e5f90b0e71..fccc413756468 100644 --- a/tests/cases/compiler/APISample_Watch.ts +++ b/tests/cases/compiler/APISample_Watch.ts @@ -1,12 +1,12 @@ // @module: commonjs // @skipLibCheck: true -// @includebuiltfile: typescriptServices.d.ts // @noImplicitAny:true // @strictNullChecks:true -// @filename: node_modules/typescript/index.d.ts -declare module "typescript" { - export = ts; +// @filename: node_modules/typescript/package.json +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } // @filename: APISample_Watch.ts diff --git a/tests/cases/compiler/APISample_WatchWithDefaults.ts b/tests/cases/compiler/APISample_WatchWithDefaults.ts index d028d109275ca..7efada18dbad7 100644 --- a/tests/cases/compiler/APISample_WatchWithDefaults.ts +++ b/tests/cases/compiler/APISample_WatchWithDefaults.ts @@ -1,12 +1,12 @@ // @module: commonjs // @skipLibCheck: true -// @includebuiltfile: typescriptServices.d.ts // @noImplicitAny:true // @strictNullChecks:true -// @filename: node_modules/typescript/index.d.ts -declare module "typescript" { - export = ts; +// @filename: node_modules/typescript/package.json +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } // @filename: APISample_WatchWithDefaults.ts diff --git a/tests/cases/compiler/APISample_WatchWithOwnWatchHost.ts b/tests/cases/compiler/APISample_WatchWithOwnWatchHost.ts index 18cb5766ce331..794be55855d83 100644 --- a/tests/cases/compiler/APISample_WatchWithOwnWatchHost.ts +++ b/tests/cases/compiler/APISample_WatchWithOwnWatchHost.ts @@ -1,12 +1,12 @@ // @module: commonjs // @skipLibCheck: true -// @includebuiltfile: typescriptServices.d.ts // @noImplicitAny:true // @strictNullChecks:true -// @filename: node_modules/typescript/index.d.ts -declare module "typescript" { - export = ts; +// @filename: node_modules/typescript/package.json +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } // @filename: APISample_WatchWithOwnWatchHost.ts diff --git a/tests/cases/compiler/APISample_compile.ts b/tests/cases/compiler/APISample_compile.ts index 49d821fae16b3..ed5d5723f3c0a 100644 --- a/tests/cases/compiler/APISample_compile.ts +++ b/tests/cases/compiler/APISample_compile.ts @@ -1,12 +1,12 @@ // @module: commonjs // @skipLibCheck: true -// @includebuiltfile: typescriptServices.d.ts // @noImplicitAny:true // @strictNullChecks:true -// @filename: node_modules/typescript/index.d.ts -declare module "typescript" { - export = ts; +// @filename: node_modules/typescript/package.json +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } // @filename: APISample_compile.ts diff --git a/tests/cases/compiler/APISample_jsdoc.ts b/tests/cases/compiler/APISample_jsdoc.ts index 22f98f4797f36..d166e435feb15 100644 --- a/tests/cases/compiler/APISample_jsdoc.ts +++ b/tests/cases/compiler/APISample_jsdoc.ts @@ -1,12 +1,12 @@ // @module: commonjs // @skipLibCheck: true -// @includebuiltfile: typescriptServices.d.ts // @noImplicitAny:true // @strictNullChecks:true -// @filename: node_modules/typescript/index.d.ts -declare module "typescript" { - export = ts; +// @filename: node_modules/typescript/package.json +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } // @filename: APISample_jsdoc.ts diff --git a/tests/cases/compiler/APISample_linter.ts b/tests/cases/compiler/APISample_linter.ts index a6ae00944bb07..7d485e4d85ff1 100644 --- a/tests/cases/compiler/APISample_linter.ts +++ b/tests/cases/compiler/APISample_linter.ts @@ -1,12 +1,12 @@ // @module: commonjs // @skipLibCheck: true -// @includebuiltfile: typescriptServices.d.ts // @noImplicitAny:true // @strictNullChecks:true -// @filename: node_modules/typescript/index.d.ts -declare module "typescript" { - export = ts; +// @filename: node_modules/typescript/package.json +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } // @filename: APISample_linter.ts @@ -72,4 +72,4 @@ fileNames.forEach(fileName => { // delint it delint(sourceFile); -}); \ No newline at end of file +}); diff --git a/tests/cases/compiler/APISample_parseConfig.ts b/tests/cases/compiler/APISample_parseConfig.ts index 243e25f995b2a..a4bcbc4aea8c5 100644 --- a/tests/cases/compiler/APISample_parseConfig.ts +++ b/tests/cases/compiler/APISample_parseConfig.ts @@ -1,12 +1,12 @@ // @module: commonjs // @skipLibCheck: true -// @includebuiltfile: typescriptServices.d.ts // @noImplicitAny:true // @strictNullChecks:true -// @filename: node_modules/typescript/index.d.ts -declare module "typescript" { - export = ts; +// @filename: node_modules/typescript/package.json +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } // @filename: APISample_parseConfig.ts @@ -44,4 +44,4 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string): return undefined; } return ts.createProgram(rootFiles, settings.options); -} \ No newline at end of file +} diff --git a/tests/cases/compiler/APISample_transform.ts b/tests/cases/compiler/APISample_transform.ts index a750d0d359596..b2e001071bb1a 100644 --- a/tests/cases/compiler/APISample_transform.ts +++ b/tests/cases/compiler/APISample_transform.ts @@ -1,12 +1,12 @@ // @module: commonjs // @skipLibCheck: true -// @includebuiltfile: typescriptServices.d.ts // @noImplicitAny:true // @strictNullChecks:true -// @filename: node_modules/typescript/index.d.ts -declare module "typescript" { - export = ts; +// @filename: node_modules/typescript/package.json +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } // @filename: APISample_transform.ts @@ -24,4 +24,4 @@ const source = "let x: string = 'string'"; let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); -console.log(JSON.stringify(result)); \ No newline at end of file +console.log(JSON.stringify(result)); diff --git a/tests/cases/compiler/APISample_watcher.ts b/tests/cases/compiler/APISample_watcher.ts index dfae23488c6e3..824b083b6be66 100644 --- a/tests/cases/compiler/APISample_watcher.ts +++ b/tests/cases/compiler/APISample_watcher.ts @@ -1,12 +1,12 @@ // @module: commonjs // @skipLibCheck: true -// @includebuiltfile: typescriptServices.d.ts // @noImplicitAny:true // @strictNullChecks:true -// @filename: node_modules/typescript/index.d.ts -declare module "typescript" { - export = ts; +// @filename: node_modules/typescript/package.json +{ + "name": "typescript", + "types": "/.ts/typescript.d.ts" } // @filename: APISample_watcher.ts From d06719f3c383426b0e4607cbe10c418aed8105a4 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Oct 2022 13:31:44 -0700 Subject: [PATCH 2/2] Remove unused constant --- src/harness/harnessIO.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/harness/harnessIO.ts b/src/harness/harnessIO.ts index 87148c13492a7..dfa3cf68b75c5 100644 --- a/src/harness/harnessIO.ts +++ b/src/harness/harnessIO.ts @@ -177,8 +177,6 @@ namespace Harness { } export const libFolder = "built/local/"; - const tcServicesFileName = ts.combinePaths(libFolder, "typescriptServices.js"); - export const tcServicesFile = IO.readFile(tcServicesFileName) + IO.newLine() + `//# sourceURL=${IO.resolvePath(tcServicesFileName)}`; export type SourceMapEmitterCallback = ( emittedFile: string,