diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 9ede133aae270..a69d2c0adfe64 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -579,19 +579,13 @@ export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string const failedLookupLocations: string[] = []; const affectingLocations: string[] = []; - // Allow type reference directives to opt into `exports` resolution in any resolution mode - // when a `resolution-mode` override is present. - let features = getNodeResolutionFeatures(options); - if (resolutionMode !== undefined) { - features |= NodeResolutionFeatures.AllFeatures; - } + + let features = NodeResolutionFeatures.AllFeatures; const moduleResolution = getEmitModuleResolutionKind(options); if (resolutionMode === ModuleKind.ESNext && (ModuleResolutionKind.Node16 <= moduleResolution && moduleResolution <= ModuleResolutionKind.NodeNext)) { features |= NodeResolutionFeatures.EsmMode; } - const conditions = (features & NodeResolutionFeatures.Exports) - ? getConditions(options, resolutionMode) - : []; + const conditions = getConditions(options, resolutionMode); const diagnostics: Diagnostic[] = []; const moduleResolutionState: ModuleResolutionState = { compilerOptions: options, @@ -677,7 +671,7 @@ export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string } } return resolvedTypeScriptOnly( - loadNodeModuleFromDirectory(Extensions.Declaration, candidate, !directoryExists, moduleResolutionState), + loadModuleFromSpecificNodeModulesDirectory(Extensions.Declaration, typeReferenceDirectiveName, typeRoot, directoryExists, moduleResolutionState, /*cache*/ undefined, redirectedReference, /*disableFileLookup*/ true), ); }); } @@ -3051,7 +3045,7 @@ function loadModuleFromImmediateNodeModulesDirectory(extensions: Extensions, mod } } -function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, moduleName: string, nodeModulesDirectory: string, nodeModulesDirectoryExists: boolean, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): Resolved | undefined { +function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, moduleName: string, nodeModulesDirectory: string, nodeModulesDirectoryExists: boolean, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined, disableFileLookup?: boolean): Resolved | undefined { const candidate = normalizePath(combinePaths(nodeModulesDirectory, moduleName)); const { packageName, rest } = parsePackageName(moduleName); const packageDirectory = combinePaths(nodeModulesDirectory, packageName); @@ -3066,7 +3060,7 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, modu !hasProperty((rootPackageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state))?.contents.packageJsonContent ?? emptyArray, "exports") ) ) { - const fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state); + const fromFile = !disableFileLookup && loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state); if (fromFile) { return noPackageId(fromFile); } @@ -3083,7 +3077,7 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions: Extensions, modu } const loader: ResolutionKindSpecificLoader = (extensions, candidate, onlyRecordFailures, state) => { - let pathAndExtension = (rest || !(state.features & NodeResolutionFeatures.EsmMode)) && loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) || + let pathAndExtension = (rest || !(state.features & NodeResolutionFeatures.EsmMode)) && !disableFileLookup && loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) || loadNodeModuleFromDirectoryWorker( extensions, candidate, diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index ac44525404f5d..da20da65fa0e1 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -2352,7 +2352,7 @@ export class TestState { } public baselineSyntacticAndSemanticDiagnostics() { - const files = ts.filter(this.getCompilerTestFiles(), f => !ts.endsWith(f.unitName, ".json")); + const files = ts.filter(this.getCompilerTestFiles(), f => !ts.endsWith(f.unitName, ".json") && (this.testType === FourSlashTestType.Server || !!this.languageService.getProgram()!.getSourceFile(f.unitName))); const result = this.getSyntacticDiagnosticBaselineText(files) + Harness.IO.newLine() + Harness.IO.newLine() diff --git a/tests/baselines/reference/nodeNextImportModeImplicitIndexResolution2.errors.txt b/tests/baselines/reference/nodeNextImportModeImplicitIndexResolution2.errors.txt index 914722e2f4d65..378ec3b33bb46 100644 --- a/tests/baselines/reference/nodeNextImportModeImplicitIndexResolution2.errors.txt +++ b/tests/baselines/reference/nodeNextImportModeImplicitIndexResolution2.errors.txt @@ -1,7 +1,13 @@ +error TS2688: Cannot find type definition file for 'dedent4'. + The file is in the program because: + Entry point for implicit type library 'dedent4' /index.cts(4,21): error TS2307: Cannot find module 'dedent4' or its corresponding type declarations. /index.mts(4,21): error TS2307: Cannot find module 'dedent4' or its corresponding type declarations. +!!! error TS2688: Cannot find type definition file for 'dedent4'. +!!! error TS2688: The file is in the program because: +!!! error TS2688: Entry point for implicit type library 'dedent4' ==== /node_modules/@types/dedent/package.json (0 errors) ==== { "name": "@types/dedent", "version": "1.0.0", "main": "" } diff --git a/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.js b/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.js index 834a8fa145c4e..68d25303dd7c7 100644 --- a/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.js +++ b/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.js @@ -13,6 +13,7 @@ export const a =
; "main": "", "types": "index.d.ts", "exports": { + ".": "./index.d.ts", "./*.js": "./*.js", "./*": "./*.js" } diff --git a/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json b/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json index 371f19d242f39..958196cb251b2 100644 --- a/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json +++ b/tests/baselines/reference/reactJsxReactResolvedNodeNextEsm.trace.json @@ -35,8 +35,7 @@ "======== Resolving type reference directive 'react', containing file '/.src/__inferred type names__.ts', root directory '/.src/node_modules/@types,/node_modules/@types'. ========", "Resolving with primary search path '/.src/node_modules/@types, /node_modules/@types'.", "File '/.src/node_modules/@types/react/package.json' exists according to earlier cached lookups.", - "'package.json' does not have a 'typings' field.", - "'package.json' has 'types' field 'index.d.ts' that references '/.src/node_modules/@types/react/index.d.ts'.", + "Using 'exports' subpath '.' with target './index.d.ts'.", "File '/.src/node_modules/@types/react/index.d.ts' exists - use it as a name resolution result.", "Resolving real path for '/.src/node_modules/@types/react/index.d.ts', result '/.src/node_modules/@types/react/index.d.ts'.", "======== Type reference directive 'react' was successfully resolved to '/.src/node_modules/@types/react/index.d.ts' with Package ID '@types/react/index.d.ts@0.0.1', primary: true. ========", diff --git a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).errors.txt b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).errors.txt index f7596129d6f40..6169c43c7d0d1 100644 --- a/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).errors.txt +++ b/tests/baselines/reference/resolutionModeImportType1(moduleresolution=classic).errors.txt @@ -1,14 +1,8 @@ -error TS2688: Cannot find type definition file for 'foo'. - The file is in the program because: - Entry point for implicit type library 'foo' /app.ts(1,30): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? /app.ts(2,29): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? /app.ts(3,30): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -!!! error TS2688: Cannot find type definition file for 'foo'. -!!! error TS2688: The file is in the program because: -!!! error TS2688: Entry point for implicit type library 'foo' ==== /node_modules/@types/foo/package.json (0 errors) ==== { "name": "@types/foo", diff --git a/tests/baselines/reference/resolutionModeTypeOnlyImport1(moduleresolution=classic).errors.txt b/tests/baselines/reference/resolutionModeTypeOnlyImport1(moduleresolution=classic).errors.txt index 8e52a8e3c12ce..3240d3c1788e6 100644 --- a/tests/baselines/reference/resolutionModeTypeOnlyImport1(moduleresolution=classic).errors.txt +++ b/tests/baselines/reference/resolutionModeTypeOnlyImport1(moduleresolution=classic).errors.txt @@ -1,14 +1,8 @@ -error TS2688: Cannot find type definition file for 'foo'. - The file is in the program because: - Entry point for implicit type library 'foo' /app.ts(1,35): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? /app.ts(2,34): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? /app.ts(3,35): error TS2792: Cannot find module 'foo'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? -!!! error TS2688: Cannot find type definition file for 'foo'. -!!! error TS2688: The file is in the program because: -!!! error TS2688: Entry point for implicit type library 'foo' ==== /node_modules/@types/foo/package.json (0 errors) ==== { "name": "@types/foo", diff --git a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt index fe904ca69530b..9734cc634249f 100644 --- a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt @@ -1,3 +1,6 @@ +error TS2688: Cannot find type definition file for 'bar'. + The file is in the program because: + Entry point for implicit type library 'bar' error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? The file is in the program because: Root file specified for compilation @@ -16,6 +19,9 @@ error TS6504: File '/node_modules/foo/index.mjs' is a JavaScript file. Did you m There are types at '/node_modules/@types/bar/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@types/bar' library may need to update its package.json or typings. +!!! error TS2688: Cannot find type definition file for 'bar'. +!!! error TS2688: The file is in the program because: +!!! error TS2688: Entry point for implicit type library 'bar' !!! error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? !!! error TS6504: The file is in the program because: !!! error TS6504: Root file specified for compilation diff --git a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json index acf4e85067873..f50718a61d8c6 100644 --- a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json +++ b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json @@ -113,11 +113,26 @@ "Resolving with primary search path '/.src/node_modules/@types, /node_modules/@types'.", "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", "File '/node_modules/@types/bar/package.json' exists according to earlier cached lookups.", - "'package.json' does not have a 'typings' field.", - "'package.json' has 'types' field 'index.d.ts' that references '/node_modules/@types/bar/index.d.ts'.", - "File '/node_modules/@types/bar/index.d.ts' exists - use it as a name resolution result.", - "Resolving real path for '/node_modules/@types/bar/index.d.ts', result '/node_modules/@types/bar/index.d.ts'.", - "======== Type reference directive 'bar' was successfully resolved to '/node_modules/@types/bar/index.d.ts' with Package ID '@types/bar/index.d.ts@1.0.0', primary: true. ========", + "Entering conditional exports.", + "Saw non-matching condition 'require'.", + "Exiting conditional exports.", + "Looking up in 'node_modules' folder, initial location '/.src'.", + "Searching all ancestor node_modules directories for preferred extensions: Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "File '/node_modules/bar/package.json' exists according to earlier cached lookups.", + "Entering conditional exports.", + "Matched 'exports' condition 'import'.", + "Using 'exports' subpath '.' with target './index.mjs'.", + "File name '/node_modules/bar/index.mjs' has a '.mjs' extension - stripping it.", + "File '/node_modules/bar/index.d.mts' does not exist.", + "Failed to resolve under condition 'import'.", + "Saw non-matching condition 'require'.", + "Exiting conditional exports.", + "File '/node_modules/@types/bar/package.json' exists according to earlier cached lookups.", + "Entering conditional exports.", + "Saw non-matching condition 'require'.", + "Exiting conditional exports.", + "======== Type reference directive 'bar' was not resolved. ========", "File '/.ts/package.json' does not exist.", "File '/package.json' does not exist according to earlier cached lookups.", "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", diff --git a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json index 09a281e268717..0ee7837f35ce8 100644 --- a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json +++ b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json @@ -102,9 +102,12 @@ "Resolving with primary search path '/.src/node_modules/@types, /node_modules/@types'.", "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", "File '/node_modules/@types/bar/package.json' exists according to earlier cached lookups.", - "'package.json' does not have a 'typings' field.", - "'package.json' has 'types' field 'index.d.ts' that references '/node_modules/@types/bar/index.d.ts'.", + "Entering conditional exports.", + "Matched 'exports' condition 'require'.", + "Using 'exports' subpath '.' with target './index.d.ts'.", "File '/node_modules/@types/bar/index.d.ts' exists - use it as a name resolution result.", + "Resolved under condition 'require'.", + "Exiting conditional exports.", "Resolving real path for '/node_modules/@types/bar/index.d.ts', result '/node_modules/@types/bar/index.d.ts'.", "======== Type reference directive 'bar' was successfully resolved to '/node_modules/@types/bar/index.d.ts' with Package ID '@types/bar/index.d.ts@1.0.0', primary: true. ========", "File '/.ts/package.json' does not exist.", diff --git a/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=commonjs).errors.txt b/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=commonjs).errors.txt new file mode 100644 index 0000000000000..9062d29947423 --- /dev/null +++ b/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=commonjs).errors.txt @@ -0,0 +1,17 @@ +usage.ts(1,23): error TS2688: Cannot find type definition file for 'pkg'. + + +==== node_modules/pkg/index.d.ts (0 errors) ==== + interface GlobalThing { a: number } +==== node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "types": "index.d.ts", + "exports": "some-other-thing.js" + } +==== usage.ts (1 errors) ==== + /// + ~~~ +!!! error TS2688: Cannot find type definition file for 'pkg'. + + const a: GlobalThing = { a: 0 }; \ No newline at end of file diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js index d59303ac57b12..cd12d8f9934a6 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js @@ -91,11 +91,17 @@ File '/Users/name/projects/web/node_modules/@types/yargs/package.json' exists ac ======== Resolving type reference directive 'yargs', containing file '/Users/name/projects/web/__inferred type names__.ts', root directory '/Users/name/projects/web/node_modules/@types,/Users/name/projects/node_modules/@types,/Users/name/node_modules/@types,/Users/node_modules/@types,/node_modules/@types'. ======== Resolving with primary search path '/Users/name/projects/web/node_modules/@types, /Users/name/projects/node_modules/@types, /Users/name/node_modules/@types, /Users/node_modules/@types, /node_modules/@types'. File '/Users/name/projects/web/node_modules/@types/yargs/package.json' exists according to earlier cached lookups. -'package.json' does not have a 'typesVersions' field. -'package.json' does not have a 'typings' field. -'package.json' does not have a 'types' field. -'package.json' does not have a 'main' field. +Entering conditional exports. +Matched 'exports' condition 'types'. +Entering conditional exports. +Saw non-matching condition 'import'. +Matched 'exports' condition 'default'. +Using 'exports' subpath '.' with target './index.d.ts'. File '/Users/name/projects/web/node_modules/@types/yargs/index.d.ts' exists - use it as a name resolution result. +Resolved under condition 'default'. +Exiting conditional exports. +Resolved under condition 'types'. +Exiting conditional exports. Resolving real path for '/Users/name/projects/web/node_modules/@types/yargs/index.d.ts', result '/Users/name/projects/web/node_modules/@types/yargs/index.d.ts'. ======== Type reference directive 'yargs' was successfully resolved to '/Users/name/projects/web/node_modules/@types/yargs/index.d.ts' with Package ID 'yargs/index.d.ts@17.0.12', primary: true. ======== File '/a/lib/package.json' does not exist. diff --git a/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_exportMap5.js b/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_exportMap5.js index a8e2b92cd4260..8a844d2e594a5 100644 --- a/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_exportMap5.js +++ b/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_exportMap5.js @@ -154,13 +154,15 @@ Info seq [hh:mm:ss:mss] event: } Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /dev/null/inferredProject1* Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /node_modules/@types/dependency/package.json 2000 undefined Project: /dev/null/inferredProject1* WatchType: File location affecting resolution +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /node_modules/@types/dependency/lib/package.json 2000 undefined Project: /dev/null/inferredProject1* WatchType: File location affecting resolution Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred) -Info seq [hh:mm:ss:mss] Files (4) +Info seq [hh:mm:ss:mss] Files (5) /lib.d.ts Text-1 lib.d.ts-Text /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text /tsconfig.json SVC-1-0 "{\n \"compilerOptions\": {\n \"module\": \"nodenext\"\n }\n}" + /node_modules/@types/dependency/lib/index.d.ts Text-1 "export declare function fooFromIndex(): void;" lib.d.ts @@ -171,6 +173,9 @@ Info seq [hh:mm:ss:mss] Files (4) Library referenced via 'decorators.legacy' from file 'lib.d.ts' tsconfig.json Root file specified for compilation + node_modules/@types/dependency/lib/index.d.ts + Entry point for implicit type library 'dependency' with packageId '@types/dependency/lib/index.d.ts@1.0.0' + File is ECMAScript module because 'node_modules/@types/dependency/package.json' has field "type" with value "module" Info seq [hh:mm:ss:mss] ----------------------------------------------- Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /package.json 250 undefined WatchType: package.json file @@ -179,7 +184,7 @@ Info seq [hh:mm:ss:mss] Files (5) Info seq [hh:mm:ss:mss] ----------------------------------------------- Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred) -Info seq [hh:mm:ss:mss] Files (4) +Info seq [hh:mm:ss:mss] Files (5) Info seq [hh:mm:ss:mss] ----------------------------------------------- Info seq [hh:mm:ss:mss] Open files: @@ -197,6 +202,7 @@ watchedFiles:: {"pollingInterval":500} /node_modules/@types/dependency/lib/package.json: *new* {"pollingInterval":2000} + {"pollingInterval":2000} /node_modules/@types/dependency/package.json: *new* {"pollingInterval":2000} {"pollingInterval":2000} @@ -238,8 +244,9 @@ ScriptInfos:: /dev/null/inferredProject1* /node_modules/@types/dependency/lib/index.d.ts *new* version: Text-1 - containingProjects: 1 + containingProjects: 2 /tsconfig.json + /dev/null/inferredProject1* /src/foo.ts *new* version: Text-1 containingProjects: 1 @@ -265,7 +272,7 @@ Info seq [hh:mm:ss:mss] Files (5) Info seq [hh:mm:ss:mss] ----------------------------------------------- Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred) -Info seq [hh:mm:ss:mss] Files (4) +Info seq [hh:mm:ss:mss] Files (5) Info seq [hh:mm:ss:mss] ----------------------------------------------- Info seq [hh:mm:ss:mss] Open files: @@ -285,6 +292,7 @@ watchedFiles:: {"pollingInterval":500} /node_modules/@types/dependency/lib/package.json: {"pollingInterval":2000} + {"pollingInterval":2000} /node_modules/@types/dependency/package.json: {"pollingInterval":2000} {"pollingInterval":2000} @@ -328,8 +336,9 @@ ScriptInfos:: /dev/null/inferredProject1* /node_modules/@types/dependency/lib/index.d.ts version: Text-1 - containingProjects: 1 + containingProjects: 2 /tsconfig.json + /dev/null/inferredProject1* /src/foo.ts (Open) *changed* open: true *changed* version: Text-1 @@ -1140,6 +1149,7 @@ watchedFiles:: /node_modules/@types/dependency/lib/lol.d.ts: *new* {"pollingInterval":500} /node_modules/@types/dependency/lib/package.json: + {"pollingInterval":2000} {"pollingInterval":2000} {"pollingInterval":2000} *new* /node_modules/@types/dependency/package.json: @@ -1187,8 +1197,9 @@ ScriptInfos:: /dev/null/inferredProject1* /node_modules/@types/dependency/lib/index.d.ts version: Text-1 - containingProjects: 1 + containingProjects: 2 /tsconfig.json + /dev/null/inferredProject1* /node_modules/@types/dependency/lib/lol.d.ts *new* version: Text-1 containingProjects: 1 diff --git a/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_exportMap6.js b/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_exportMap6.js index dc45b84d66612..eaa6501ba8e6b 100644 --- a/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_exportMap6.js +++ b/tests/baselines/reference/tsserver/fourslashServer/autoImportProvider_exportMap6.js @@ -66,7 +66,8 @@ fooFrom //// [/tsconfig.json] { "compilerOptions": { - "module": "nodenext" + "module": "nodenext", + "types": [] } } @@ -102,6 +103,7 @@ Info seq [hh:mm:ss:mss] Config: /tsconfig.json : { ], "options": { "module": 199, + "types": [], "configFilePath": "/tsconfig.json" } } @@ -112,17 +114,13 @@ Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.d.ts 5 Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.legacy.d.ts 500 undefined WatchType: Closed Script info Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /src/foo.ts 500 undefined WatchType: Closed Script info Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json -Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /node_modules/@types/dependency/package.json 2000 undefined Project: /tsconfig.json WatchType: File location affecting resolution -Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /node_modules/dependency/lib/index.d.ts 500 undefined WatchType: Closed Script info -Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /node_modules/dependency/lib/package.json 2000 undefined Project: /tsconfig.json WatchType: File location affecting resolution Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured) -Info seq [hh:mm:ss:mss] Files (5) +Info seq [hh:mm:ss:mss] Files (4) /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text /lib.d.ts Text-1 lib.d.ts-Text /src/foo.ts Text-1 "fooFrom" - /node_modules/dependency/lib/index.d.ts Text-1 "export declare function fooFromIndex(): void" lib.decorators.d.ts @@ -136,9 +134,6 @@ Info seq [hh:mm:ss:mss] Files (5) src/foo.ts Matched by default include pattern '**/*' File is ECMAScript module because 'package.json' has field "type" with value "module" - node_modules/dependency/lib/index.d.ts - Entry point for implicit type library 'dependency' with packageId 'dependency/lib/index.d.ts@1.0.0' - File is ECMAScript module because 'node_modules/dependency/package.json' has field "type" with value "module" Info seq [hh:mm:ss:mss] ----------------------------------------------- Info seq [hh:mm:ss:mss] event: @@ -163,13 +158,16 @@ Info seq [hh:mm:ss:mss] event: } Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /dev/null/inferredProject1* Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /node_modules/@types/dependency/package.json 2000 undefined Project: /dev/null/inferredProject1* WatchType: File location affecting resolution +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /node_modules/@types/dependency/lib/index.d.ts 500 undefined WatchType: Closed Script info +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /node_modules/@types/dependency/lib/package.json 2000 undefined Project: /dev/null/inferredProject1* WatchType: File location affecting resolution Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred) -Info seq [hh:mm:ss:mss] Files (4) +Info seq [hh:mm:ss:mss] Files (5) /lib.d.ts Text-1 lib.d.ts-Text /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text - /tsconfig.json SVC-1-0 "{\n \"compilerOptions\": {\n \"module\": \"nodenext\"\n }\n}" + /tsconfig.json SVC-1-0 "{\n \"compilerOptions\": {\n \"module\": \"nodenext\",\n \"types\": []\n }\n}" + /node_modules/@types/dependency/lib/index.d.ts Text-1 "export declare function fooFromAtTypesIndex(): void;" lib.d.ts @@ -180,15 +178,18 @@ Info seq [hh:mm:ss:mss] Files (4) Library referenced via 'decorators.legacy' from file 'lib.d.ts' tsconfig.json Root file specified for compilation + node_modules/@types/dependency/lib/index.d.ts + Entry point for implicit type library 'dependency' with packageId '@types/dependency/lib/index.d.ts@1.0.0' + File is ECMAScript module because 'node_modules/@types/dependency/package.json' has field "type" with value "module" Info seq [hh:mm:ss:mss] ----------------------------------------------- Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /package.json 250 undefined WatchType: package.json file Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured) -Info seq [hh:mm:ss:mss] Files (5) +Info seq [hh:mm:ss:mss] Files (4) Info seq [hh:mm:ss:mss] ----------------------------------------------- Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred) -Info seq [hh:mm:ss:mss] Files (4) +Info seq [hh:mm:ss:mss] Files (5) Info seq [hh:mm:ss:mss] ----------------------------------------------- Info seq [hh:mm:ss:mss] Open files: @@ -202,12 +203,11 @@ watchedFiles:: {"pollingInterval":500} /lib.decorators.legacy.d.ts: *new* {"pollingInterval":500} -/node_modules/@types/dependency/package.json: *new* - {"pollingInterval":2000} - {"pollingInterval":2000} -/node_modules/dependency/lib/index.d.ts: *new* +/node_modules/@types/dependency/lib/index.d.ts: *new* {"pollingInterval":500} -/node_modules/dependency/lib/package.json: *new* +/node_modules/@types/dependency/lib/package.json: *new* + {"pollingInterval":2000} +/node_modules/@types/dependency/package.json: *new* {"pollingInterval":2000} /package.json: *new* {"pollingInterval":250} @@ -245,10 +245,10 @@ ScriptInfos:: containingProjects: 2 /tsconfig.json /dev/null/inferredProject1* -/node_modules/dependency/lib/index.d.ts *new* +/node_modules/@types/dependency/lib/index.d.ts *new* version: Text-1 containingProjects: 1 - /tsconfig.json + /dev/null/inferredProject1* /src/foo.ts *new* version: Text-1 containingProjects: 1 @@ -270,11 +270,11 @@ Info seq [hh:mm:ss:mss] request: Info seq [hh:mm:ss:mss] FileWatcher:: Close:: WatchInfo: /src/foo.ts 500 undefined WatchType: Closed Script info Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /src/foo.ts ProjectRootPath: undefined:: Result: /tsconfig.json Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured) -Info seq [hh:mm:ss:mss] Files (5) +Info seq [hh:mm:ss:mss] Files (4) Info seq [hh:mm:ss:mss] ----------------------------------------------- Info seq [hh:mm:ss:mss] Project '/dev/null/inferredProject1*' (Inferred) -Info seq [hh:mm:ss:mss] Files (4) +Info seq [hh:mm:ss:mss] Files (5) Info seq [hh:mm:ss:mss] ----------------------------------------------- Info seq [hh:mm:ss:mss] Open files: @@ -290,12 +290,11 @@ watchedFiles:: {"pollingInterval":500} /lib.decorators.legacy.d.ts: {"pollingInterval":500} -/node_modules/@types/dependency/package.json: - {"pollingInterval":2000} - {"pollingInterval":2000} -/node_modules/dependency/lib/index.d.ts: +/node_modules/@types/dependency/lib/index.d.ts: {"pollingInterval":500} -/node_modules/dependency/lib/package.json: +/node_modules/@types/dependency/lib/package.json: + {"pollingInterval":2000} +/node_modules/@types/dependency/package.json: {"pollingInterval":2000} /package.json: {"pollingInterval":250} @@ -335,10 +334,10 @@ ScriptInfos:: containingProjects: 2 /tsconfig.json /dev/null/inferredProject1* -/node_modules/dependency/lib/index.d.ts +/node_modules/@types/dependency/lib/index.d.ts version: Text-1 containingProjects: 1 - /tsconfig.json + /dev/null/inferredProject1* /src/foo.ts (Open) *changed* open: true *changed* version: Text-1 @@ -384,16 +383,21 @@ Info seq [hh:mm:ss:mss] request: Info seq [hh:mm:ss:mss] getCompletionData: Get current token: * Info seq [hh:mm:ss:mss] getCompletionData: Is inside comment: * Info seq [hh:mm:ss:mss] getCompletionData: Get previous token: * -Info seq [hh:mm:ss:mss] AutoImportProviderProject: found 1 root files in 1 dependencies 0 referenced projects in * ms +Info seq [hh:mm:ss:mss] AutoImportProviderProject: found 2 root files in 1 dependencies 0 referenced projects in * ms +Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /node_modules/dependency/lib/index.d.ts 500 undefined WatchType: Closed Script info Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /node_modules/dependency/lib/lol.d.ts 500 undefined WatchType: Closed Script info Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /dev/null/autoImportProviderProject1* Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /node_modules/dependency/lib/package.json 2000 undefined Project: /dev/null/autoImportProviderProject1* WatchType: File location affecting resolution Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /dev/null/autoImportProviderProject1* projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms Info seq [hh:mm:ss:mss] Project '/dev/null/autoImportProviderProject1*' (AutoImportProvider) -Info seq [hh:mm:ss:mss] Files (1) +Info seq [hh:mm:ss:mss] Files (2) + /node_modules/dependency/lib/index.d.ts Text-1 "export declare function fooFromIndex(): void" /node_modules/dependency/lib/lol.d.ts Text-1 "export declare function fooFromLol(): void" + node_modules/dependency/lib/index.d.ts + Root file specified for compilation + File is ECMAScript module because 'node_modules/dependency/package.json' has field "type" with value "module" node_modules/dependency/lib/lol.d.ts Root file specified for compilation File is ECMAScript module because 'node_modules/dependency/package.json' has field "type" with value "module" @@ -1091,11 +1095,13 @@ Info seq [hh:mm:ss:mss] response: "kind": "text" } ], + "isPackageJsonImport": true, "data": { "exportName": "fooFromIndex", "exportMapKey": "12 * fooFromIndex ", "moduleSpecifier": "dependency", - "fileName": "/node_modules/dependency/lib/index.d.ts" + "fileName": "/node_modules/dependency/lib/index.d.ts", + "isPackageJsonImport": true } }, { @@ -1143,16 +1149,18 @@ watchedFiles:: {"pollingInterval":500} /lib.decorators.legacy.d.ts: {"pollingInterval":500} -/node_modules/@types/dependency/package.json: +/node_modules/@types/dependency/lib/index.d.ts: + {"pollingInterval":500} +/node_modules/@types/dependency/lib/package.json: {"pollingInterval":2000} +/node_modules/@types/dependency/package.json: {"pollingInterval":2000} -/node_modules/dependency/lib/index.d.ts: +/node_modules/dependency/lib/index.d.ts: *new* {"pollingInterval":500} /node_modules/dependency/lib/lol.d.ts: *new* {"pollingInterval":500} -/node_modules/dependency/lib/package.json: +/node_modules/dependency/lib/package.json: *new* {"pollingInterval":2000} - {"pollingInterval":2000} *new* /package.json: {"pollingInterval":250} /tsconfig.json: @@ -1192,10 +1200,14 @@ ScriptInfos:: containingProjects: 2 /tsconfig.json /dev/null/inferredProject1* -/node_modules/dependency/lib/index.d.ts +/node_modules/@types/dependency/lib/index.d.ts version: Text-1 containingProjects: 1 - /tsconfig.json + /dev/null/inferredProject1* +/node_modules/dependency/lib/index.d.ts *new* + version: Text-1 + containingProjects: 1 + /dev/null/autoImportProviderProject1* /node_modules/dependency/lib/lol.d.ts *new* version: Text-1 containingProjects: 1 diff --git a/tests/baselines/reference/tsserver/fourslashServer/getJavaScriptSyntacticDiagnostics01.js b/tests/baselines/reference/tsserver/fourslashServer/getJavaScriptSyntacticDiagnostics01.js index 014a773dbc10e..195ea4c7969c9 100644 --- a/tests/baselines/reference/tsserver/fourslashServer/getJavaScriptSyntacticDiagnostics01.js +++ b/tests/baselines/reference/tsserver/fourslashServer/getJavaScriptSyntacticDiagnostics01.js @@ -108,73 +108,3 @@ ScriptInfos:: version: SVC-1-0 containingProjects: 1 /dev/null/inferredProject1* *default* - -Info seq [hh:mm:ss:mss] request: - { - "seq": 1, - "type": "request", - "arguments": { - "file": "/tests/cases/fourslash/server/a.js", - "includeLinePosition": true - }, - "command": "syntacticDiagnosticsSync" - } -Info seq [hh:mm:ss:mss] response: - { - "seq": 0, - "type": "response", - "command": "syntacticDiagnosticsSync", - "request_seq": 1, - "success": true, - "body": [ - { - "message": "Variable declaration expected.", - "start": 4, - "length": 3, - "category": "error", - "code": 1134, - "startLocation": { - "line": 1, - "offset": 5 - }, - "endLocation": { - "line": 1, - "offset": 8 - } - }, - { - "message": "Expression expected.", - "start": 7, - "length": 1, - "category": "error", - "code": 1109, - "startLocation": { - "line": 1, - "offset": 8 - }, - "endLocation": { - "line": 1, - "offset": 9 - } - } - ] - } -Info seq [hh:mm:ss:mss] request: - { - "seq": 2, - "type": "request", - "arguments": { - "file": "/tests/cases/fourslash/server/a.js", - "includeLinePosition": true - }, - "command": "semanticDiagnosticsSync" - } -Info seq [hh:mm:ss:mss] response: - { - "seq": 0, - "type": "response", - "command": "semanticDiagnosticsSync", - "request_seq": 2, - "success": true, - "body": [] - } \ No newline at end of file diff --git a/tests/baselines/reference/tsserver/fourslashServer/getJavaScriptSyntacticDiagnostics02.js b/tests/baselines/reference/tsserver/fourslashServer/getJavaScriptSyntacticDiagnostics02.js index 1466e72d5fc08..d2799703949d5 100644 --- a/tests/baselines/reference/tsserver/fourslashServer/getJavaScriptSyntacticDiagnostics02.js +++ b/tests/baselines/reference/tsserver/fourslashServer/getJavaScriptSyntacticDiagnostics02.js @@ -111,118 +111,3 @@ ScriptInfos:: version: SVC-1-0 containingProjects: 1 /dev/null/inferredProject1* *default* - -Info seq [hh:mm:ss:mss] request: - { - "seq": 1, - "type": "request", - "arguments": { - "file": "/tests/cases/fourslash/server/b.js", - "includeLinePosition": true - }, - "command": "syntacticDiagnosticsSync" - } -Info seq [hh:mm:ss:mss] response: - { - "seq": 0, - "type": "response", - "command": "syntacticDiagnosticsSync", - "request_seq": 1, - "success": true, - "body": [ - { - "message": "Type annotations can only be used in TypeScript files.", - "start": 20, - "length": 7, - "category": "error", - "code": 8010, - "startLocation": { - "line": 2, - "offset": 8 - }, - "endLocation": { - "line": 2, - "offset": 15 - } - }, - { - "message": "Type annotations can only be used in TypeScript files.", - "start": 52, - "length": 6, - "category": "error", - "code": 8010, - "startLocation": { - "line": 3, - "offset": 17 - }, - "endLocation": { - "line": 3, - "offset": 23 - } - }, - { - "message": "'var' is not allowed as a variable declaration name.", - "start": 67, - "length": 3, - "category": "error", - "code": 1389, - "startLocation": { - "line": 4, - "offset": 5 - }, - "endLocation": { - "line": 4, - "offset": 8 - } - }, - { - "message": "Variable declaration expected.", - "start": 71, - "length": 1, - "category": "error", - "code": 1134, - "startLocation": { - "line": 4, - "offset": 9 - }, - "endLocation": { - "line": 4, - "offset": 10 - } - }, - { - "message": "Variable declaration expected.", - "start": 73, - "length": 3, - "category": "error", - "code": 1134, - "startLocation": { - "line": 4, - "offset": 11 - }, - "endLocation": { - "line": 4, - "offset": 14 - } - } - ] - } -Info seq [hh:mm:ss:mss] request: - { - "seq": 2, - "type": "request", - "arguments": { - "file": "/tests/cases/fourslash/server/b.js", - "includeLinePosition": true - }, - "command": "semanticDiagnosticsSync" - } -Info seq [hh:mm:ss:mss] response: - { - "seq": 0, - "type": "response", - "command": "semanticDiagnosticsSync", - "request_seq": 2, - "success": true, - "body": [] - } \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.errors.txt b/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.errors.txt index 477a9831661d5..e747e03ae48d6 100644 --- a/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.errors.txt +++ b/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.errors.txt @@ -1,37 +1,39 @@ +error TS2688: Cannot find type definition file for '@mangled/attypescache'. + The file is in the program because: + Entry point of type library '@mangled/attypescache' specified in compilerOptions error TS2688: Cannot find type definition file for '@mangled/nodemodulescache'. The file is in the program because: Entry point of type library '@mangled/nodemodulescache' specified in compilerOptions error TS2688: Cannot find type definition file for '@mangled/typescache'. The file is in the program because: Entry point of type library '@mangled/typescache' specified in compilerOptions -error TS2688: Cannot find type definition file for '@scoped/attypescache'. - The file is in the program because: - Entry point of type library '@scoped/attypescache' specified in compilerOptions +/a.ts(2,1): error TS2304: Cannot find name 'mangledAtTypesCache'. /a.ts(4,1): error TS2304: Cannot find name 'mangledNodeModules'. -/a.ts(5,1): error TS2552: Cannot find name 'atTypesCache'. Did you mean 'typesCache'? +/a.ts(6,1): error TS2304: Cannot find name 'mangledAtTypesCache'. +!!! error TS2688: Cannot find type definition file for '@mangled/attypescache'. +!!! error TS2688: The file is in the program because: +!!! error TS2688: Entry point of type library '@mangled/attypescache' specified in compilerOptions !!! error TS2688: Cannot find type definition file for '@mangled/nodemodulescache'. !!! error TS2688: The file is in the program because: !!! error TS2688: Entry point of type library '@mangled/nodemodulescache' specified in compilerOptions !!! error TS2688: Cannot find type definition file for '@mangled/typescache'. !!! error TS2688: The file is in the program because: !!! error TS2688: Entry point of type library '@mangled/typescache' specified in compilerOptions -!!! error TS2688: Cannot find type definition file for '@scoped/attypescache'. -!!! error TS2688: The file is in the program because: -!!! error TS2688: Entry point of type library '@scoped/attypescache' specified in compilerOptions -==== /a.ts (2 errors) ==== +==== /a.ts (3 errors) ==== typesCache; mangledAtTypesCache; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'mangledAtTypesCache'. nodeModulesCache; mangledNodeModules; ~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'mangledNodeModules'. atTypesCache; - ~~~~~~~~~~~~ -!!! error TS2552: Cannot find name 'atTypesCache'. Did you mean 'typesCache'? -!!! related TS2728 /types/@scoped/typescache/index.d.ts:1:15: 'typesCache' is declared here. mangledAtTypesCache; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'mangledAtTypesCache'. ==== /types/@scoped/typescache/index.d.ts (0 errors) ==== declare const typesCache: number; diff --git a/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.symbols b/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.symbols index 980352c5e3c22..d64300a949d24 100644 --- a/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.symbols +++ b/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.symbols @@ -5,16 +5,14 @@ typesCache; >typesCache : Symbol(typesCache, Decl(index.d.ts, 0, 13)) mangledAtTypesCache; ->mangledAtTypesCache : Symbol(mangledAtTypesCache, Decl(index.d.ts, 0, 13)) - nodeModulesCache; >nodeModulesCache : Symbol(nodeModulesCache, Decl(index.d.ts, 0, 13)) mangledNodeModules; atTypesCache; -mangledAtTypesCache; ->mangledAtTypesCache : Symbol(mangledAtTypesCache, Decl(index.d.ts, 0, 13)) +>atTypesCache : Symbol(atTypesCache, Decl(index.d.ts, 0, 13)) +mangledAtTypesCache; === /types/@scoped/typescache/index.d.ts === declare const typesCache: number; >typesCache : Symbol(typesCache, Decl(index.d.ts, 0, 13)) @@ -23,7 +21,7 @@ declare const typesCache: number; declare const nodeModulesCache: number; >nodeModulesCache : Symbol(nodeModulesCache, Decl(index.d.ts, 0, 13)) -=== /node_modules/@types/mangled__attypescache/index.d.ts === -declare const mangledAtTypesCache: number; ->mangledAtTypesCache : Symbol(mangledAtTypesCache, Decl(index.d.ts, 0, 13)) +=== /node_modules/@types/@scoped/attypescache/index.d.ts === +declare const atTypesCache: number; +>atTypesCache : Symbol(atTypesCache, Decl(index.d.ts, 0, 13)) diff --git a/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.trace.json b/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.trace.json index af808d436429d..ba361033d1817 100644 --- a/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.trace.json +++ b/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.trace.json @@ -21,8 +21,10 @@ "File '/node_modules/@scoped/attypescache.d.ts' does not exist.", "Scoped package detected, looking in 'scoped__attypescache'", "File '/node_modules/@types/scoped__attypescache.d.ts' does not exist.", - "Resolving type reference directive for program that specifies custom typeRoots, skipping lookup in 'node_modules' folder.", - "======== Type reference directive '@scoped/attypescache' was not resolved. ========", + "File '/node_modules/@types/@scoped/attypescache/package.json' does not exist.", + "File '/node_modules/@types/@scoped/attypescache/index.d.ts' exists - use it as a name resolution result.", + "Resolving real path for '/node_modules/@types/@scoped/attypescache/index.d.ts', result '/node_modules/@types/@scoped/attypescache/index.d.ts'.", + "======== Type reference directive '@scoped/attypescache' was successfully resolved to '/node_modules/@types/@scoped/attypescache/index.d.ts', primary: true. ========", "======== Resolving type reference directive '@mangled/typescache', containing file '/__inferred type names__.ts', root directory '/types,/node_modules,/node_modules/@types'. ========", "Resolving with primary search path '/types, /node_modules, /node_modules/@types'.", "Scoped package detected, looking in 'mangled__typescache'", @@ -39,10 +41,8 @@ "Resolving with primary search path '/types, /node_modules, /node_modules/@types'.", "Scoped package detected, looking in 'mangled__attypescache'", "File '/node_modules/@types/mangled__attypescache.d.ts' does not exist.", - "File '/node_modules/@types/mangled__attypescache/package.json' does not exist.", - "File '/node_modules/@types/mangled__attypescache/index.d.ts' exists - use it as a name resolution result.", - "Resolving real path for '/node_modules/@types/mangled__attypescache/index.d.ts', result '/node_modules/@types/mangled__attypescache/index.d.ts'.", - "======== Type reference directive '@mangled/attypescache' was successfully resolved to '/node_modules/@types/mangled__attypescache/index.d.ts', primary: true. ========", + "Resolving type reference directive for program that specifies custom typeRoots, skipping lookup in 'node_modules' folder.", + "======== Type reference directive '@mangled/attypescache' was not resolved. ========", "File '/types/@scoped/typescache/package.json' does not exist according to earlier cached lookups.", "File '/types/@scoped/package.json' does not exist.", "File '/types/package.json' does not exist.", @@ -51,7 +51,8 @@ "File '/node_modules/@scoped/package.json' does not exist.", "File '/node_modules/package.json' does not exist.", "File '/package.json' does not exist according to earlier cached lookups.", - "File '/node_modules/@types/mangled__attypescache/package.json' does not exist according to earlier cached lookups.", + "File '/node_modules/@types/@scoped/attypescache/package.json' does not exist according to earlier cached lookups.", + "File '/node_modules/@types/@scoped/package.json' does not exist.", "File '/node_modules/@types/package.json' does not exist.", "File '/node_modules/package.json' does not exist according to earlier cached lookups.", "File '/package.json' does not exist according to earlier cached lookups.", diff --git a/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.types b/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.types index 318525428dd40..b2b7037d77787 100644 --- a/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.types +++ b/tests/baselines/reference/typeReferenceDirectiveScopedPackageCustomTypeRoot.types @@ -6,8 +6,8 @@ typesCache; > : ^^^^^^ mangledAtTypesCache; ->mangledAtTypesCache : number -> : ^^^^^^ +>mangledAtTypesCache : any +> : ^^^ nodeModulesCache; >nodeModulesCache : number @@ -18,12 +18,12 @@ mangledNodeModules; > : ^^^ atTypesCache; ->atTypesCache : any -> : ^^^ +>atTypesCache : number +> : ^^^^^^ mangledAtTypesCache; ->mangledAtTypesCache : number -> : ^^^^^^ +>mangledAtTypesCache : any +> : ^^^ === /types/@scoped/typescache/index.d.ts === declare const typesCache: number; @@ -35,8 +35,8 @@ declare const nodeModulesCache: number; >nodeModulesCache : number > : ^^^^^^ -=== /node_modules/@types/mangled__attypescache/index.d.ts === -declare const mangledAtTypesCache: number; ->mangledAtTypesCache : number -> : ^^^^^^ +=== /node_modules/@types/@scoped/attypescache/index.d.ts === +declare const atTypesCache: number; +>atTypesCache : number +> : ^^^^^^ diff --git a/tests/baselines/reference/typeRootsPrimarySecondaryLookupConsistency.baseline b/tests/baselines/reference/typeRootsPrimarySecondaryLookupConsistency.baseline new file mode 100644 index 0000000000000..f43acd2db49c2 --- /dev/null +++ b/tests/baselines/reference/typeRootsPrimarySecondaryLookupConsistency.baseline @@ -0,0 +1,46 @@ +// === Syntax and Semantic Diagnostics === +Syntactic Diagnostics for file '/tests/cases/fourslash/typeRootsPrimarySecondaryLookupConsistency.ts': + + +==== /node_modules/@types/inside-at-types/main.d.mts (0 errors) ==== + export {}; + declare global { + var exportsInsideAtTypes: any; + } +==== /node_modules/outside-at-types/main.d.mts (0 errors) ==== + export {}; + declare global { + var exportsOutsideAtTypes: any; + } +==== /index.ts (0 errors) ==== + typesFieldInsideAtTypes; // Error + typesFieldOutsideAtTypes; // Error + + exportsInsideAtTypes; + exportsOutsideAtTypes; + +Semantic Diagnostics for file '/tests/cases/fourslash/typeRootsPrimarySecondaryLookupConsistency.ts': +/index.ts(1,1): error TS2304: Cannot find name 'typesFieldInsideAtTypes'. +/index.ts(2,1): error TS2304: Cannot find name 'typesFieldOutsideAtTypes'. + + +==== /node_modules/@types/inside-at-types/main.d.mts (0 errors) ==== + export {}; + declare global { + var exportsInsideAtTypes: any; + } +==== /node_modules/outside-at-types/main.d.mts (0 errors) ==== + export {}; + declare global { + var exportsOutsideAtTypes: any; + } +==== /index.ts (2 errors) ==== + typesFieldInsideAtTypes; // Error + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'typesFieldInsideAtTypes'. + typesFieldOutsideAtTypes; // Error + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'typesFieldOutsideAtTypes'. + + exportsInsideAtTypes; + exportsOutsideAtTypes; \ No newline at end of file diff --git a/tests/cases/compiler/reactJsxReactResolvedNodeNextEsm.tsx b/tests/cases/compiler/reactJsxReactResolvedNodeNextEsm.tsx index 6d2fc006f15db..464f2d6dc64e5 100644 --- a/tests/cases/compiler/reactJsxReactResolvedNodeNextEsm.tsx +++ b/tests/cases/compiler/reactJsxReactResolvedNodeNextEsm.tsx @@ -14,6 +14,7 @@ export const a =
; "main": "", "types": "index.d.ts", "exports": { + ".": "./index.d.ts", "./*.js": "./*.js", "./*": "./*.js" } diff --git a/tests/cases/fourslash/server/autoImportProvider_exportMap6.ts b/tests/cases/fourslash/server/autoImportProvider_exportMap6.ts index 19a32344ae60d..14cccf8e5d099 100644 --- a/tests/cases/fourslash/server/autoImportProvider_exportMap6.ts +++ b/tests/cases/fourslash/server/autoImportProvider_exportMap6.ts @@ -5,7 +5,8 @@ // @Filename: /tsconfig.json //// { //// "compilerOptions": { -//// "module": "nodenext" +//// "module": "nodenext", +//// "types": [] //// } //// } diff --git a/tests/cases/fourslash/typeRootsPrimarySecondaryLookupConsistency.ts b/tests/cases/fourslash/typeRootsPrimarySecondaryLookupConsistency.ts new file mode 100644 index 0000000000000..68724afc210b9 --- /dev/null +++ b/tests/cases/fourslash/typeRootsPrimarySecondaryLookupConsistency.ts @@ -0,0 +1,67 @@ +/// + +// @Filename: /tsconfig.json +//// { +//// "compilerOptions": { +//// "module": "nodenext", +//// "types": ["inside-at-types", "outside-at-types"] +//// } +//// } + +// @Filename: /node_modules/@types/inside-at-types/package.json +//// { +//// "name": "@types/inside-at-types", +//// "version": "1.0.0", +//// "types": "./index.d.ts", +//// "exports": { +//// ".": { +//// "default": "./main.mjs" +//// } +//// } +//// } + +// @Filename: /node_modules/@types/inside-at-types/index.d.ts +//// export {}; +//// declare global { +//// var typesFieldInsideAtTypes: any; +//// } + +// @Filename: /node_modules/@types/inside-at-types/main.d.mts +//// export {}; +//// declare global { +//// var exportsInsideAtTypes: any; +//// } + +// @Filename: /node_modules/outside-at-types/package.json +//// { +//// "name": "outside-at-types", +//// "version": "1.0.0", +//// "types": "./index.d.ts", +//// "exports": { +//// ".": { +//// "default": "./main.mjs" +//// } +//// } +//// } + +// @Filename: /node_modules/outside-at-types/index.d.ts +//// export {}; +//// declare global { +//// var typesFieldOutsideAtTypes: any; +//// } + +// @Filename: /node_modules/outside-at-types/main.d.mts +//// export {}; +//// declare global { +//// var exportsOutsideAtTypes: any; +//// } + +// @Filename: /index.ts +//// typesFieldInsideAtTypes; // Error +//// typesFieldOutsideAtTypes; // Error +//// +//// exportsInsideAtTypes; +//// exportsOutsideAtTypes; + +goTo.file("/index.ts"); +verify.baselineSyntacticAndSemanticDiagnostics(); \ No newline at end of file