diff --git a/.github/tsc.json b/.github/tsc.json deleted file mode 100644 index 158f7e83d3a1b..0000000000000 --- a/.github/tsc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "problemMatcher": [ - { - "owner": "tsc", - "pattern": [ - { - "regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),(\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$", - "file": 1, - "line": 2, - "column": 3, - "severity": 4, - "code": 5, - "message": 6 - } - ] - } - ] -} diff --git a/package-lock.json b/package-lock.json index 138a520117c99..72b8001db2d7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -175,9 +175,9 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.4.tgz", - "integrity": "sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw==", + "version": "0.10.5", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.5.tgz", + "integrity": "sha512-XVVDtp+dVvRxMoxSiSfasYaG02VEe1qH5cKgMQJWhol6HwzbcqoCMJi8dAGoYAO57jhUyhI6cWuRiTcRaDaYug==", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", @@ -8615,9 +8615,9 @@ } }, "@humanwhocodes/config-array": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.4.tgz", - "integrity": "sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw==", + "version": "0.10.5", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.5.tgz", + "integrity": "sha512-XVVDtp+dVvRxMoxSiSfasYaG02VEe1qH5cKgMQJWhol6HwzbcqoCMJi8dAGoYAO57jhUyhI6cWuRiTcRaDaYug==", "dev": true, "requires": { "@humanwhocodes/object-schema": "^1.2.1", diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cfdc767d9cf40..dd56dc8ff8905 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7280,6 +7280,7 @@ namespace ts { && symbol.escapedName !== InternalSymbolName.ExportEquals && !(symbol.flags & SymbolFlags.Prototype) && !(symbol.flags & SymbolFlags.Class) + && !(symbol.flags & SymbolFlags.Method) && !isConstMergedWithNSPrintableAsSignatureMerge) { if (propertyAsAlias) { const createdExport = serializeMaybeAliasAssignment(symbol); diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 3e46edbec46c1..222d1dee63f4d 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -2437,12 +2437,7 @@ namespace ts { } } - const { packageName, rest } = parsePackageName(moduleName); const loader: ResolutionKindSpecificLoader = (extensions, candidate, onlyRecordFailures, state) => { - // package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them) - if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) { - return loadModuleFromExports(packageInfo, extensions, combinePaths(".", rest), state, cache, redirectedReference)?.value; - } let pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) || loadNodeModuleFromDirectoryWorker( @@ -2466,20 +2461,24 @@ namespace ts { return withPackageId(packageInfo, pathAndExtension); }; - if (rest !== "") { // If "rest" is empty, we just did this search above. - const packageDirectory = combinePaths(nodeModulesDirectory, packageName); - - // Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId and path mappings. + const { packageName, rest } = parsePackageName(moduleName); + const packageDirectory = combinePaths(nodeModulesDirectory, packageName); + if (rest !== "") { + // Previous `packageInfo` may have been from a nested package.json; ensure we have the one from the package root now. packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state); - if (packageInfo && packageInfo.contents.versionPaths) { - if (state.traceEnabled) { - trace(state.host, Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.contents.versionPaths.version, version, rest); - } - const packageDirectoryExists = nodeModulesDirectoryExists && directoryProbablyExists(packageDirectory, state.host); - const fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state); - if (fromPaths) { - return fromPaths.value; - } + } + // package exports are higher priority than file/directory/typesVersions lookups and (and, if there's exports present, blocks them) + if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) { + return loadModuleFromExports(packageInfo, extensions, combinePaths(".", rest), state, cache, redirectedReference)?.value; + } + if (rest !== "" && packageInfo && packageInfo.contents.versionPaths) { + if (state.traceEnabled) { + trace(state.host, Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.contents.versionPaths.version, version, rest); + } + const packageDirectoryExists = nodeModulesDirectoryExists && directoryProbablyExists(packageDirectory, state.host); + const fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.contents.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state); + if (fromPaths) { + return fromPaths.value; } } diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index 46130e35659f9..27b863a3abf3c 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -14,7 +14,7 @@ namespace ts { removeResolutionsOfFile(filePath: Path): void; removeResolutionsFromProjectReferenceRedirects(filePath: Path): void; setFilesWithInvalidatedNonRelativeUnresolvedImports(filesWithUnresolvedImports: ESMap): void; - createHasInvalidatedResolution(forceAllFilesAsInvalidated?: boolean): HasInvalidatedResolution; + createHasInvalidatedResolution(customHasInvalidatedResolution: HasInvalidatedResolution): HasInvalidatedResolution; hasChangedAutomaticTypeDirectiveNames(): boolean; isFileWithInvalidatedNonRelativeUnresolvedImports(path: Path): boolean; @@ -300,17 +300,13 @@ namespace ts { return !!value && !!value.length; } - function createHasInvalidatedResolution(forceAllFilesAsInvalidated?: boolean): HasInvalidatedResolution { + function createHasInvalidatedResolution(customHasInvalidatedResolution: HasInvalidatedResolution): HasInvalidatedResolution { // Ensure pending resolutions are applied invalidateResolutionsOfFailedLookupLocations(); - if (forceAllFilesAsInvalidated) { - // Any file asked would have invalidated resolution - filesWithInvalidatedResolutions = undefined; - return returnTrue; - } const collected = filesWithInvalidatedResolutions; filesWithInvalidatedResolutions = undefined; - return path => (!!collected && collected.has(path)) || + return path => customHasInvalidatedResolution(path) || + !!collected?.has(path) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1753770f44ce4..f63c1f21078bc 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -7215,7 +7215,8 @@ namespace ts { getEnvironmentVariable?(name: string): string | undefined; /* @internal */ onReleaseOldSourceFile?(oldSourceFile: SourceFile, oldOptions: CompilerOptions, hasSourceFileByPath: boolean): void; /* @internal */ onReleaseParsedCommandLine?(configFileName: string, oldResolvedRef: ResolvedProjectReference | undefined, optionOptions: CompilerOptions): void; - /* @internal */ hasInvalidatedResolution?: HasInvalidatedResolution; + /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */ + hasInvalidatedResolution?(filePath: Path): boolean; /* @internal */ hasChangedAutomaticTypeDirectiveNames?: HasChangedAutomaticTypeDirectiveNames; createHash?(data: string): string; getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; diff --git a/src/compiler/watchPublic.ts b/src/compiler/watchPublic.ts index 51f58d396c59c..788a8856f3a58 100644 --- a/src/compiler/watchPublic.ts +++ b/src/compiler/watchPublic.ts @@ -112,6 +112,8 @@ namespace ts { resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[]; + /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */ + hasInvalidatedResolution?(filePath: Path): boolean; /** * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it */ @@ -371,6 +373,10 @@ namespace ts { maybeBind(host, host.getModuleResolutionCache) : (() => resolutionCache.getModuleResolutionCache()); const userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; + // All resolutions are invalid if user provided resolutions and didnt supply hasInvalidatedResolution + const customHasInvalidatedResolution = userProvidedResolution ? + maybeBind(host, host.hasInvalidatedResolution) || returnTrue : + returnFalse; builderProgram = readBuilderProgram(compilerOptions, compilerHost) as any as T; synchronizeProgram(); @@ -443,8 +449,7 @@ namespace ts { } } - // All resolutions are invalid if user provided resolutions - const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); + const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(customHasInvalidatedResolution); const { originalReadFile, originalFileExists, originalDirectoryExists, originalCreateDirectory, originalWriteFile, diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 3935699561fad..491a5205e3847 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13227,15 +13227,6 @@ - - - - - - - - - @@ -13425,15 +13416,6 @@ - - - - - - - - - @@ -13680,6 +13662,15 @@ + + + + + + + + + @@ -14358,6 +14349,15 @@ + + + + + + + + + @@ -15249,6 +15249,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index 6cbf2bd958cfa..5ac938db518c7 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13662,6 +13662,15 @@ + + + + + + + + + @@ -15240,6 +15249,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index a720655caea5e..6dfde4fe463bf 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13236,15 +13236,6 @@ - - - - - - - - - @@ -13434,15 +13425,6 @@ - - - - - - - - - @@ -13689,6 +13671,15 @@ + + + + + + + + + @@ -14367,6 +14358,15 @@ + + + + + + + + + @@ -15258,6 +15258,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 592c2d4482f40..9a49e6a0153ab 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13656,6 +13656,15 @@ + + + + + + + + + @@ -15234,6 +15243,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 8dcce65959b25..72639b61e4da3 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13674,6 +13674,15 @@ + + + + + + + + + @@ -15252,6 +15261,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index d1e21b6763be2..b483ab9f285fe 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13239,15 +13239,6 @@ - - - - - - - - - @@ -13437,15 +13428,6 @@ - - - - - - - - - @@ -13692,6 +13674,15 @@ + + + + + + + + + @@ -14370,6 +14361,15 @@ + + + + + + + + + @@ -15261,6 +15261,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index f6cb8d7d6df8d..92308dd71b961 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13227,15 +13227,6 @@ - - - - - - - - - @@ -13425,15 +13416,6 @@ - - - - - - - - - @@ -13680,6 +13662,15 @@ + + + + + + + + + @@ -14358,6 +14349,15 @@ + + + + + + + + + @@ -15249,6 +15249,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index a7ecb39ba528f..1ea8603b279bb 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13662,6 +13662,15 @@ + + + + + + + + + @@ -15240,6 +15249,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 75e7eabc54878..31ea3324ef72e 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13662,6 +13662,15 @@ + + + + + + + + + @@ -15240,6 +15249,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 147a468e272ea..920523da277ec 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13214,15 +13214,6 @@ - - - - - - - - - @@ -13412,15 +13403,6 @@ - - - - - - - - - @@ -13667,6 +13649,12 @@ + + + + + + @@ -14345,6 +14333,15 @@ + + + + + + + + + @@ -15236,6 +15233,18 @@ + + + + + + + + + + + + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 66e46a340bd39..f087c0e7a39d2 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13652,6 +13652,15 @@ + + + + + + + + + @@ -15230,6 +15239,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index a8130e7dd33fd..8d729d7572889 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13661,6 +13661,15 @@ + + + + + + + + + @@ -15239,6 +15248,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/server/project.ts b/src/server/project.ts index 43b1c7128e005..8a45bab06057f 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1176,7 +1176,7 @@ namespace ts.server { Debug.assert(!this.isClosed(), "Called update graph worker of closed project"); this.writeLog(`Starting updateGraphWorker: Project: ${this.getProjectName()}`); const start = timestamp(); - this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution(); + this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution(returnFalse); this.resolutionCache.startCachingPerDirectoryResolution(); this.program = this.languageService.getProgram(); // TODO: GH#18217 this.dirty = false; diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 6e175092d0d4a..2542a0732342b 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -257,7 +257,7 @@ namespace ts.codefix { } const enumDeclaration = find(symbol.declarations, isEnumDeclaration); - if (enumDeclaration && !isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) { + if (enumDeclaration && !(leftExpressionType.flags & TypeFlags.EnumLike) && !isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) { return { kind: InfoKind.Enum, token, parentDeclaration: enumDeclaration }; } diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 8bec8c130bcae..7bce1b660b4cd 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -137,7 +137,7 @@ namespace ts.FindAllReferences { case SyntaxKind.ImportType: // Only check for typeof import('xyz') - if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { + if (!isAvailableThroughGlobal && direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); } directImports.push(direct); diff --git a/src/testRunner/unittests/tscWatch/watchApi.ts b/src/testRunner/unittests/tscWatch/watchApi.ts index 477a982eafde2..cfcbc115a69f4 100644 --- a/src/testRunner/unittests/tscWatch/watchApi.ts +++ b/src/testRunner/unittests/tscWatch/watchApi.ts @@ -1,23 +1,22 @@ namespace ts.tscWatch { describe("unittests:: tsc-watch:: watchAPI:: tsc-watch with custom module resolution", () => { - const configFileJson: any = { - compilerOptions: { module: "commonjs", resolveJsonModule: true }, - files: ["index.ts"] - }; - const mainFile: File = { - path: `${projectRoot}/index.ts`, - content: "import settings from './settings.json';" - }; - const config: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify(configFileJson) - }; - const settingsJson: File = { - path: `${projectRoot}/settings.json`, - content: JSON.stringify({ content: "Print this" }) - }; - it("verify that module resolution with json extension works when returned without extension", () => { + const configFileJson: any = { + compilerOptions: { module: "commonjs", resolveJsonModule: true }, + files: ["index.ts"] + }; + const mainFile: File = { + path: `${projectRoot}/index.ts`, + content: "import settings from './settings.json';" + }; + const config: File = { + path: `${projectRoot}/tsconfig.json`, + content: JSON.stringify(configFileJson) + }; + const settingsJson: File = { + path: `${projectRoot}/settings.json`, + content: JSON.stringify({ content: "Print this" }) + }; const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem( [libFile, mainFile, config, settingsJson], { currentDirectory: projectRoot }), @@ -50,6 +49,64 @@ namespace ts.tscWatch { watchOrSolution: watch }); }); + + describe("hasInvalidatedResolution", () => { + function verifyWatch(subScenario: string, implementHasInvalidatedResolution: boolean) { + it(subScenario, () => { + const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem({ + [`${projectRoot}/tsconfig.json`]: JSON.stringify({ + compilerOptions: { traceResolution: true, extendedDiagnostics: true }, + files: ["main.ts"] + }), + [`${projectRoot}/main.ts`]: `import { foo } from "./other";`, + [`${projectRoot}/other.d.ts`]: "export function foo(): void;", + [libFile.path]: libFile.content, + }, { currentDirectory: projectRoot })); + const host = createWatchCompilerHostOfConfigFileForBaseline({ + configFileName: `${projectRoot}/tsconfig.json`, + system: sys, + cb, + }); + host.resolveModuleNames = (moduleNames, containingFile, _reusedNames, _redirectedReference, options) => + moduleNames.map(m => resolveModuleName(m, containingFile, options, host).resolvedModule); + // Invalidate resolutions only when ts file is created + if (implementHasInvalidatedResolution) host.hasInvalidatedResolution = () => sys.fileExists(`${projectRoot}/other.ts`); + const watch = createWatchProgram(host); + runWatchBaseline({ + scenario: "watchApi", + subScenario, + commandLineArgs: ["--w"], + sys, + baseline, + oldSnap, + getPrograms, + changes: [ + { + caption: "write other with same contents", + change: sys => sys.appendFile(`${projectRoot}/other.d.ts`, ""), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "change other file", + change: sys => sys.appendFile(`${projectRoot}/other.d.ts`, "export function bar(): void;"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "write other with same contents but write ts file", + change: sys => { + sys.appendFile(`${projectRoot}/other.d.ts`, ""); + sys.writeFile(`${projectRoot}/other.ts`, "export function foo() {}"); + }, + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ], + watchOrSolution: watch + }); + }); + } + verifyWatch("host implements does not implement hasInvalidatedResolution", /*implementHasInvalidatedResolution*/ false); + verifyWatch("host implements hasInvalidatedResolution", /*implementHasInvalidatedResolution*/ true); + }); }); describe("unittests:: tsc-watch:: watchAPI:: tsc-watch expose error count to watch status reporter", () => { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 50fbd1d4dea72..7b3d74e82987d 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3320,6 +3320,8 @@ declare namespace ts { */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; + /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */ + hasInvalidatedResolution?(filePath: Path): boolean; createHash?(data: string): string; getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } @@ -5442,6 +5444,8 @@ declare namespace ts { resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[]; + /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */ + hasInvalidatedResolution?(filePath: Path): boolean; /** * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it */ diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index d323d77c229dd..d65d6e1054086 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3320,6 +3320,8 @@ declare namespace ts { */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; + /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */ + hasInvalidatedResolution?(filePath: Path): boolean; createHash?(data: string): string; getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } @@ -5442,6 +5444,8 @@ declare namespace ts { resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[]; + /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */ + hasInvalidatedResolution?(filePath: Path): boolean; /** * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it */ diff --git a/tests/baselines/reference/declarationEmitMethodDeclaration.js b/tests/baselines/reference/declarationEmitMethodDeclaration.js new file mode 100644 index 0000000000000..d0d7a923e5637 --- /dev/null +++ b/tests/baselines/reference/declarationEmitMethodDeclaration.js @@ -0,0 +1,17 @@ +//// [a.js] +export default { + methods: { + foo() { } + } +} + + + + +//// [a.d.ts] +declare namespace _default { + namespace methods { + function foo(): void; + } +} +export default _default; diff --git a/tests/baselines/reference/declarationEmitMethodDeclaration.symbols b/tests/baselines/reference/declarationEmitMethodDeclaration.symbols new file mode 100644 index 0000000000000..2496f2870965b --- /dev/null +++ b/tests/baselines/reference/declarationEmitMethodDeclaration.symbols @@ -0,0 +1,10 @@ +=== /a.js === +export default { + methods: { +>methods : Symbol(methods, Decl(a.js, 0, 16)) + + foo() { } +>foo : Symbol(foo, Decl(a.js, 1, 14)) + } +} + diff --git a/tests/baselines/reference/declarationEmitMethodDeclaration.types b/tests/baselines/reference/declarationEmitMethodDeclaration.types new file mode 100644 index 0000000000000..c672e7d5dc9b0 --- /dev/null +++ b/tests/baselines/reference/declarationEmitMethodDeclaration.types @@ -0,0 +1,13 @@ +=== /a.js === +export default { +>{ methods: { foo() { } }} : { methods: { foo(): void; }; } + + methods: { +>methods : { foo(): void; } +>{ foo() { } } : { foo(): void; } + + foo() { } +>foo : () => void + } +} + diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt new file mode 100644 index 0000000000000..22d2482ced9ae --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).errors.txt @@ -0,0 +1,92 @@ +error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.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 +/main.cts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. + If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` +/main.cts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. +/main.cts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. +/main.mts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. + If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` +/main.mts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. +/main.mts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. + + +!!! error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.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 +==== /node_modules/exports-and-types-versions/package.json (0 errors) ==== + { + "name": "exports-and-types-versions", + "version": "1.0.0", + "exports": { + "./foo": "./dist/foo.js", + "./yep": { + "types": "./types/foo.d.ts", + "default": "./dist/foo.js" + }, + "./versioned-yep": { + "types@>=4": "./types/foo.d.ts" + }, + "./versioned-nah": { + "types@<4": "./types/foo.d.ts" + } + }, + "typesVersions": { + "*": { + "foo": ["./types/foo.d.ts"], + "nope": ["./types/foo.d.ts"], + "versioned-nah": ["./types/foo.d.ts"] + } + } + } + +==== /node_modules/exports-and-types-versions/dist/foo.js (0 errors) ==== + module.exports = {}; + +==== /node_modules/exports-and-types-versions/types/foo.d.ts (0 errors) ==== + export {}; + +==== /node_modules/just-types-versions/package.json (0 errors) ==== + { + "name": "just-types-versions", + "version": "1.0.0", + "typesVersions": { + "*": { + "foo": ["./types/foo.d.ts"] + } + } + } + +==== /node_modules/just-types-versions/types/foo.d.ts (0 errors) ==== + export {}; + +==== /main.cts (3 errors) ==== + import {} from "exports-and-types-versions/foo"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. +!!! error TS7016: If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` + import {} from "exports-and-types-versions/nope"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. + import {} from "exports-and-types-versions/yep"; + import {} from "exports-and-types-versions/versioned-yep"; + import {} from "exports-and-types-versions/versioned-nah"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. + import {} from "just-types-versions/foo"; + +==== /main.mts (3 errors) ==== + import {} from "exports-and-types-versions/foo"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. +!!! error TS7016: If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` + import {} from "exports-and-types-versions/nope"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. + import {} from "exports-and-types-versions/yep"; + import {} from "exports-and-types-versions/versioned-yep"; + import {} from "exports-and-types-versions/versioned-nah"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. + import {} from "just-types-versions/foo"; + \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).js b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).js new file mode 100644 index 0000000000000..396ca2dfc4bcc --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).js @@ -0,0 +1,70 @@ +//// [tests/cases/conformance/node/nodeModulesExportsBlocksTypesVersions.ts] //// + +//// [package.json] +{ + "name": "exports-and-types-versions", + "version": "1.0.0", + "exports": { + "./foo": "./dist/foo.js", + "./yep": { + "types": "./types/foo.d.ts", + "default": "./dist/foo.js" + }, + "./versioned-yep": { + "types@>=4": "./types/foo.d.ts" + }, + "./versioned-nah": { + "types@<4": "./types/foo.d.ts" + } + }, + "typesVersions": { + "*": { + "foo": ["./types/foo.d.ts"], + "nope": ["./types/foo.d.ts"], + "versioned-nah": ["./types/foo.d.ts"] + } + } +} + +//// [foo.js] +module.exports = {}; + +//// [foo.d.ts] +export {}; + +//// [package.json] +{ + "name": "just-types-versions", + "version": "1.0.0", + "typesVersions": { + "*": { + "foo": ["./types/foo.d.ts"] + } + } +} + +//// [foo.d.ts] +export {}; + +//// [main.cts] +import {} from "exports-and-types-versions/foo"; +import {} from "exports-and-types-versions/nope"; +import {} from "exports-and-types-versions/yep"; +import {} from "exports-and-types-versions/versioned-yep"; +import {} from "exports-and-types-versions/versioned-nah"; +import {} from "just-types-versions/foo"; + +//// [main.mts] +import {} from "exports-and-types-versions/foo"; +import {} from "exports-and-types-versions/nope"; +import {} from "exports-and-types-versions/yep"; +import {} from "exports-and-types-versions/versioned-yep"; +import {} from "exports-and-types-versions/versioned-nah"; +import {} from "just-types-versions/foo"; + + +//// [main.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [main.mjs] +export {}; diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).symbols b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).symbols new file mode 100644 index 0000000000000..2db356fe2494c --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).symbols @@ -0,0 +1,23 @@ +=== /node_modules/exports-and-types-versions/types/foo.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /node_modules/just-types-versions/types/foo.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /main.cts === +import {} from "exports-and-types-versions/foo"; +No type information for this code.import {} from "exports-and-types-versions/nope"; +No type information for this code.import {} from "exports-and-types-versions/yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-nah"; +No type information for this code.import {} from "just-types-versions/foo"; +No type information for this code. +No type information for this code.=== /main.mts === +import {} from "exports-and-types-versions/foo"; +No type information for this code.import {} from "exports-and-types-versions/nope"; +No type information for this code.import {} from "exports-and-types-versions/yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-nah"; +No type information for this code.import {} from "just-types-versions/foo"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).trace.json b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).trace.json new file mode 100644 index 0000000000000..64a53eefcc0c7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).trace.json @@ -0,0 +1,260 @@ +[ + "File '/node_modules/exports-and-types-versions/types/package.json' does not exist.", + "Found 'package.json' at '/node_modules/exports-and-types-versions/package.json'.", + "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "File '/node_modules/just-types-versions/types/package.json' does not exist.", + "Found 'package.json' at '/node_modules/just-types-versions/package.json'.", + "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "======== Resolving module 'exports-and-types-versions/foo' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist.", + "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File name '/node_modules/exports-and-types-versions/dist/foo.js' has a '.js' extension - stripping it.", + "File '/node_modules/exports-and-types-versions/dist/foo.ts' does not exist.", + "File '/node_modules/exports-and-types-versions/dist/foo.tsx' does not exist.", + "File '/node_modules/exports-and-types-versions/dist/foo.d.ts' does not exist.", + "Export specifier './foo' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File name '/node_modules/exports-and-types-versions/dist/foo.js' has a '.js' extension - stripping it.", + "File '/node_modules/exports-and-types-versions/dist/foo.js' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/dist/foo.js', result '/node_modules/exports-and-types-versions/dist/foo.js'.", + "======== Module name 'exports-and-types-versions/foo' was successfully resolved to '/node_modules/exports-and-types-versions/dist/foo.js' with Package ID 'exports-and-types-versions/dist/foo.js@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/nope' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './nope' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './nope' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "======== Module name 'exports-and-types-versions/nope' was not resolved. ========", + "======== Resolving module 'exports-and-types-versions/yep' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/yep' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File '/node_modules/exports-and-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/types/foo.d.ts', result '/node_modules/exports-and-types-versions/types/foo.d.ts'.", + "======== Module name 'exports-and-types-versions/yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/versioned-yep' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-yep' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File '/node_modules/exports-and-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/types/foo.d.ts', result '/node_modules/exports-and-types-versions/types/foo.d.ts'.", + "======== Module name 'exports-and-types-versions/versioned-yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/versioned-nah' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './versioned-nah' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './versioned-nah' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "======== Module name 'exports-and-types-versions/versioned-nah' was not resolved. ========", + "======== Resolving module 'just-types-versions/foo' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'just-types-versions/foo' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/just-types-versions/package.json' exists according to earlier cached lookups.", + "'package.json' has a 'typesVersions' entry '*' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'foo'.", + "Module name 'foo', matched pattern 'foo'.", + "Trying substitution './types/foo.d.ts', candidate module location: './types/foo.d.ts'.", + "File '/node_modules/just-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/just-types-versions/types/foo.d.ts', result '/node_modules/just-types-versions/types/foo.d.ts'.", + "======== Module name 'just-types-versions/foo' was successfully resolved to '/node_modules/just-types-versions/types/foo.d.ts'. ========", + "======== Resolving module 'exports-and-types-versions/foo' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File name '/node_modules/exports-and-types-versions/dist/foo.js' has a '.js' extension - stripping it.", + "File '/node_modules/exports-and-types-versions/dist/foo.ts' does not exist.", + "File '/node_modules/exports-and-types-versions/dist/foo.tsx' does not exist.", + "File '/node_modules/exports-and-types-versions/dist/foo.d.ts' does not exist.", + "Export specifier './foo' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File name '/node_modules/exports-and-types-versions/dist/foo.js' has a '.js' extension - stripping it.", + "File '/node_modules/exports-and-types-versions/dist/foo.js' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/dist/foo.js', result '/node_modules/exports-and-types-versions/dist/foo.js'.", + "======== Module name 'exports-and-types-versions/foo' was successfully resolved to '/node_modules/exports-and-types-versions/dist/foo.js' with Package ID 'exports-and-types-versions/dist/foo.js@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/nope' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './nope' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './nope' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "======== Module name 'exports-and-types-versions/nope' was not resolved. ========", + "======== Resolving module 'exports-and-types-versions/yep' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/yep' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File '/node_modules/exports-and-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/types/foo.d.ts', result '/node_modules/exports-and-types-versions/types/foo.d.ts'.", + "======== Module name 'exports-and-types-versions/yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/versioned-yep' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-yep' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File '/node_modules/exports-and-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/types/foo.d.ts', result '/node_modules/exports-and-types-versions/types/foo.d.ts'.", + "======== Module name 'exports-and-types-versions/versioned-yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/versioned-nah' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './versioned-nah' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './versioned-nah' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "======== Module name 'exports-and-types-versions/versioned-nah' was not resolved. ========", + "======== Resolving module 'just-types-versions/foo' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'Node16'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'just-types-versions/foo' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/just-types-versions/package.json' exists according to earlier cached lookups.", + "'package.json' has a 'typesVersions' entry '*' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'foo'.", + "Module name 'foo', matched pattern 'foo'.", + "Trying substitution './types/foo.d.ts', candidate module location: './types/foo.d.ts'.", + "File '/node_modules/just-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/just-types-versions/types/foo.d.ts', result '/node_modules/just-types-versions/types/foo.d.ts'.", + "======== Module name 'just-types-versions/foo' was successfully resolved to '/node_modules/just-types-versions/types/foo.d.ts'. ========", + "File 'package.json' does not exist.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups." +] \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).types b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).types new file mode 100644 index 0000000000000..2db356fe2494c --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=node16).types @@ -0,0 +1,23 @@ +=== /node_modules/exports-and-types-versions/types/foo.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /node_modules/just-types-versions/types/foo.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /main.cts === +import {} from "exports-and-types-versions/foo"; +No type information for this code.import {} from "exports-and-types-versions/nope"; +No type information for this code.import {} from "exports-and-types-versions/yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-nah"; +No type information for this code.import {} from "just-types-versions/foo"; +No type information for this code. +No type information for this code.=== /main.mts === +import {} from "exports-and-types-versions/foo"; +No type information for this code.import {} from "exports-and-types-versions/nope"; +No type information for this code.import {} from "exports-and-types-versions/yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-nah"; +No type information for this code.import {} from "just-types-versions/foo"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt new file mode 100644 index 0000000000000..22d2482ced9ae --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).errors.txt @@ -0,0 +1,92 @@ +error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.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 +/main.cts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. + If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` +/main.cts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. +/main.cts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. +/main.mts(1,16): error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. + If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` +/main.mts(2,16): error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. +/main.mts(5,16): error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. + + +!!! error TS6504: File '/node_modules/exports-and-types-versions/dist/foo.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 +==== /node_modules/exports-and-types-versions/package.json (0 errors) ==== + { + "name": "exports-and-types-versions", + "version": "1.0.0", + "exports": { + "./foo": "./dist/foo.js", + "./yep": { + "types": "./types/foo.d.ts", + "default": "./dist/foo.js" + }, + "./versioned-yep": { + "types@>=4": "./types/foo.d.ts" + }, + "./versioned-nah": { + "types@<4": "./types/foo.d.ts" + } + }, + "typesVersions": { + "*": { + "foo": ["./types/foo.d.ts"], + "nope": ["./types/foo.d.ts"], + "versioned-nah": ["./types/foo.d.ts"] + } + } + } + +==== /node_modules/exports-and-types-versions/dist/foo.js (0 errors) ==== + module.exports = {}; + +==== /node_modules/exports-and-types-versions/types/foo.d.ts (0 errors) ==== + export {}; + +==== /node_modules/just-types-versions/package.json (0 errors) ==== + { + "name": "just-types-versions", + "version": "1.0.0", + "typesVersions": { + "*": { + "foo": ["./types/foo.d.ts"] + } + } + } + +==== /node_modules/just-types-versions/types/foo.d.ts (0 errors) ==== + export {}; + +==== /main.cts (3 errors) ==== + import {} from "exports-and-types-versions/foo"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. +!!! error TS7016: If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` + import {} from "exports-and-types-versions/nope"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. + import {} from "exports-and-types-versions/yep"; + import {} from "exports-and-types-versions/versioned-yep"; + import {} from "exports-and-types-versions/versioned-nah"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. + import {} from "just-types-versions/foo"; + +==== /main.mts (3 errors) ==== + import {} from "exports-and-types-versions/foo"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7016: Could not find a declaration file for module 'exports-and-types-versions/foo'. '/node_modules/exports-and-types-versions/dist/foo.js' implicitly has an 'any' type. +!!! error TS7016: If the 'exports-and-types-versions' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'exports-and-types-versions/foo';` + import {} from "exports-and-types-versions/nope"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'exports-and-types-versions/nope' or its corresponding type declarations. + import {} from "exports-and-types-versions/yep"; + import {} from "exports-and-types-versions/versioned-yep"; + import {} from "exports-and-types-versions/versioned-nah"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'exports-and-types-versions/versioned-nah' or its corresponding type declarations. + import {} from "just-types-versions/foo"; + \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).js b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).js new file mode 100644 index 0000000000000..396ca2dfc4bcc --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).js @@ -0,0 +1,70 @@ +//// [tests/cases/conformance/node/nodeModulesExportsBlocksTypesVersions.ts] //// + +//// [package.json] +{ + "name": "exports-and-types-versions", + "version": "1.0.0", + "exports": { + "./foo": "./dist/foo.js", + "./yep": { + "types": "./types/foo.d.ts", + "default": "./dist/foo.js" + }, + "./versioned-yep": { + "types@>=4": "./types/foo.d.ts" + }, + "./versioned-nah": { + "types@<4": "./types/foo.d.ts" + } + }, + "typesVersions": { + "*": { + "foo": ["./types/foo.d.ts"], + "nope": ["./types/foo.d.ts"], + "versioned-nah": ["./types/foo.d.ts"] + } + } +} + +//// [foo.js] +module.exports = {}; + +//// [foo.d.ts] +export {}; + +//// [package.json] +{ + "name": "just-types-versions", + "version": "1.0.0", + "typesVersions": { + "*": { + "foo": ["./types/foo.d.ts"] + } + } +} + +//// [foo.d.ts] +export {}; + +//// [main.cts] +import {} from "exports-and-types-versions/foo"; +import {} from "exports-and-types-versions/nope"; +import {} from "exports-and-types-versions/yep"; +import {} from "exports-and-types-versions/versioned-yep"; +import {} from "exports-and-types-versions/versioned-nah"; +import {} from "just-types-versions/foo"; + +//// [main.mts] +import {} from "exports-and-types-versions/foo"; +import {} from "exports-and-types-versions/nope"; +import {} from "exports-and-types-versions/yep"; +import {} from "exports-and-types-versions/versioned-yep"; +import {} from "exports-and-types-versions/versioned-nah"; +import {} from "just-types-versions/foo"; + + +//// [main.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [main.mjs] +export {}; diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).symbols b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).symbols new file mode 100644 index 0000000000000..2db356fe2494c --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).symbols @@ -0,0 +1,23 @@ +=== /node_modules/exports-and-types-versions/types/foo.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /node_modules/just-types-versions/types/foo.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /main.cts === +import {} from "exports-and-types-versions/foo"; +No type information for this code.import {} from "exports-and-types-versions/nope"; +No type information for this code.import {} from "exports-and-types-versions/yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-nah"; +No type information for this code.import {} from "just-types-versions/foo"; +No type information for this code. +No type information for this code.=== /main.mts === +import {} from "exports-and-types-versions/foo"; +No type information for this code.import {} from "exports-and-types-versions/nope"; +No type information for this code.import {} from "exports-and-types-versions/yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-nah"; +No type information for this code.import {} from "just-types-versions/foo"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).trace.json b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).trace.json new file mode 100644 index 0000000000000..0469b9d6ee7c7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).trace.json @@ -0,0 +1,264 @@ +[ + "File '/node_modules/exports-and-types-versions/types/package.json' does not exist.", + "Found 'package.json' at '/node_modules/exports-and-types-versions/package.json'.", + "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "File '/node_modules/just-types-versions/types/package.json' does not exist.", + "Found 'package.json' at '/node_modules/just-types-versions/package.json'.", + "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "======== Resolving module 'exports-and-types-versions/foo' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist.", + "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File name '/node_modules/exports-and-types-versions/dist/foo.js' has a '.js' extension - stripping it.", + "File '/node_modules/exports-and-types-versions/dist/foo.ts' does not exist.", + "File '/node_modules/exports-and-types-versions/dist/foo.tsx' does not exist.", + "File '/node_modules/exports-and-types-versions/dist/foo.d.ts' does not exist.", + "Export specifier './foo' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File name '/node_modules/exports-and-types-versions/dist/foo.js' has a '.js' extension - stripping it.", + "File '/node_modules/exports-and-types-versions/dist/foo.js' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/dist/foo.js', result '/node_modules/exports-and-types-versions/dist/foo.js'.", + "======== Module name 'exports-and-types-versions/foo' was successfully resolved to '/node_modules/exports-and-types-versions/dist/foo.js' with Package ID 'exports-and-types-versions/dist/foo.js@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/nope' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './nope' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './nope' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "======== Module name 'exports-and-types-versions/nope' was not resolved. ========", + "======== Resolving module 'exports-and-types-versions/yep' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/yep' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File '/node_modules/exports-and-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/types/foo.d.ts', result '/node_modules/exports-and-types-versions/types/foo.d.ts'.", + "======== Module name 'exports-and-types-versions/yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/versioned-yep' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-yep' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File '/node_modules/exports-and-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/types/foo.d.ts', result '/node_modules/exports-and-types-versions/types/foo.d.ts'.", + "======== Module name 'exports-and-types-versions/versioned-yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/versioned-nah' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './versioned-nah' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './versioned-nah' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "======== Module name 'exports-and-types-versions/versioned-nah' was not resolved. ========", + "======== Resolving module 'just-types-versions/foo' from '/main.cts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'just-types-versions/foo' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/just-types-versions/package.json' exists according to earlier cached lookups.", + "'package.json' has a 'typesVersions' entry '*' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'foo'.", + "Module name 'foo', matched pattern 'foo'.", + "Trying substitution './types/foo.d.ts', candidate module location: './types/foo.d.ts'.", + "File '/node_modules/just-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/just-types-versions/types/foo.d.ts', result '/node_modules/just-types-versions/types/foo.d.ts'.", + "======== Module name 'just-types-versions/foo' was successfully resolved to '/node_modules/just-types-versions/types/foo.d.ts'. ========", + "======== Resolving module 'exports-and-types-versions/foo' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File name '/node_modules/exports-and-types-versions/dist/foo.js' has a '.js' extension - stripping it.", + "File '/node_modules/exports-and-types-versions/dist/foo.ts' does not exist.", + "File '/node_modules/exports-and-types-versions/dist/foo.tsx' does not exist.", + "File '/node_modules/exports-and-types-versions/dist/foo.d.ts' does not exist.", + "Export specifier './foo' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/foo' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File name '/node_modules/exports-and-types-versions/dist/foo.js' has a '.js' extension - stripping it.", + "File '/node_modules/exports-and-types-versions/dist/foo.js' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/dist/foo.js', result '/node_modules/exports-and-types-versions/dist/foo.js'.", + "======== Module name 'exports-and-types-versions/foo' was successfully resolved to '/node_modules/exports-and-types-versions/dist/foo.js' with Package ID 'exports-and-types-versions/dist/foo.js@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/nope' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './nope' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/nope' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './nope' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "======== Module name 'exports-and-types-versions/nope' was not resolved. ========", + "======== Resolving module 'exports-and-types-versions/yep' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/yep' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File '/node_modules/exports-and-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/types/foo.d.ts', result '/node_modules/exports-and-types-versions/types/foo.d.ts'.", + "======== Module name 'exports-and-types-versions/yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/versioned-yep' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-yep' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "File '/node_modules/exports-and-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/exports-and-types-versions/types/foo.d.ts', result '/node_modules/exports-and-types-versions/types/foo.d.ts'.", + "======== Module name 'exports-and-types-versions/versioned-yep' was successfully resolved to '/node_modules/exports-and-types-versions/types/foo.d.ts' with Package ID 'exports-and-types-versions/types/foo.d.ts@1.0.0'. ========", + "======== Resolving module 'exports-and-types-versions/versioned-nah' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './versioned-nah' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'exports-and-types-versions/versioned-nah' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/exports-and-types-versions/package.json' exists according to earlier cached lookups.", + "Export specifier './versioned-nah' does not exist in package.json scope at path '/node_modules/exports-and-types-versions'.", + "======== Module name 'exports-and-types-versions/versioned-nah' was not resolved. ========", + "======== Resolving module 'just-types-versions/foo' from '/main.mts'. ========", + "Module resolution kind is not specified, using 'NodeNext'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'just-types-versions/foo' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/just-types-versions/package.json' exists according to earlier cached lookups.", + "'package.json' has a 'typesVersions' entry '*' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'foo'.", + "Module name 'foo', matched pattern 'foo'.", + "Trying substitution './types/foo.d.ts', candidate module location: './types/foo.d.ts'.", + "File '/node_modules/just-types-versions/types/foo.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/just-types-versions/types/foo.d.ts', result '/node_modules/just-types-versions/types/foo.d.ts'.", + "======== Module name 'just-types-versions/foo' was successfully resolved to '/node_modules/just-types-versions/types/foo.d.ts'. ========", + "File 'package.json' does not exist.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups.", + "File 'package.json' does not exist according to earlier cached lookups.", + "File '/package.json' does not exist according to earlier cached lookups." +] \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).types b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).types new file mode 100644 index 0000000000000..2db356fe2494c --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksTypesVersions(module=nodenext).types @@ -0,0 +1,23 @@ +=== /node_modules/exports-and-types-versions/types/foo.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /node_modules/just-types-versions/types/foo.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /main.cts === +import {} from "exports-and-types-versions/foo"; +No type information for this code.import {} from "exports-and-types-versions/nope"; +No type information for this code.import {} from "exports-and-types-versions/yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-nah"; +No type information for this code.import {} from "just-types-versions/foo"; +No type information for this code. +No type information for this code.=== /main.mts === +import {} from "exports-and-types-versions/foo"; +No type information for this code.import {} from "exports-and-types-versions/nope"; +No type information for this code.import {} from "exports-and-types-versions/yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-yep"; +No type information for this code.import {} from "exports-and-types-versions/versioned-nah"; +No type information for this code.import {} from "just-types-versions/foo"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc b/tests/baselines/reference/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc new file mode 100644 index 0000000000000..7b1eac5d729a0 --- /dev/null +++ b/tests/baselines/reference/referencesIsAvailableThroughGlobalNoCrash.baseline.jsonc @@ -0,0 +1,293 @@ +// === /packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts === +// declare var [|debug|]: [|debug|].Debug & { debug: [|debug|].Debug; default: [|debug|].Debug }; +// [|export|] = [|debug|]; +// export as namespace debug; +// declare namespace [|debug|] { +// interface Debug { +// coerce: (val: any) => any; +// } +// } + +// === /packages/playwright-core/src/index.ts === +// export const debug: typeof import('[|../bundles/utils/node_modules//*FIND ALL REFS*/@types/debug|]') = require('./utilsBundleImpl').debug; + +[ + { + "definition": { + "containerKind": "", + "containerName": "", + "fileName": "/packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts", + "kind": "module", + "name": "module \"/packages/playwright-core/bundles/utils/node_modules/@types/debug/index\"", + "textSpan": { + "start": 0, + "length": 211 + }, + "displayParts": [ + { + "text": "module", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "\"/packages/playwright-core/bundles/utils/node_modules/@types/debug/index\"", + "kind": "stringLiteral" + } + ] + }, + "references": [ + { + "textSpan": { + "start": 79, + "length": 6 + }, + "fileName": "/packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts", + "contextSpan": { + "start": 79, + "length": 15 + }, + "isWriteAccess": false + } + ] + }, + { + "definition": { + "containerKind": "", + "containerName": "", + "fileName": "/packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts", + "kind": "var", + "name": "namespace debug\nvar debug: debug.Debug & {\n debug: debug.Debug;\n default: debug.Debug;\n}", + "textSpan": { + "start": 12, + "length": 5 + }, + "displayParts": [ + { + "text": "namespace", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "debug", + "kind": "localName" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "var", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "debug", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "debug", + "kind": "localName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Debug", + "kind": "interfaceName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "&", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "debug", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "debug", + "kind": "localName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Debug", + "kind": "text" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "default", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "debug", + "kind": "localName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Debug", + "kind": "text" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "contextSpan": { + "start": 0, + "length": 78 + } + }, + "references": [ + { + "textSpan": { + "start": 12, + "length": 5 + }, + "fileName": "/packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts", + "contextSpan": { + "start": 0, + "length": 78 + }, + "isWriteAccess": true + }, + { + "textSpan": { + "start": 19, + "length": 5 + }, + "fileName": "/packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts", + "isWriteAccess": false + }, + { + "textSpan": { + "start": 42, + "length": 5 + }, + "fileName": "/packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts", + "isWriteAccess": false + }, + { + "textSpan": { + "start": 64, + "length": 5 + }, + "fileName": "/packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts", + "isWriteAccess": false + }, + { + "textSpan": { + "start": 88, + "length": 5 + }, + "fileName": "/packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts", + "contextSpan": { + "start": 79, + "length": 15 + }, + "isWriteAccess": false + }, + { + "textSpan": { + "start": 35, + "length": 42 + }, + "fileName": "/packages/playwright-core/src/index.ts", + "contextSpan": { + "start": 0, + "length": 117 + }, + "isWriteAccess": false + }, + { + "textSpan": { + "start": 140, + "length": 5 + }, + "fileName": "/packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts", + "contextSpan": { + "start": 122, + "length": 89 + }, + "isWriteAccess": true + } + ] + } +] \ No newline at end of file diff --git a/tests/baselines/reference/tscWatch/watchApi/host-implements-does-not-implement-hasInvalidatedResolution.js b/tests/baselines/reference/tscWatch/watchApi/host-implements-does-not-implement-hasInvalidatedResolution.js new file mode 100644 index 0000000000000..b18d7b8972d77 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchApi/host-implements-does-not-implement-hasInvalidatedResolution.js @@ -0,0 +1,287 @@ +Input:: +//// [/user/username/projects/myproject/tsconfig.json] +{"compilerOptions":{"traceResolution":true,"extendedDiagnostics":true},"files":["main.ts"]} + +//// [/user/username/projects/myproject/main.ts] +import { foo } from "./other"; + +//// [/user/username/projects/myproject/other.d.ts] +export function foo(): void; + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +/a/lib/tsc.js --w +Output:: +>> Screen clear +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/main.ts"] + options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/main.ts 250 undefined Source file +======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'NodeJs'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'. +File '/user/username/projects/myproject/other.ts' does not exist. +File '/user/username/projects/myproject/other.tsx' does not exist. +File '/user/username/projects/myproject/other.d.ts' exist - use it as a name resolution result. +======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.d.ts'. ======== +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 undefined Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots +[12:00:26 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/main.ts"] +Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/other.d.ts +/user/username/projects/myproject/main.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/other.d.ts +/user/username/projects/myproject/main.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/other.d.ts (used version) +/user/username/projects/myproject/main.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/main.ts: + {} +/user/username/projects/myproject/other.d.ts: + {} +/a/lib/lib.d.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/main.js] +"use strict"; +exports.__esModule = true; + + + +Change:: write other with same contents + +Input:: +//// [/user/username/projects/myproject/other.d.ts] file changed its modified time + +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Synchronizing program +[12:00:29 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/main.ts"] + options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'NodeJs'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'. +File '/user/username/projects/myproject/other.ts' does not exist. +File '/user/username/projects/myproject/other.tsx' does not exist. +File '/user/username/projects/myproject/other.d.ts' exist - use it as a name resolution result. +======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.d.ts'. ======== +[12:00:30 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/main.ts"] +Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: SafeModules +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/other.d.ts +/user/username/projects/myproject/main.ts + +Semantic diagnostics in builder refreshed for:: + +No shapes updated in the builder:: + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/main.ts: + {} +/user/username/projects/myproject/other.d.ts: + {} +/a/lib/lib.d.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + + +Change:: change other file + +Input:: +//// [/user/username/projects/myproject/other.d.ts] +export function foo(): void;export function bar(): void; + + +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Synchronizing program +[12:00:33 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/main.ts"] + options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'NodeJs'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'. +File '/user/username/projects/myproject/other.ts' does not exist. +File '/user/username/projects/myproject/other.tsx' does not exist. +File '/user/username/projects/myproject/other.d.ts' exist - use it as a name resolution result. +======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.d.ts'. ======== +[12:00:37 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/main.ts"] +Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: SafeModules +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/other.d.ts +/user/username/projects/myproject/main.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/other.d.ts +/user/username/projects/myproject/main.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/other.d.ts (used version) +/user/username/projects/myproject/main.ts (computed .d.ts) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/main.ts: + {} +/user/username/projects/myproject/other.d.ts: + {} +/a/lib/lib.d.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/main.js] file written with same contents + +Change:: write other with same contents but write ts file + +Input:: +//// [/user/username/projects/myproject/other.d.ts] file changed its modified time +//// [/user/username/projects/myproject/other.ts] +export function foo() {} + + +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Synchronizing program +[12:00:42 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/main.ts"] + options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'NodeJs'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'. +File '/user/username/projects/myproject/other.ts' exist - use it as a name resolution result. +======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.ts'. ======== +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/other.ts 250 undefined Source file +[12:00:48 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/main.ts"] +Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: SafeModules +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/other.ts +/user/username/projects/myproject/main.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/other.ts +/user/username/projects/myproject/main.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/other.ts (computed .d.ts) +/user/username/projects/myproject/main.ts (computed .d.ts) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/main.ts: + {} +/user/username/projects/myproject/other.d.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/other.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/main.js] file written with same contents +//// [/user/username/projects/myproject/other.js] +"use strict"; +exports.__esModule = true; +exports.foo = void 0; +function foo() { } +exports.foo = foo; + + diff --git a/tests/baselines/reference/tscWatch/watchApi/host-implements-hasInvalidatedResolution.js b/tests/baselines/reference/tscWatch/watchApi/host-implements-hasInvalidatedResolution.js new file mode 100644 index 0000000000000..71dac5e657e1b --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchApi/host-implements-hasInvalidatedResolution.js @@ -0,0 +1,273 @@ +Input:: +//// [/user/username/projects/myproject/tsconfig.json] +{"compilerOptions":{"traceResolution":true,"extendedDiagnostics":true},"files":["main.ts"]} + +//// [/user/username/projects/myproject/main.ts] +import { foo } from "./other"; + +//// [/user/username/projects/myproject/other.d.ts] +export function foo(): void; + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +/a/lib/tsc.js --w +Output:: +>> Screen clear +[12:00:23 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/main.ts"] + options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/main.ts 250 undefined Source file +======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'NodeJs'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'. +File '/user/username/projects/myproject/other.ts' does not exist. +File '/user/username/projects/myproject/other.tsx' does not exist. +File '/user/username/projects/myproject/other.d.ts' exist - use it as a name resolution result. +======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.d.ts'. ======== +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 undefined Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots +[12:00:26 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/main.ts"] +Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/other.d.ts +/user/username/projects/myproject/main.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/other.d.ts +/user/username/projects/myproject/main.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/other.d.ts (used version) +/user/username/projects/myproject/main.ts (used version) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/main.ts: + {} +/user/username/projects/myproject/other.d.ts: + {} +/a/lib/lib.d.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/main.js] +"use strict"; +exports.__esModule = true; + + + +Change:: write other with same contents + +Input:: +//// [/user/username/projects/myproject/other.d.ts] file changed its modified time + +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Synchronizing program +[12:00:29 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/main.ts"] + options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:30 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/main.ts"] +Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/other.d.ts +/user/username/projects/myproject/main.ts + +Semantic diagnostics in builder refreshed for:: + +No shapes updated in the builder:: + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/main.ts: + {} +/user/username/projects/myproject/other.d.ts: + {} +/a/lib/lib.d.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + + +Change:: change other file + +Input:: +//// [/user/username/projects/myproject/other.d.ts] +export function foo(): void;export function bar(): void; + + +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Synchronizing program +[12:00:33 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/main.ts"] + options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +[12:00:37 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/main.ts"] +Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/other.d.ts +/user/username/projects/myproject/main.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/other.d.ts +/user/username/projects/myproject/main.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/other.d.ts (used version) +/user/username/projects/myproject/main.ts (computed .d.ts) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/main.ts: + {} +/user/username/projects/myproject/other.d.ts: + {} +/a/lib/lib.d.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/main.js] file written with same contents + +Change:: write other with same contents but write ts file + +Input:: +//// [/user/username/projects/myproject/other.d.ts] file changed its modified time +//// [/user/username/projects/myproject/other.ts] +export function foo() {} + + +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file +Synchronizing program +[12:00:42 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/main.ts"] + options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ======== +Module resolution kind is not specified, using 'NodeJs'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'. +File '/user/username/projects/myproject/other.ts' exist - use it as a name resolution result. +======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.ts'. ======== +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/other.ts 250 undefined Source file +[12:00:48 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/main.ts"] +Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: SafeModules +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/other.ts +/user/username/projects/myproject/main.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/other.ts +/user/username/projects/myproject/main.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/other.ts (computed .d.ts) +/user/username/projects/myproject/main.ts (computed .d.ts) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/main.ts: + {} +/user/username/projects/myproject/other.d.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/other.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/main.js] file written with same contents +//// [/user/username/projects/myproject/other.js] +"use strict"; +exports.__esModule = true; +exports.foo = void 0; +function foo() { } +exports.foo = foo; + + diff --git a/tests/cases/compiler/declarationEmitMethodDeclaration.ts b/tests/cases/compiler/declarationEmitMethodDeclaration.ts new file mode 100644 index 0000000000000..44032d9543ee4 --- /dev/null +++ b/tests/cases/compiler/declarationEmitMethodDeclaration.ts @@ -0,0 +1,10 @@ +// @allowJs: true +// @checkJs: true +// @declaration: true +// @emitDeclarationOnly: true +// @filename: /a.js +export default { + methods: { + foo() { } + } +} diff --git a/tests/cases/conformance/node/nodeModulesExportsBlocksTypesVersions.ts b/tests/cases/conformance/node/nodeModulesExportsBlocksTypesVersions.ts new file mode 100644 index 0000000000000..2eedbe682cdd5 --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesExportsBlocksTypesVersions.ts @@ -0,0 +1,65 @@ +// @module: node16,nodenext +// @traceResolution: true +// @noImplicitAny: true + +// @Filename: /node_modules/exports-and-types-versions/package.json +{ + "name": "exports-and-types-versions", + "version": "1.0.0", + "exports": { + "./foo": "./dist/foo.js", + "./yep": { + "types": "./types/foo.d.ts", + "default": "./dist/foo.js" + }, + "./versioned-yep": { + "types@>=4": "./types/foo.d.ts" + }, + "./versioned-nah": { + "types@<4": "./types/foo.d.ts" + } + }, + "typesVersions": { + "*": { + "foo": ["./types/foo.d.ts"], + "nope": ["./types/foo.d.ts"], + "versioned-nah": ["./types/foo.d.ts"] + } + } +} + +// @Filename: /node_modules/exports-and-types-versions/dist/foo.js +module.exports = {}; + +// @Filename: /node_modules/exports-and-types-versions/types/foo.d.ts +export {}; + +// @Filename: /node_modules/just-types-versions/package.json +{ + "name": "just-types-versions", + "version": "1.0.0", + "typesVersions": { + "*": { + "foo": ["./types/foo.d.ts"] + } + } +} + +// @Filename: /node_modules/just-types-versions/types/foo.d.ts +export {}; + +// @Filename: /main.cts +import {} from "exports-and-types-versions/foo"; +import {} from "exports-and-types-versions/nope"; +import {} from "exports-and-types-versions/yep"; +import {} from "exports-and-types-versions/versioned-yep"; +import {} from "exports-and-types-versions/versioned-nah"; +import {} from "just-types-versions/foo"; + +// @Filename: /main.mts +import {} from "exports-and-types-versions/foo"; +import {} from "exports-and-types-versions/nope"; +import {} from "exports-and-types-versions/yep"; +import {} from "exports-and-types-versions/versioned-yep"; +import {} from "exports-and-types-versions/versioned-nah"; +import {} from "just-types-versions/foo"; diff --git a/tests/cases/fourslash/codeFixAddMissingEnumMember13.ts b/tests/cases/fourslash/codeFixAddMissingEnumMember13.ts new file mode 100644 index 0000000000000..b3e47efaff526 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingEnumMember13.ts @@ -0,0 +1,7 @@ +/// + +////enum E { A, B } +////declare var a: E; +////a.C; + +verify.not.codeFixAvailable("fixMissingMember"); diff --git a/tests/cases/fourslash/referencesIsAvailableThroughGlobalNoCrash.ts b/tests/cases/fourslash/referencesIsAvailableThroughGlobalNoCrash.ts new file mode 100644 index 0000000000000..f741763e1b413 --- /dev/null +++ b/tests/cases/fourslash/referencesIsAvailableThroughGlobalNoCrash.ts @@ -0,0 +1,20 @@ +/// + +// @Filename: /packages/playwright-core/bundles/utils/node_modules/@types/debug/index.d.ts +//// declare var debug: debug.Debug & { debug: debug.Debug; default: debug.Debug }; +//// export = debug; +//// export as namespace debug; +//// declare namespace debug { +//// interface Debug { +//// coerce: (val: any) => any; +//// } +//// } + +// @Filename: /packages/playwright-core/bundles/utils/node_modules/@types/debug/package.json +//// { "types": "index.d.ts" } + +// @Filename: /packages/playwright-core/src/index.ts +//// export const debug: typeof import('../bundles/utils/node_modules//*1*/@types/debug') = require('./utilsBundleImpl').debug; + + +verify.baselineFindAllReferences('1');