mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Stop checking existing resolution now that we have concept of package ID (#58528)
This commit is contained in:
parent
d90e8e7eca
commit
ef01ea1ac6
@ -4200,10 +4200,6 @@
|
||||
"category": "Error",
|
||||
"code": 4085
|
||||
},
|
||||
"Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.": {
|
||||
"category": "Error",
|
||||
"code": 4090
|
||||
},
|
||||
"Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 4091
|
||||
|
||||
@ -1589,7 +1589,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
const cachedBindAndCheckDiagnosticsForFile: DiagnosticCache<Diagnostic> = {};
|
||||
const cachedDeclarationDiagnosticsForFile: DiagnosticCache<DiagnosticWithLocation> = {};
|
||||
|
||||
let resolvedTypeReferenceDirectives = createModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>();
|
||||
let fileProcessingDiagnostics: FilePreprocessingDiagnostics[] | undefined;
|
||||
let automaticTypeDirectiveNames: string[] | undefined;
|
||||
let automaticTypeDirectiveResolutions: ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>;
|
||||
@ -1929,7 +1928,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
resolvedLibProcessing = undefined;
|
||||
resolvedModulesProcessing = undefined;
|
||||
resolvedTypeReferenceDirectiveNamesProcessing = undefined;
|
||||
resolvedTypeReferenceDirectives = undefined!;
|
||||
|
||||
const program: Program = {
|
||||
getRootFileNames: () => rootNames,
|
||||
@ -4022,55 +4020,18 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
reason: FileIncludeReason,
|
||||
): void {
|
||||
addResolutionDiagnostics(resolution);
|
||||
// If we already found this library as a primary reference - nothing to do
|
||||
const previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)?.resolvedTypeReferenceDirective;
|
||||
if (previousResolution && previousResolution.primary) {
|
||||
return;
|
||||
}
|
||||
let saveResolution = true;
|
||||
const { resolvedTypeReferenceDirective } = resolution;
|
||||
if (resolvedTypeReferenceDirective) {
|
||||
if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth++;
|
||||
|
||||
if (resolvedTypeReferenceDirective.primary) {
|
||||
// resolved from the primary path
|
||||
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName!, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, reason); // TODO: GH#18217
|
||||
}
|
||||
else {
|
||||
// If we already resolved to this file, it must have been a secondary reference. Check file contents
|
||||
// for sameness and possibly issue an error
|
||||
if (previousResolution) {
|
||||
// Don't bother reading the file again if it's the same file.
|
||||
if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
|
||||
const otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName!);
|
||||
const existingFile = getSourceFile(previousResolution.resolvedFileName!)!;
|
||||
if (otherFileText !== existingFile.text) {
|
||||
addFilePreprocessingFileExplainingDiagnostic(
|
||||
existingFile,
|
||||
reason,
|
||||
Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict,
|
||||
[typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName!, previousResolution.resolvedFileName!],
|
||||
);
|
||||
}
|
||||
}
|
||||
// don't overwrite previous resolution result
|
||||
saveResolution = false;
|
||||
}
|
||||
else {
|
||||
// First resolution of this library
|
||||
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName!, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, reason);
|
||||
}
|
||||
}
|
||||
// resolved from the primary path
|
||||
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName!, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, reason); // TODO: GH#18217
|
||||
|
||||
if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--;
|
||||
}
|
||||
else {
|
||||
addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
|
||||
}
|
||||
|
||||
if (saveResolution) {
|
||||
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
|
||||
}
|
||||
}
|
||||
|
||||
function pathForLibFile(libFileName: string): string {
|
||||
|
||||
@ -12,10 +12,14 @@ declare var foo: any;
|
||||
|
||||
=== /node_modules/foo/node_modules/alpha/index.d.ts ===
|
||||
declare var alpha: any;
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11))
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 11))
|
||||
|
||||
=== /node_modules/bar/index.d.ts ===
|
||||
/// <reference types="alpha" />
|
||||
declare var bar: any;
|
||||
>bar : Symbol(bar, Decl(index.d.ts, 1, 11))
|
||||
|
||||
=== /node_modules/bar/node_modules/alpha/index.d.ts ===
|
||||
declare var alpha: any;
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 11))
|
||||
|
||||
|
||||
@ -54,6 +54,11 @@
|
||||
"File '/node_modules/bar/node_modules/alpha/index.d.ts' exists - use it as a name resolution result.",
|
||||
"Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'.",
|
||||
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========",
|
||||
"File '/node_modules/bar/node_modules/alpha/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/node_modules/bar/node_modules/package.json' does not exist.",
|
||||
"File '/node_modules/bar/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/node_modules/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"======== Resolving module '@typescript/lib-es5' from '/.src/test/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========",
|
||||
|
||||
@ -19,3 +19,7 @@ declare var alpha: any;
|
||||
declare var bar: any;
|
||||
>bar : any
|
||||
|
||||
=== /node_modules/bar/node_modules/alpha/index.d.ts ===
|
||||
declare var alpha: any;
|
||||
>alpha : any
|
||||
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
/node_modules/bar/index.d.ts(1,23): error TS4090: Conflicting definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Consider installing a specific version of this library to resolve the conflict.
|
||||
The file is in the program because:
|
||||
Type library referenced via 'alpha' from file '/node_modules/foo/index.d.ts'
|
||||
Type library referenced via 'alpha' from file '/node_modules/bar/index.d.ts'
|
||||
/node_modules/bar/node_modules/alpha/index.d.ts(1,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'alpha' must be of type 'any', but here has type '{}'.
|
||||
|
||||
|
||||
==== /src/root.ts (0 errors) ====
|
||||
@ -15,16 +12,13 @@
|
||||
==== /node_modules/foo/node_modules/alpha/index.d.ts (0 errors) ====
|
||||
declare var alpha: any;
|
||||
|
||||
==== /node_modules/bar/index.d.ts (1 errors) ====
|
||||
==== /node_modules/bar/index.d.ts (0 errors) ====
|
||||
/// <reference types="alpha" />
|
||||
~~~~~
|
||||
!!! error TS4090: Conflicting definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Consider installing a specific version of this library to resolve the conflict.
|
||||
!!! error TS4090: The file is in the program because:
|
||||
!!! error TS4090: Type library referenced via 'alpha' from file '/node_modules/foo/index.d.ts'
|
||||
!!! error TS4090: Type library referenced via 'alpha' from file '/node_modules/bar/index.d.ts'
|
||||
!!! related TS1404 /node_modules/foo/index.d.ts:1:23: File is included via type library reference here.
|
||||
declare var bar: any;
|
||||
|
||||
==== /node_modules/bar/node_modules/alpha/index.d.ts (0 errors) ====
|
||||
==== /node_modules/bar/node_modules/alpha/index.d.ts (1 errors) ====
|
||||
declare var alpha: {};
|
||||
~~~~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'alpha' must be of type 'any', but here has type '{}'.
|
||||
!!! related TS6203 /node_modules/foo/node_modules/alpha/index.d.ts:1:13: 'alpha' was also declared here.
|
||||
|
||||
@ -12,10 +12,14 @@ declare var foo: any;
|
||||
|
||||
=== /node_modules/foo/node_modules/alpha/index.d.ts ===
|
||||
declare var alpha: any;
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11))
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 11))
|
||||
|
||||
=== /node_modules/bar/index.d.ts ===
|
||||
/// <reference types="alpha" />
|
||||
declare var bar: any;
|
||||
>bar : Symbol(bar, Decl(index.d.ts, 1, 11))
|
||||
|
||||
=== /node_modules/bar/node_modules/alpha/index.d.ts ===
|
||||
declare var alpha: {};
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 11))
|
||||
|
||||
|
||||
@ -54,6 +54,11 @@
|
||||
"File '/node_modules/bar/node_modules/alpha/index.d.ts' exists - use it as a name resolution result.",
|
||||
"Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'.",
|
||||
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========",
|
||||
"File '/node_modules/bar/node_modules/alpha/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/node_modules/bar/node_modules/package.json' does not exist.",
|
||||
"File '/node_modules/bar/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/node_modules/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"======== Resolving module '@typescript/lib-es5' from '/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========",
|
||||
|
||||
@ -22,3 +22,8 @@ declare var bar: any;
|
||||
>bar : any
|
||||
> : ^^^
|
||||
|
||||
=== /node_modules/bar/node_modules/alpha/index.d.ts ===
|
||||
declare var alpha: {};
|
||||
>alpha : any
|
||||
> : ^^^
|
||||
|
||||
|
||||
@ -166,6 +166,7 @@ Info seq [hh:mm:ss:mss] Files (4)
|
||||
Matched by default include pattern '**/*'
|
||||
../lib/@types/UpperCasePackage/index.d.ts
|
||||
Entry point for implicit type library 'UpperCasePackage'
|
||||
Type library referenced via 'UpperCasePackage' from file '../lib/@app/lib/index.d.ts'
|
||||
../lib/@app/lib/index.d.ts
|
||||
Entry point for implicit type library 'lib'
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user