Skip to content

Commit 387b02a

Browse files
Fix all tests with unintentional error changes
Added explicit types arrays to tests that had NEW errors after the default change: - tsc/incremental: react-jsx tests now have types: ["react"] - tsbuild/moduleResolution: type-reference-resolution test now has types: ["sometype"] - tscWatch/resolutionCache: tests now have types: ["node"] - tsserver tests: added types for node, lib1, lib2, typings - compiler tests: jsDeclarationsTypeReferences and typeReferenceDirectives tests now have explicit @types directives All tests now pass with only expected errors (no unintentional changes). Co-authored-by: RyanCavanaugh <[email protected]>
1 parent 89de5f6 commit 387b02a

14 files changed

+21
-30
lines changed

src/testRunner/unittests/tsbuild/moduleResolution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ describe("unittests:: tsbuild:: moduleResolution:: handles the modules and optio
7878
TestServerHost.createWatchedSystem({
7979
"/home/src/workspaces/project/packages/pkg1_index.ts": `export const theNum: TheNum = "type1";`,
8080
"/home/src/workspaces/project/packages/pkg1.tsconfig.json": jsonToReadableText({
81-
compilerOptions: { composite: true, typeRoots: ["./typeroot1"] },
81+
compilerOptions: { composite: true, typeRoots: ["./typeroot1"], types: ["sometype"] },
8282
files: ["./pkg1_index.ts"],
8383
}),
8484
"/home/src/workspaces/project/packages/typeroot1/sometype/index.d.ts": dedent`declare type TheNum = "type1";`,
8585
"/home/src/workspaces/project/packages/pkg2_index.ts": `export const theNum: TheNum2 = "type2";`,
8686
"/home/src/workspaces/project/packages/pkg2.tsconfig.json": jsonToReadableText({
87-
compilerOptions: { composite: true, typeRoots: ["./typeroot2"] },
87+
compilerOptions: { composite: true, typeRoots: ["./typeroot2"], types: ["sometype"] },
8888
files: ["./pkg2_index.ts"],
8989
}),
9090
"/home/src/workspaces/project/packages/typeroot2/sometype/index.d.ts": dedent`declare type TheNum2 = "type2";`,

src/testRunner/unittests/tsc/incremental.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ declare global {
188188
"/home/src/workspaces/project/node_modules/react/jsx-runtime.js": "export {}", // js needs to be present so there's a resolution result
189189
"/home/src/workspaces/project/node_modules/@types/react/index.d.ts": getJsxLibraryContent(), // doesn't contain a jsx-runtime definition
190190
"/home/src/workspaces/project/src/index.tsx": `export const App = () => <div propA={true}></div>;`,
191-
"/home/src/workspaces/project/tsconfig.json": jsonToReadableText({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react" } }),
191+
"/home/src/workspaces/project/tsconfig.json": jsonToReadableText({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react", types: ["react"] } }),
192192
}),
193193
commandLineArgs: ts.emptyArray,
194194
});
@@ -201,7 +201,7 @@ declare global {
201201
"/home/src/workspaces/project/node_modules/react/jsx-runtime.js": "export {}", // js needs to be present so there's a resolution result
202202
"/home/src/workspaces/project/node_modules/@types/react/index.d.ts": getJsxLibraryContent(), // doesn't contain a jsx-runtime definition
203203
"/home/src/workspaces/project/src/index.tsx": `export const App = () => <div propA={true}></div>;`,
204-
"/home/src/workspaces/project/tsconfig.json": jsonToReadableText({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react" } }),
204+
"/home/src/workspaces/project/tsconfig.json": jsonToReadableText({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react", types: ["react"] } }),
205205
}),
206206
commandLineArgs: ["--strict"],
207207
});

src/testRunner/unittests/tscWatch/resolutionCache.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ describe("unittests:: tscWatch:: resolutionCache:: tsc-watch module resolution c
241241
TestServerHost.createWatchedSystem([{
242242
path: "/users/username/projects/project/foo.ts",
243243
content: `import * as fs from "fs";`,
244+
}, {
245+
path: "/users/username/projects/project/tsconfig.json",
246+
content: jsonToReadableText({ compilerOptions: { types: ["node"] } }),
244247
}], { currentDirectory: "/users/username/projects/project" }),
245248
edits: [
246249
{
@@ -565,7 +568,7 @@ declare namespace NodeJS {
565568
};
566569
const tsconfig: File = {
567570
path: `/user/username/projects/myproject/tsconfig.json`,
568-
content: "{}",
571+
content: jsonToReadableText({ compilerOptions: { types: ["node"] } }),
569572
};
570573
const { nodeAtTypesIndex, nodeAtTypesBase, nodeAtTypes36Base, nodeAtTypesGlobals } = getNodeAtTypes();
571574
return TestServerHost.createWatchedSystem(

src/testRunner/unittests/tsserver/configuredProjects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ describe("unittests:: tsserver:: configuredProjects:: non-existing directories l
11771177
const config = {
11781178
path: "/user/username/projects/project/a/tsconfig.json",
11791179
content: jsonToReadableText({
1180-
compiler: {},
1180+
compilerOptions: { types: ["typings"] },
11811181
files: [],
11821182
}),
11831183
};

src/testRunner/unittests/tsserver/getMoveToRefactoringFileSuggestions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { value1 } from "../node_modules/.cache/someFile.d.ts";`,
3636
};
3737
const tsconfig: File = {
3838
path: "/home/src/projects/project/tsconfig.json",
39-
content: "{}",
39+
content: jsonToReadableText({ compilerOptions: { types: ["node"] } }),
4040
};
4141
const host = TestServerHost.createServerHost([file1, file2, file3, file3, file4, nodeModulesFile1, nodeModulesFile2, tsconfig]);
4242
const session = new TestSession(host);

src/testRunner/unittests/tsserver/resolutionCache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem watchin
5959
const tsconfig = {
6060
path: "/users/username/projects/project/tsconfig.json",
6161
content: jsonToReadableText({
62-
compilerOptions: {},
62+
compilerOptions: { types: ["lib1", "lib2"] },
6363
exclude: ["node_modules"],
6464
}),
6565
};

tests/baselines/reference/typeReferenceDirectives13.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
2323
export interface A {
2424
x: () => typeof $;
2525
}
26-
27-
28-
//// [DtsFileErrors]
29-
30-
31-
/app.d.ts(2,21): error TS2581: Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`.
32-
33-
34-
==== /app.d.ts (1 errors) ====
35-
export interface A {
36-
x: () => typeof $;
37-
~
38-
!!! error TS2581: Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`.
39-
}
40-
41-
==== /ref.d.ts (0 errors) ====
42-
export interface $ { x }
43-
44-
==== /types/lib/index.d.ts (0 errors) ====
45-
declare let $: { x: number }
46-

tests/baselines/reference/typeReferenceDirectives13.trace.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
"File '/ref.ts' does not exist.",
1414
"File '/ref.tsx' does not exist.",
1515
"File '/ref.d.ts' exists - use it as a name resolution result.",
16-
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========"
16+
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========",
17+
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========",
18+
"Resolution for type reference directive 'lib' was found in cache from location '/'.",
19+
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
1720
]

tests/cases/compiler/typeReferenceDirectives13.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// @typeRoots: /types
55
// @traceResolution: true
66
// @currentDirectory: /
7+
// @types: lib
78

89
// @filename: /ref.d.ts
910
export interface $ { x }

tests/cases/compiler/typeReferenceDirectives5.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// @declaration: true
55
// @typeRoots: /types
66
// @currentDirectory: /
7+
// @types: lib
78

89
// @filename: /ref.d.ts
910
export interface $ { x }

0 commit comments

Comments
 (0)