diff --git a/src/testRunner/unittests/tsbuild/moduleResolution.ts b/src/testRunner/unittests/tsbuild/moduleResolution.ts index 0d5d1f53101..3fb96b6715b 100644 --- a/src/testRunner/unittests/tsbuild/moduleResolution.ts +++ b/src/testRunner/unittests/tsbuild/moduleResolution.ts @@ -78,13 +78,13 @@ describe("unittests:: tsbuild:: moduleResolution:: handles the modules and optio TestServerHost.createWatchedSystem({ "/home/src/workspaces/project/packages/pkg1_index.ts": `export const theNum: TheNum = "type1";`, "/home/src/workspaces/project/packages/pkg1.tsconfig.json": jsonToReadableText({ - compilerOptions: { composite: true, typeRoots: ["./typeroot1"] }, + compilerOptions: { composite: true, typeRoots: ["./typeroot1"], types: ["sometype"] }, files: ["./pkg1_index.ts"], }), "/home/src/workspaces/project/packages/typeroot1/sometype/index.d.ts": dedent`declare type TheNum = "type1";`, "/home/src/workspaces/project/packages/pkg2_index.ts": `export const theNum: TheNum2 = "type2";`, "/home/src/workspaces/project/packages/pkg2.tsconfig.json": jsonToReadableText({ - compilerOptions: { composite: true, typeRoots: ["./typeroot2"] }, + compilerOptions: { composite: true, typeRoots: ["./typeroot2"], types: ["sometype"] }, files: ["./pkg2_index.ts"], }), "/home/src/workspaces/project/packages/typeroot2/sometype/index.d.ts": dedent`declare type TheNum2 = "type2";`, diff --git a/src/testRunner/unittests/tsc/incremental.ts b/src/testRunner/unittests/tsc/incremental.ts index fcbd91ab1d2..fff1b9b18f5 100644 --- a/src/testRunner/unittests/tsc/incremental.ts +++ b/src/testRunner/unittests/tsc/incremental.ts @@ -188,7 +188,7 @@ declare global { "/home/src/workspaces/project/node_modules/react/jsx-runtime.js": "export {}", // js needs to be present so there's a resolution result "/home/src/workspaces/project/node_modules/@types/react/index.d.ts": getJsxLibraryContent(), // doesn't contain a jsx-runtime definition "/home/src/workspaces/project/src/index.tsx": `export const App = () =>
;`, - "/home/src/workspaces/project/tsconfig.json": jsonToReadableText({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react" } }), + "/home/src/workspaces/project/tsconfig.json": jsonToReadableText({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react", types: ["react"] } }), }), commandLineArgs: ts.emptyArray, }); @@ -201,7 +201,7 @@ declare global { "/home/src/workspaces/project/node_modules/react/jsx-runtime.js": "export {}", // js needs to be present so there's a resolution result "/home/src/workspaces/project/node_modules/@types/react/index.d.ts": getJsxLibraryContent(), // doesn't contain a jsx-runtime definition "/home/src/workspaces/project/src/index.tsx": `export const App = () =>
;`, - "/home/src/workspaces/project/tsconfig.json": jsonToReadableText({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react" } }), + "/home/src/workspaces/project/tsconfig.json": jsonToReadableText({ compilerOptions: { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react", types: ["react"] } }), }), commandLineArgs: ["--strict"], }); diff --git a/src/testRunner/unittests/tscWatch/resolutionCache.ts b/src/testRunner/unittests/tscWatch/resolutionCache.ts index fcf41017d37..b3e8c36d8b3 100644 --- a/src/testRunner/unittests/tscWatch/resolutionCache.ts +++ b/src/testRunner/unittests/tscWatch/resolutionCache.ts @@ -241,6 +241,9 @@ describe("unittests:: tscWatch:: resolutionCache:: tsc-watch module resolution c TestServerHost.createWatchedSystem([{ path: "/users/username/projects/project/foo.ts", content: `import * as fs from "fs";`, + }, { + path: "/users/username/projects/project/tsconfig.json", + content: jsonToReadableText({ compilerOptions: { types: ["node"] } }), }], { currentDirectory: "/users/username/projects/project" }), edits: [ { @@ -565,7 +568,7 @@ declare namespace NodeJS { }; const tsconfig: File = { path: `/user/username/projects/myproject/tsconfig.json`, - content: "{}", + content: jsonToReadableText({ compilerOptions: { types: ["node"] } }), }; const { nodeAtTypesIndex, nodeAtTypesBase, nodeAtTypes36Base, nodeAtTypesGlobals } = getNodeAtTypes(); return TestServerHost.createWatchedSystem( diff --git a/src/testRunner/unittests/tsserver/configuredProjects.ts b/src/testRunner/unittests/tsserver/configuredProjects.ts index f8014a45f72..926ae1d7ac9 100644 --- a/src/testRunner/unittests/tsserver/configuredProjects.ts +++ b/src/testRunner/unittests/tsserver/configuredProjects.ts @@ -1177,7 +1177,7 @@ describe("unittests:: tsserver:: configuredProjects:: non-existing directories l const config = { path: "/user/username/projects/project/a/tsconfig.json", content: jsonToReadableText({ - compiler: {}, + compilerOptions: { types: ["typings"] }, files: [], }), }; diff --git a/src/testRunner/unittests/tsserver/getMoveToRefactoringFileSuggestions.ts b/src/testRunner/unittests/tsserver/getMoveToRefactoringFileSuggestions.ts index c5c8a88abde..07e300cb82e 100644 --- a/src/testRunner/unittests/tsserver/getMoveToRefactoringFileSuggestions.ts +++ b/src/testRunner/unittests/tsserver/getMoveToRefactoringFileSuggestions.ts @@ -36,7 +36,7 @@ import { value1 } from "../node_modules/.cache/someFile.d.ts";`, }; const tsconfig: File = { path: "/home/src/projects/project/tsconfig.json", - content: "{}", + content: jsonToReadableText({ compilerOptions: { types: ["node"] } }), }; const host = TestServerHost.createServerHost([file1, file2, file3, file3, file4, nodeModulesFile1, nodeModulesFile2, tsconfig]); const session = new TestSession(host); diff --git a/src/testRunner/unittests/tsserver/resolutionCache.ts b/src/testRunner/unittests/tsserver/resolutionCache.ts index 2f0a8f9e424..bb09c13027c 100644 --- a/src/testRunner/unittests/tsserver/resolutionCache.ts +++ b/src/testRunner/unittests/tsserver/resolutionCache.ts @@ -59,7 +59,7 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem watchin const tsconfig = { path: "/users/username/projects/project/tsconfig.json", content: jsonToReadableText({ - compilerOptions: {}, + compilerOptions: { types: ["lib1", "lib2"] }, exclude: ["node_modules"], }), }; diff --git a/tests/baselines/reference/typeReferenceDirectives13.js b/tests/baselines/reference/typeReferenceDirectives13.js index 89f2bfc9d95..c313b9a328c 100644 --- a/tests/baselines/reference/typeReferenceDirectives13.js +++ b/tests/baselines/reference/typeReferenceDirectives13.js @@ -23,24 +23,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); export interface A { x: () => typeof $; } - - -//// [DtsFileErrors] - - -/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`. - - -==== /app.d.ts (1 errors) ==== - export interface A { - x: () => typeof $; - ~ -!!! error TS2581: Cannot find name '$'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`. - } - -==== /ref.d.ts (0 errors) ==== - export interface $ { x } - -==== /types/lib/index.d.ts (0 errors) ==== - declare let $: { x: number } - \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives13.trace.json b/tests/baselines/reference/typeReferenceDirectives13.trace.json index 9dca874c775..e012935dca8 100644 --- a/tests/baselines/reference/typeReferenceDirectives13.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives13.trace.json @@ -13,5 +13,8 @@ "File '/ref.ts' does not exist.", "File '/ref.tsx' does not exist.", "File '/ref.d.ts' exists - use it as a name resolution result.", - "======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========" + "======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========", + "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'lib' was found in cache from location '/'.", + "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/cases/compiler/typeReferenceDirectives13.ts b/tests/cases/compiler/typeReferenceDirectives13.ts index c8a0d40df5c..b37dd50e143 100644 --- a/tests/cases/compiler/typeReferenceDirectives13.ts +++ b/tests/cases/compiler/typeReferenceDirectives13.ts @@ -4,6 +4,7 @@ // @typeRoots: /types // @traceResolution: true // @currentDirectory: / +// @types: lib // @filename: /ref.d.ts export interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives5.ts b/tests/cases/compiler/typeReferenceDirectives5.ts index dad75ff02f1..0051a29552f 100644 --- a/tests/cases/compiler/typeReferenceDirectives5.ts +++ b/tests/cases/compiler/typeReferenceDirectives5.ts @@ -4,6 +4,7 @@ // @declaration: true // @typeRoots: /types // @currentDirectory: / +// @types: lib // @filename: /ref.d.ts export interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives6.ts b/tests/cases/compiler/typeReferenceDirectives6.ts index eb759e29232..6b0820c44f1 100644 --- a/tests/cases/compiler/typeReferenceDirectives6.ts +++ b/tests/cases/compiler/typeReferenceDirectives6.ts @@ -4,6 +4,7 @@ // @declaration: true // @typeRoots: /types // @currentDirectory: / +// @types: lib // $ comes from type declaration file - type reference directive should be added diff --git a/tests/cases/compiler/typeReferenceDirectives9.ts b/tests/cases/compiler/typeReferenceDirectives9.ts index e497e0af2ee..c71b66a08be 100644 --- a/tests/cases/compiler/typeReferenceDirectives9.ts +++ b/tests/cases/compiler/typeReferenceDirectives9.ts @@ -4,6 +4,7 @@ // @typeRoots: /types // @traceResolution: true // @currentDirectory: / +// @types: lib // @filename: /types/lib/index.d.ts diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts index 5d96e640242..c73ec827f32 100644 --- a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences.ts @@ -3,6 +3,7 @@ // @target: es5 // @outDir: tests/cases/conformance/jsdoc/declarations/out // @declaration: true +// @types: node // @filename: node_modules/@types/node/index.d.ts declare module "fs" { export class Something {} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences3.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences3.ts index a78ca90d3b7..826d554cc6d 100644 --- a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences3.ts +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsTypeReferences3.ts @@ -3,6 +3,7 @@ // @target: es5 // @outDir: tests/cases/conformance/jsdoc/declarations/out // @declaration: true +// @types: node // @filename: node_modules/@types/node/index.d.ts declare module "fs" { export class Something {}