Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitef01ea1

Browse files
authored
Stop checking existing resolution now that we have concept of package ID (microsoft#58528)
1 parentd90e8e7 commitef01ea1

10 files changed

+38
-59
lines changed

‎src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4200,10 +4200,6 @@
42004200
"category":"Error",
42014201
"code":4085
42024202
},
4203-
"Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.": {
4204-
"category":"Error",
4205-
"code":4090
4206-
},
42074203
"Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'.": {
42084204
"category":"Error",
42094205
"code":4091

‎src/compiler/program.ts

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
15891589
constcachedBindAndCheckDiagnosticsForFile:DiagnosticCache<Diagnostic>={};
15901590
constcachedDeclarationDiagnosticsForFile:DiagnosticCache<DiagnosticWithLocation>={};
15911591

1592-
letresolvedTypeReferenceDirectives=createModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>();
15931592
letfileProcessingDiagnostics:FilePreprocessingDiagnostics[]|undefined;
15941593
letautomaticTypeDirectiveNames:string[]|undefined;
15951594
letautomaticTypeDirectiveResolutions:ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>;
@@ -1929,7 +1928,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
19291928
resolvedLibProcessing=undefined;
19301929
resolvedModulesProcessing=undefined;
19311930
resolvedTypeReferenceDirectiveNamesProcessing=undefined;
1932-
resolvedTypeReferenceDirectives=undefined!;
19331931

19341932
constprogram:Program={
19351933
getRootFileNames:()=>rootNames,
@@ -4022,55 +4020,18 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
40224020
reason:FileIncludeReason,
40234021
):void{
40244022
addResolutionDiagnostics(resolution);
4025-
// If we already found this library as a primary reference - nothing to do
4026-
constpreviousResolution=resolvedTypeReferenceDirectives.get(typeReferenceDirective,mode)?.resolvedTypeReferenceDirective;
4027-
if(previousResolution&&previousResolution.primary){
4028-
return;
4029-
}
4030-
letsaveResolution=true;
40314023
const{ resolvedTypeReferenceDirective}=resolution;
40324024
if(resolvedTypeReferenceDirective){
40334025
if(resolvedTypeReferenceDirective.isExternalLibraryImport)currentNodeModulesDepth++;
40344026

4035-
if(resolvedTypeReferenceDirective.primary){
4036-
// resolved from the primary path
4037-
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName!,/*isDefaultLib*/false,/*ignoreNoDefaultLib*/false,resolvedTypeReferenceDirective.packageId,reason);// TODO: GH#18217
4038-
}
4039-
else{
4040-
// If we already resolved to this file, it must have been a secondary reference. Check file contents
4041-
// for sameness and possibly issue an error
4042-
if(previousResolution){
4043-
// Don't bother reading the file again if it's the same file.
4044-
if(resolvedTypeReferenceDirective.resolvedFileName!==previousResolution.resolvedFileName){
4045-
constotherFileText=host.readFile(resolvedTypeReferenceDirective.resolvedFileName!);
4046-
constexistingFile=getSourceFile(previousResolution.resolvedFileName!)!;
4047-
if(otherFileText!==existingFile.text){
4048-
addFilePreprocessingFileExplainingDiagnostic(
4049-
existingFile,
4050-
reason,
4051-
Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict,
4052-
[typeReferenceDirective,resolvedTypeReferenceDirective.resolvedFileName!,previousResolution.resolvedFileName!],
4053-
);
4054-
}
4055-
}
4056-
// don't overwrite previous resolution result
4057-
saveResolution=false;
4058-
}
4059-
else{
4060-
// First resolution of this library
4061-
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName!,/*isDefaultLib*/false,/*ignoreNoDefaultLib*/false,resolvedTypeReferenceDirective.packageId,reason);
4062-
}
4063-
}
4027+
// resolved from the primary path
4028+
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName!,/*isDefaultLib*/false,/*ignoreNoDefaultLib*/false,resolvedTypeReferenceDirective.packageId,reason);// TODO: GH#18217
40644029

40654030
if(resolvedTypeReferenceDirective.isExternalLibraryImport)currentNodeModulesDepth--;
40664031
}
40674032
else{
40684033
addFilePreprocessingFileExplainingDiagnostic(/*file*/undefined,reason,Diagnostics.Cannot_find_type_definition_file_for_0,[typeReferenceDirective]);
40694034
}
4070-
4071-
if(saveResolution){
4072-
resolvedTypeReferenceDirectives.set(typeReferenceDirective,mode,resolution);
4073-
}
40744035
}
40754036

40764037
functionpathForLibFile(libFileName:string):string{

‎tests/baselines/reference/library-reference-4.symbols

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ declare var foo: any;
1212

1313
=== /node_modules/foo/node_modules/alpha/index.d.ts ===
1414
declare var alpha: any;
15-
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11))
15+
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 11))
1616

1717
=== /node_modules/bar/index.d.ts ===
1818
/// <reference types="alpha" />
1919
declare var bar: any;
2020
>bar : Symbol(bar, Decl(index.d.ts, 1, 11))
2121

22+
=== /node_modules/bar/node_modules/alpha/index.d.ts ===
23+
declare var alpha: any;
24+
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 11))
25+

