From 34cf76ca3bcfa14dadc925b884d007e75bb342d3 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 26 Jun 2023 14:30:23 -0700 Subject: [PATCH] Replace lib file instead of changing target --- .../forceConsistentCasingInFileNames.ts | 3 +-- .../unittests/tscWatch/moduleResolution.ts | 13 +++++++++---- .../with-nodeNext-resolution.js | 18 +++++++++--------- .../moduleResolution/diagnostics-from-cache.js | 16 ++++++++-------- .../type-reference-resolutions-reuse.js | 18 +++++++++--------- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/testRunner/unittests/tscWatch/forceConsistentCasingInFileNames.ts b/src/testRunner/unittests/tscWatch/forceConsistentCasingInFileNames.ts index 9eb0a025deb..635ad80aff0 100644 --- a/src/testRunner/unittests/tscWatch/forceConsistentCasingInFileNames.ts +++ b/src/testRunner/unittests/tscWatch/forceConsistentCasingInFileNames.ts @@ -295,14 +295,13 @@ a;b; }), "/Users/name/projects/web/tsconfig.json": JSON.stringify({ compilerOptions: { - target: "es5", module: "nodenext", moduleResolution: "nodenext", forceConsistentCasingInFileNames: true, traceResolution: true, } }), - [libFile.path]: libFile.content, + [libFile.path.replace("lib.d.ts", "lib.esnext.full.d.ts")]: libFile.content, }, { currentDirectory: "/Users/name/projects/web" }), }); diff --git a/src/testRunner/unittests/tscWatch/moduleResolution.ts b/src/testRunner/unittests/tscWatch/moduleResolution.ts index 07de6c69fe0..88d9fd45f82 100644 --- a/src/testRunner/unittests/tscWatch/moduleResolution.ts +++ b/src/testRunner/unittests/tscWatch/moduleResolution.ts @@ -89,7 +89,6 @@ describe("unittests:: tsc-watch:: moduleResolution", () => { path: `/user/username/projects/myproject/tsconfig.json`, content: JSON.stringify({ compilerOptions: { - target: "es5", module: "nodenext", moduleResolution: "nodenext", outDir: "./dist", @@ -125,7 +124,10 @@ describe("unittests:: tsc-watch:: moduleResolution", () => { export function thing(): void {} ` }, - libFile + { + ...libFile, + path: libFile.path.replace("lib.d.ts", "lib.esnext.full.d.ts") + } ], { currentDirectory: "/user/username/projects/myproject" }), commandLineArgs: ["-w", "--traceResolution"], edits: [{ @@ -354,7 +356,7 @@ describe("unittests:: tsc-watch:: moduleResolution", () => { { path: `/user/username/projects/myproject/tsconfig.json`, content: JSON.stringify({ - compilerOptions: { target: "es5", module: "node16", moduleResolution: "node16" }, + compilerOptions: { module: "node16", moduleResolution: "node16" }, }) }, { @@ -424,7 +426,10 @@ describe("unittests:: tsc-watch:: moduleResolution", () => { path: `/user/username/projects/myproject/node_modules/@types/pkg2/index.d.ts`, content: `export const x = 10;` }, - libFile + { + ...libFile, + path: libFile.path.replace("lib.d.ts", "lib.es2022.full.d.ts"), + } ], { currentDirectory: "/user/username/projects/myproject" }), commandLineArgs: ["-w", "--traceResolution"], edits: [ diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js index 5ce4e93b9bb..319c2c17b16 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js @@ -13,9 +13,9 @@ export function foo(): void; {"name":"yargs","version":"17.0.12","exports":{".":{"types":{"import":"./index.d.mts","default":"./index.d.ts"}}}} //// [/Users/name/projects/web/tsconfig.json] -{"compilerOptions":{"target":"es5","module":"nodenext","moduleResolution":"nodenext","forceConsistentCasingInFileNames":true,"traceResolution":true}} +{"compilerOptions":{"module":"nodenext","moduleResolution":"nodenext","forceConsistentCasingInFileNames":true,"traceResolution":true}} -//// [/a/lib/lib.d.ts] +//// [/a/lib/lib.esnext.full.d.ts] /// interface Boolean {} interface Function {} @@ -83,8 +83,8 @@ Resolving real path for '/Users/name/projects/web/node_modules/@types/yargs/inde File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -../../../../a/lib/lib.d.ts - Default library for target 'es5' +../../../../a/lib/lib.esnext.full.d.ts + Default library for target 'esnext' node_modules/@types/yargs/index.d.ts Imported via "yargs" from file 'src/bin.ts' with packageId 'yargs/index.d.ts@17.0.12' Entry point for implicit type library 'yargs' with packageId 'yargs/index.d.ts@17.0.12' @@ -97,20 +97,20 @@ src/bin.ts Program root files: ["/Users/name/projects/web/src/bin.ts"] -Program options: {"target":1,"module":199,"moduleResolution":99,"forceConsistentCasingInFileNames":true,"traceResolution":true,"watch":true,"explainFiles":true,"configFilePath":"/Users/name/projects/web/tsconfig.json"} +Program options: {"module":199,"moduleResolution":99,"forceConsistentCasingInFileNames":true,"traceResolution":true,"watch":true,"explainFiles":true,"configFilePath":"/Users/name/projects/web/tsconfig.json"} Program structureReused: Not Program files:: -/a/lib/lib.d.ts +/a/lib/lib.esnext.full.d.ts /Users/name/projects/web/node_modules/@types/yargs/index.d.ts /Users/name/projects/web/src/bin.ts Semantic diagnostics in builder refreshed for:: -/a/lib/lib.d.ts +/a/lib/lib.esnext.full.d.ts /Users/name/projects/web/node_modules/@types/yargs/index.d.ts /Users/name/projects/web/src/bin.ts Shape signatures in builder refreshed for:: -/a/lib/lib.d.ts (used version) +/a/lib/lib.esnext.full.d.ts (used version) /users/name/projects/web/node_modules/@types/yargs/index.d.ts (used version) /users/name/projects/web/src/bin.ts (used version) @@ -125,7 +125,7 @@ PolledWatches:: {"pollingInterval":2000} FsWatches:: -/a/lib/lib.d.ts: *new* +/a/lib/lib.esnext.full.d.ts: *new* {} /users/name/projects: *new* {} diff --git a/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js b/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js index 36cca1f87df..849445e987f 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js @@ -1,7 +1,7 @@ currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false Input:: //// [/user/username/projects/myproject/tsconfig.json] -{"compilerOptions":{"target":"es5","module":"nodenext","moduleResolution":"nodenext","outDir":"./dist","declaration":true,"declarationDir":"./types"}} +{"compilerOptions":{"module":"nodenext","moduleResolution":"nodenext","outDir":"./dist","declaration":true,"declarationDir":"./types"}} //// [/user/username/projects/myproject/package.json] {"name":"@this/package","type":"module","exports":{".":{"default":"./dist/index.js","types":"./types/index.d.ts"}}} @@ -16,7 +16,7 @@ export function thing(): void {} export function thing(): void {} -//// [/a/lib/lib.d.ts] +//// [/a/lib/lib.esnext.full.d.ts] /// interface Boolean {} interface Function {} @@ -59,17 +59,17 @@ File '/package.json' does not exist. Program root files: ["/user/username/projects/myproject/index.ts","/user/username/projects/myproject/index2.ts"] -Program options: {"target":1,"module":199,"moduleResolution":99,"outDir":"/user/username/projects/myproject/dist","declaration":true,"declarationDir":"/user/username/projects/myproject/types","watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program options: {"module":199,"moduleResolution":99,"outDir":"/user/username/projects/myproject/dist","declaration":true,"declarationDir":"/user/username/projects/myproject/types","watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} Program structureReused: Not Program files:: -/a/lib/lib.d.ts +/a/lib/lib.esnext.full.d.ts /user/username/projects/myproject/index.ts /user/username/projects/myproject/index2.ts No cached semantic diagnostics in the builder:: Shape signatures in builder refreshed for:: -/a/lib/lib.d.ts (used version) +/a/lib/lib.esnext.full.d.ts (used version) /user/username/projects/myproject/index.ts (computed .d.ts during emit) /user/username/projects/myproject/index2.ts (computed .d.ts during emit) @@ -80,7 +80,7 @@ PolledWatches:: {"pollingInterval":500} FsWatches:: -/a/lib/lib.d.ts: *new* +/a/lib/lib.esnext.full.d.ts: *new* {} /user/username/projects/myproject/index.ts: *new* {} @@ -156,10 +156,10 @@ File '/package.json' does not exist according to earlier cached lookups. Program root files: ["/user/username/projects/myproject/index.ts","/user/username/projects/myproject/index2.ts"] -Program options: {"target":1,"module":199,"moduleResolution":99,"outDir":"/user/username/projects/myproject/dist","declaration":true,"declarationDir":"/user/username/projects/myproject/types","watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program options: {"module":199,"moduleResolution":99,"outDir":"/user/username/projects/myproject/dist","declaration":true,"declarationDir":"/user/username/projects/myproject/types","watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} Program structureReused: SafeModules Program files:: -/a/lib/lib.d.ts +/a/lib/lib.esnext.full.d.ts /user/username/projects/myproject/index.ts /user/username/projects/myproject/index2.ts diff --git a/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js b/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js index 2af1ce80f9c..e78fc3f6a43 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js @@ -1,7 +1,7 @@ currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false Input:: //// [/user/username/projects/myproject/tsconfig.json] -{"compilerOptions":{"target":"es5","module":"node16","moduleResolution":"node16"}} +{"compilerOptions":{"module":"node16","moduleResolution":"node16"}} //// [/user/username/projects/myproject/index.ts] /// @@ -43,7 +43,7 @@ declare global { //// [/user/username/projects/myproject/node_modules/@types/pkg2/index.d.ts] export const x = 10; -//// [/a/lib/lib.d.ts] +//// [/a/lib/lib.es2022.full.d.ts] /// interface Boolean {} interface Function {} @@ -146,24 +146,24 @@ File '/package.json' does not exist according to earlier cached lookups. Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/index.ts"] -Program options: {"target":1,"module":100,"moduleResolution":3,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program options: {"module":100,"moduleResolution":3,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} Program structureReused: Not Program files:: -/a/lib/lib.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/a.ts /user/username/projects/myproject/node_modules/pkg/import.d.ts /user/username/projects/myproject/index.ts /user/username/projects/myproject/node_modules/@types/pkg2/index.d.ts Semantic diagnostics in builder refreshed for:: -/a/lib/lib.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/a.ts /user/username/projects/myproject/node_modules/pkg/import.d.ts /user/username/projects/myproject/index.ts /user/username/projects/myproject/node_modules/@types/pkg2/index.d.ts Shape signatures in builder refreshed for:: -/a/lib/lib.d.ts (used version) +/a/lib/lib.es2022.full.d.ts (used version) /user/username/projects/myproject/a.ts (used version) /user/username/projects/myproject/node_modules/pkg/import.d.ts (used version) /user/username/projects/myproject/index.ts (used version) @@ -186,7 +186,7 @@ PolledWatches:: {"pollingInterval":2000} FsWatches:: -/a/lib/lib.d.ts: *new* +/a/lib/lib.es2022.full.d.ts: *new* {} /user/username/projects/myproject/a.ts: *new* {} @@ -324,10 +324,10 @@ File '/package.json' does not exist according to earlier cached lookups. Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/index.ts"] -Program options: {"target":1,"module":100,"moduleResolution":3,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program options: {"module":100,"moduleResolution":3,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} Program structureReused: SafeModules Program files:: -/a/lib/lib.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/node_modules/pkg/import.d.ts /user/username/projects/myproject/a.ts /user/username/projects/myproject/index.ts