‎tests/baselines/reference/library-reference-4.trace.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
"File '/node_modules/bar/node_modules/alpha/index.d.ts' exists - use it as a name resolution result.",
5555
"Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'.",
5656
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========",
57+
"File '/node_modules/bar/node_modules/alpha/package.json' does not exist according to earlier cached lookups.",
58+
"File '/node_modules/bar/node_modules/package.json' does not exist.",
59+
"File '/node_modules/bar/package.json' does not exist according to earlier cached lookups.",
60+
"File '/node_modules/package.json' does not exist according to earlier cached lookups.",
61+
"File '/package.json' does not exist according to earlier cached lookups.",
5762
"File '/.ts/package.json' does not exist.",
5863
"File '/package.json' does not exist according to earlier cached lookups.",
5964
"======== Resolving module '@typescript/lib-es5' from '/.src/test/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========",

‎tests/baselines/reference/library-reference-4.types

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ declare var alpha: any;
1919
declare var bar: any;
2020
>bar : any
2121

22+
=== /node_modules/bar/node_modules/alpha/index.d.ts ===
23+
declare var alpha: any;
24+
>alpha : any
25+
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/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.
2-
The file is in the program because:
3-
Type library referenced via 'alpha' from file '/node_modules/foo/index.d.ts'
4-
Type library referenced via 'alpha' from file '/node_modules/bar/index.d.ts'
1+
/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 '{}'.
52

63

74
==== /src/root.ts (0 errors) ====
@@ -15,16 +12,13 @@
1512
==== /node_modules/foo/node_modules/alpha/index.d.ts (0 errors) ====
1613
declare var alpha: any;
1714

18-
==== /node_modules/bar/index.d.ts (1 errors) ====
15+
==== /node_modules/bar/index.d.ts (0 errors) ====
1916
/// <reference types="alpha" />
20-
~~~~~
21-
!!! 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.
22-
!!! error TS4090: The file is in the program because:
23-
!!! error TS4090: Type library referenced via 'alpha' from file '/node_modules/foo/index.d.ts'
24-
!!! error TS4090: Type library referenced via 'alpha' from file '/node_modules/bar/index.d.ts'
25-
!!! related TS1404 /node_modules/foo/index.d.ts:1:23: File is included via type library reference here.
2617
declare var bar: any;
2718

28-
==== /node_modules/bar/node_modules/alpha/index.d.ts (0 errors) ====
19+
==== /node_modules/bar/node_modules/alpha/index.d.ts (1 errors) ====
2920
declare var alpha: {};
21+
~~~~~
22+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'alpha' must be of type 'any', but here has type '{}'.
23+
!!! related TS6203 /node_modules/foo/node_modules/alpha/index.d.ts:1:13: 'alpha' was also declared here.
3024

‎tests/baselines/reference/library-reference-5.symbols

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ declare var foo: any;
1212

1313
=== /node_modules/foo/node_modules/alpha/index.d.ts ===
1414
declare var alpha: any;
15-
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11))
15+
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 11))
1616

1717
=== /node_modules/bar/index.d.ts ===
1818
/// <reference types="alpha" />
1919
declare var bar: any;
2020
>bar : Symbol(bar, Decl(index.d.ts, 1, 11))
2121

22+
=== /node_modules/bar/node_modules/alpha/index.d.ts ===
23+
declare var alpha: {};
24+
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 11))
25+

‎tests/baselines/reference/library-reference-5.trace.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
"File '/node_modules/bar/node_modules/alpha/index.d.ts' exists - use it as a name resolution result.",
5555
"Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'.",
5656
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========",
57+
"File '/node_modules/bar/node_modules/alpha/package.json' does not exist according to earlier cached lookups.",
58+
"File '/node_modules/bar/node_modules/package.json' does not exist.",
59+
"File '/node_modules/bar/package.json' does not exist according to earlier cached lookups.",
60+
"File '/node_modules/package.json' does not exist according to earlier cached lookups.",
61+
"File '/package.json' does not exist according to earlier cached lookups.",
5762
"File '/.ts/package.json' does not exist.",
5863
"File '/package.json' does not exist according to earlier cached lookups.",
5964
"======== Resolving module '@typescript/lib-es5' from '/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========",

‎tests/baselines/reference/library-reference-5.types

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ declare var bar: any;
2222
>bar : any
2323
> : ^^^
2424

25+
=== /node_modules/bar/node_modules/alpha/index.d.ts ===
26+
declare var alpha: {};
27+
>alpha : any
28+
> : ^^^
29+

‎tests/baselines/reference/tsserver/typeReferenceDirectives/when-typeReferenceDirective-contains-UpperCasePackage.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ Info seq [hh:mm:ss:mss] Files (4)
166166
Matchedbydefaultincludepattern'**/*'
167167
../lib/@types/UpperCasePackage/index.d.ts
168168
Entrypointforimplicittypelibrary'UpperCasePackage'
169+
Typelibraryreferencedvia'UpperCasePackage'fromfile'../lib/@app/lib/index.d.ts'
169170
../lib/@app/lib/index.d.ts
170171
Entrypointforimplicittypelibrary'lib'
171172

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp