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

Commite51cbc8

Browse files
authored
Do not lowercase typeReference directive name (microsoft#58525)
1 parent524456f commite51cbc8

File tree

9 files changed

+188
-13
lines changed

9 files changed

+188
-13
lines changed

‎src/compiler/program.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,8 +1058,7 @@ export function createModuleResolutionLoader(
10581058
}
10591059

10601060
functiongetTypeReferenceResolutionName<TextendsFileReference|string>(entry:T){
1061-
// We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
1062-
return!isString(entry) ?toFileNameLowerCase(entry.fileName) :entry;
1061+
return!isString(entry) ?entry.fileName :entry;
10631062
}
10641063

10651064
consttypeReferenceResolutionNameAndModeGetter:ResolutionNameAndModeGetter<FileReference|string,SourceFile|undefined>={
@@ -2088,7 +2087,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
20882087
}
20892088

20902089
functiongetResolvedTypeReferenceDirectiveFromTypeReferenceDirective(typeRef:FileReference,sourceFile:SourceFile){
2091-
returngetResolvedTypeReferenceDirective(sourceFile,toFileNameLowerCase(typeRef.fileName),typeRef.resolutionMode||sourceFile.impliedNodeFormat);
2090+
returngetResolvedTypeReferenceDirective(sourceFile,typeRef.fileName,typeRef.resolutionMode||sourceFile.impliedNodeFormat);
20922091
}
20932092

20942093
functionforEachResolvedModule(
@@ -3994,7 +3993,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
39943993
constref=file.typeReferenceDirectives[index];
39953994
constresolvedTypeReferenceDirective=resolutions[index];
39963995
// store resolved type directive on the file
3997-
constfileName=toFileNameLowerCase(ref.fileName);
3996+
constfileName=ref.fileName;
39983997
resolutionsInFile.set(fileName,getModeForFileReference(ref,file.impliedNodeFormat),resolvedTypeReferenceDirective);
39993998
constmode=ref.resolutionMode||getDefaultResolutionModeForFile(file);
40003999
processTypeReferenceDirective(fileName,mode,resolvedTypeReferenceDirective,{kind:FileIncludeKind.TypeReferenceDirective,file:file.path, index});

‎src/testRunner/unittests/tsc/forceConsistentCasingInFileNames.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,19 @@ describe("unittests:: tsc:: forceConsistentCasingInFileNames::", () => {
2626
commandLineArgs:["-p","/home/src/projects/project/tsconfig.json","--explainFiles"],
2727
fs:()=>loadProjectFromFiles(getFsContentsForMultipleErrorsForceConsistentCasingInFileNames()),
2828
});
29+
30+
verifyTsc({
31+
scenario:"forceConsistentCasingInFileNames",
32+
subScenario:"with type ref from file",
33+
commandLineArgs:["-p","/src/project/src","--explainFiles","--traceResolution"],
34+
fs:()=>
35+
loadProjectFromFiles({
36+
"/src/project/src/fileOne.d.ts":`declare class c { }`,
37+
"/src/project/src/file2.d.ts":dedent`
38+
/// <reference types="./fileOne.d.ts"/>
39+
declare const y: c;
40+
`,
41+
"/src/project/src/tsconfig.json":"{ }",
42+
}),
43+
});
2944
});

‎src/testRunner/unittests/tsserver/typeReferenceDirectives.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
libFile,
1111
}from"../helpers/virtualFileSystemWithWatch.js";
1212

13-
describe("unittests:: tsserver:: typeReferenceDirectives",()=>{
13+
describe("unittests:: tsserver:: typeReferenceDirectives::",()=>{
1414
it("when typeReferenceDirective contains UpperCasePackage",()=>{
1515
constlibProjectLocation=`/user/username/projects/myproject/lib`;
1616
consttypeLib:File={
@@ -52,6 +52,7 @@ declare class TestLib {
5252
compilerOptions:{
5353
module:"amd",
5454
typeRoots:["../lib/@types","../lib/@app"],
55+
traceResolution:true,
5556
},
5657
}),
5758
};
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
currentDirectory::/useCaseSensitiveFileNames:false
2+
Input::
3+
//// [/lib/lib.d.ts]
4+
/// <reference no-default-lib="true"/>
5+
interfaceBoolean{}
6+
interfaceFunction{}
7+
interfaceCallableFunction{}
8+
interfaceNewableFunction{}
9+
interfaceIArguments{}
10+
interfaceNumber{ toExponential:any;}
11+
interfaceObject{}
12+
interfaceRegExp{}
13+
interfaceString{ charAt:any;}
14+
interfaceArray<T>{length:number;[n:number]:T;}
15+
interfaceReadonlyArray<T>{}
16+
declareconst console:{log(msg:any):void;};
17+
18+
//// [/src/project/src/file2.d.ts]
19+
/// <reference types="./fileOne.d.ts"/>
20+
declareconst y:c;
21+
22+
23+
//// [/src/project/src/fileOne.d.ts]
24+
declareclassc{}
25+
26+
//// [/src/project/src/tsconfig.json]
27+
{}
28+
29+
30+
31+
Output::
32+
/lib/tsc-p/src/project/src--explainFiles--traceResolution
33+
File'/src/project/src/package.json'doesnotexist.
34+
File'/src/project/package.json'doesnotexist.
35+
File'/src/package.json'doesnotexist.
36+
File'/package.json'doesnotexist.
37+
========Resolvingtypereferencedirective'./fileOne.d.ts',containingfile'/src/project/src/file2.d.ts',rootdirectory'/src/project/src/node_modules/@types,/src/project/node_modules/@types,/src/node_modules/@types,/node_modules/@types'.========
38+
Resolvingwithprimarysearchpath'/src/project/src/node_modules/@types, /src/project/node_modules/@types, /src/node_modules/@types, /node_modules/@types'.
39+
Directory'/src/project/src/node_modules/@types'doesnotexist,skippingalllookupsinit.
40+
Directory'/src/project/node_modules/@types'doesnotexist,skippingalllookupsinit.
41+
Directory'/src/node_modules/@types'doesnotexist,skippingalllookupsinit.
42+
Directory'/node_modules/@types'doesnotexist,skippingalllookupsinit.
43+
Lookingupin'node_modules'folder,initiallocation'/src/project/src'.
44+
Loadingmoduleasfile/folder,candidatemodulelocation'/src/project/src/fileOne.d.ts',targetfiletypes:Declaration.
45+
Filename'/src/project/src/fileOne.d.ts'hasa'.d.ts'extension-strippingit.
46+
File'/src/project/src/fileOne.d.ts'exists-useitasanameresolutionresult.
47+
Resolvingrealpathfor'/src/project/src/fileOne.d.ts',result'/src/project/src/fileOne.d.ts'.
48+
========Typereferencedirective'./fileOne.d.ts'wassuccessfullyresolvedto'/src/project/src/fileOne.d.ts',primary:false.========
49+
File'/src/project/src/package.json'doesnotexistaccordingtoearliercachedlookups.
50+
File'/src/project/package.json'doesnotexistaccordingtoearliercachedlookups.
51+
File'/src/package.json'doesnotexistaccordingtoearliercachedlookups.
52+
File'/package.json'doesnotexistaccordingtoearliercachedlookups.
53+
File'/lib/package.json'doesnotexist.
54+
File'/package.json'doesnotexistaccordingtoearliercachedlookups.
55+
lib/lib.d.ts
56+
Defaultlibraryfortarget'es5'
57+
src/project/src/fileOne.d.ts
58+
Typelibraryreferencedvia'./fileOne.d.ts'fromfile 'src/project/src/file2.d.ts'
59+
Matchedbydefaultincludepattern'**/*'
60+
src/project/src/file2.d.ts
61+
Matchedbydefaultincludepattern'**/*'
62+
exitCode::ExitStatus.Success
63+
64+

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

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class TestClass1 {
3737
"typeRoots":[
3838
"../lib/@types",
3939
"../lib/@app"
40-
]
40+
],
41+
"traceResolution":true
4142
}
4243
}
4344

@@ -87,16 +88,64 @@ Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/test/tsconfig
8788
"/user/username/projects/myproject/lib/@types",
8889
"/user/username/projects/myproject/lib/@app"
8990
],
91+
"traceResolution":true,
9092
"configFilePath":"/user/username/projects/myproject/test/tsconfig.json"
9193
}
9294
}
9395
Infoseq[hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo:/user/username/projects/myproject/test1undefined Config:/user/username/projects/myproject/test/tsconfig.json WatchType:Wildcarddirectory
9496
Infoseq[hh:mm:ss:mss]Elapsed::*ms DirectoryWatcher:: Added:: WatchInfo:/user/username/projects/myproject/test1undefined Config:/user/username/projects/myproject/test/tsconfig.json WatchType:Wildcarddirectory
9597
Infoseq[hh:mm:ss:mss]Starting updateGraphWorker: Project:/user/username/projects/myproject/test/tsconfig.json
98+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/test/package.json'doesnotexist.
99+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/package.json'doesnotexist.
100+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/package.json'doesnotexist.
101+
Infoseq[hh:mm:ss:mss]File'/user/username/package.json'doesnotexist.
102+
Infoseq[hh:mm:ss:mss]File'/user/package.json'doesnotexist.
103+
Infoseq[hh:mm:ss:mss]File'/package.json'doesnotexist.
104+
Infoseq[hh:mm:ss:mss]========Resolvingtypereferencedirective'UpperCasePackage',containingfile'/user/username/projects/myproject/test/__inferred type names__.ts',rootdirectory'/user/username/projects/myproject/lib/@types,/user/username/projects/myproject/lib/@app'.========
105+
Infoseq[hh:mm:ss:mss]Resolvingwithprimarysearchpath'/user/username/projects/myproject/lib/@types, /user/username/projects/myproject/lib/@app'.
106+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@types/UpperCasePackage.d.ts'doesnotexist.
107+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@types/UpperCasePackage/package.json'doesnotexist.
108+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts'exists-useitasanameresolutionresult.
109+
Infoseq[hh:mm:ss:mss]Resolvingrealpathfor'/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts',result'/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts'.
110+
Infoseq[hh:mm:ss:mss]========Typereferencedirective'UpperCasePackage'wassuccessfullyresolvedto'/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts',primary:true.========
96111
Infoseq[hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo:/user/username/projects/myproject/lib1undefined Project:/user/username/projects/myproject/test/tsconfig.json WatchType:FailedLookupLocations
97112
Infoseq[hh:mm:ss:mss]Elapsed::*ms DirectoryWatcher:: Added:: WatchInfo:/user/username/projects/myproject/lib1undefined Project:/user/username/projects/myproject/test/tsconfig.json WatchType:FailedLookupLocations
113+
Infoseq[hh:mm:ss:mss]========Resolvingtypereferencedirective'lib',containingfile'/user/username/projects/myproject/test/__inferred type names__.ts',rootdirectory'/user/username/projects/myproject/lib/@types,/user/username/projects/myproject/lib/@app'.========
114+
Infoseq[hh:mm:ss:mss]Resolvingwithprimarysearchpath'/user/username/projects/myproject/lib/@types, /user/username/projects/myproject/lib/@app'.
115+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@types/lib.d.ts'doesnotexist.
116+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@app/lib.d.ts'doesnotexist.
117+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@app/lib/package.json'doesnotexist.
118+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@app/lib/index.d.ts'exists-useitasanameresolutionresult.
119+
Infoseq[hh:mm:ss:mss]Resolvingrealpathfor'/user/username/projects/myproject/lib/@app/lib/index.d.ts',result'/user/username/projects/myproject/lib/@app/lib/index.d.ts'.
120+
Infoseq[hh:mm:ss:mss]========Typereferencedirective'lib'wassuccessfullyresolvedto'/user/username/projects/myproject/lib/@app/lib/index.d.ts',primary:true.========
121+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@types/UpperCasePackage/package.json'doesnotexistaccordingtoearliercachedlookups.
122+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@types/package.json'doesnotexist.
123+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/package.json'doesnotexist.
124+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/package.json'doesnotexistaccordingtoearliercachedlookups.
125+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/package.json'doesnotexistaccordingtoearliercachedlookups.
126+
Infoseq[hh:mm:ss:mss]File'/user/username/package.json'doesnotexistaccordingtoearliercachedlookups.
127+
Infoseq[hh:mm:ss:mss]File'/user/package.json'doesnotexistaccordingtoearliercachedlookups.
128+
Infoseq[hh:mm:ss:mss]File'/package.json'doesnotexistaccordingtoearliercachedlookups.
98129
Infoseq[hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo:/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts500undefinedWatchType:ClosedScriptinfo
130+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@app/lib/package.json'doesnotexistaccordingtoearliercachedlookups.
131+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@app/package.json'doesnotexist.
132+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/package.json'doesnotexistaccordingtoearliercachedlookups.
133+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/package.json'doesnotexistaccordingtoearliercachedlookups.
134+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/package.json'doesnotexistaccordingtoearliercachedlookups.
135+
Infoseq[hh:mm:ss:mss]File'/user/username/package.json'doesnotexistaccordingtoearliercachedlookups.
136+
Infoseq[hh:mm:ss:mss]File'/user/package.json'doesnotexistaccordingtoearliercachedlookups.
137+
Infoseq[hh:mm:ss:mss]File'/package.json'doesnotexistaccordingtoearliercachedlookups.
99138
Infoseq[hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo:/user/username/projects/myproject/lib/@app/lib/index.d.ts500undefinedWatchType:ClosedScriptinfo
139+
Infoseq[hh:mm:ss:mss]========Resolvingtypereferencedirective'UpperCasePackage',containingfile'/user/username/projects/myproject/lib/@app/lib/index.d.ts',rootdirectory'/user/username/projects/myproject/lib/@types,/user/username/projects/myproject/lib/@app'.========
140+
Infoseq[hh:mm:ss:mss]Resolvingwithprimarysearchpath'/user/username/projects/myproject/lib/@types, /user/username/projects/myproject/lib/@app'.
141+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@types/UpperCasePackage.d.ts'doesnotexist.
142+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@types/UpperCasePackage/package.json'doesnotexistaccordingtoearliercachedlookups.
143+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts'exists-useitasanameresolutionresult.
144+
Infoseq[hh:mm:ss:mss]Resolvingrealpathfor'/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts',result'/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts'.
145+
Infoseq[hh:mm:ss:mss]========Typereferencedirective'UpperCasePackage'wassuccessfullyresolvedto'/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts',primary:true.========
146+
Infoseq[hh:mm:ss:mss]File'/a/lib/package.json'doesnotexist.
147+
Infoseq[hh:mm:ss:mss]File'/a/package.json'doesnotexist.
148+
Infoseq[hh:mm:ss:mss]File'/package.json'doesnotexistaccordingtoearliercachedlookups.
100149
Infoseq[hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo:/a/lib/lib.d.ts500undefined WatchType:ClosedScriptinfo
101150
Infoseq[hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo:/user/username/projects/myproject/lib/@types1undefined Project:/user/username/projects/myproject/test/tsconfig.json WatchType:Typeroots
102151
Infoseq[hh:mm:ss:mss]Elapsed::*ms DirectoryWatcher:: Added:: WatchInfo:/user/username/projects/myproject/lib/@types1undefined Project:/user/username/projects/myproject/test/tsconfig.json WatchType:Typeroots
@@ -117,7 +166,6 @@ Info seq [hh:mm:ss:mss] Files (4)
117166
Matchedbydefaultincludepattern'**/*'
118167
../lib/@types/UpperCasePackage/index.d.ts
119168
Entrypointforimplicittypelibrary'UpperCasePackage'
120-
Typelibraryreferencedvia'UpperCasePackage'fromfile'../lib/@app/lib/index.d.ts'
121169
../lib/@app/lib/index.d.ts
122170
Entrypointforimplicittypelibrary'lib'
123171

@@ -159,7 +207,8 @@ Info seq [hh:mm:ss:mss] event:
159207
"typeRoots":[
160208
"",
161209
""
162-
]
210+
],
211+
"traceResolution":true
163212
},
164213
"typeAcquisition":{
165214
"enable":false,
@@ -292,6 +341,32 @@ ScriptInfos::
292341

293342
Infoseq[hh:mm:ss:mss] Running:/user/username/projects/myproject/test/tsconfig.json
294343
Infoseq[hh:mm:ss:mss]Starting updateGraphWorker: Project:/user/username/projects/myproject/test/tsconfig.json
344+
Infoseq[hh:mm:ss:mss]File'/a/lib/package.json'doesnotexistaccordingtoearliercachedlookups.
345+
Infoseq[hh:mm:ss:mss]File'/a/package.json'doesnotexistaccordingtoearliercachedlookups.
346+
Infoseq[hh:mm:ss:mss]File'/package.json'doesnotexistaccordingtoearliercachedlookups.
347+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/test/package.json'doesnotexistaccordingtoearliercachedlookups.
348+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/package.json'doesnotexistaccordingtoearliercachedlookups.
349+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/package.json'doesnotexistaccordingtoearliercachedlookups.
350+
Infoseq[hh:mm:ss:mss]File'/user/username/package.json'doesnotexistaccordingtoearliercachedlookups.
351+
Infoseq[hh:mm:ss:mss]File'/user/package.json'doesnotexistaccordingtoearliercachedlookups.
352+
Infoseq[hh:mm:ss:mss]File'/package.json'doesnotexistaccordingtoearliercachedlookups.
353+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@types/UpperCasePackage/package.json'doesnotexistaccordingtoearliercachedlookups.
354+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@types/package.json'doesnotexistaccordingtoearliercachedlookups.
355+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/package.json'doesnotexistaccordingtoearliercachedlookups.
356+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/package.json'doesnotexistaccordingtoearliercachedlookups.
357+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/package.json'doesnotexistaccordingtoearliercachedlookups.
358+
Infoseq[hh:mm:ss:mss]File'/user/username/package.json'doesnotexistaccordingtoearliercachedlookups.
359+
Infoseq[hh:mm:ss:mss]File'/user/package.json'doesnotexistaccordingtoearliercachedlookups.
360+
Infoseq[hh:mm:ss:mss]File'/package.json'doesnotexistaccordingtoearliercachedlookups.
361+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@app/lib/package.json'doesnotexistaccordingtoearliercachedlookups.
362+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/@app/package.json'doesnotexistaccordingtoearliercachedlookups.
363+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/lib/package.json'doesnotexistaccordingtoearliercachedlookups.
364+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/myproject/package.json'doesnotexistaccordingtoearliercachedlookups.
365+
Infoseq[hh:mm:ss:mss]File'/user/username/projects/package.json'doesnotexistaccordingtoearliercachedlookups.
366+
Infoseq[hh:mm:ss:mss]File'/user/username/package.json'doesnotexistaccordingtoearliercachedlookups.
367+
Infoseq[hh:mm:ss:mss]File'/user/package.json'doesnotexistaccordingtoearliercachedlookups.
368+
Infoseq[hh:mm:ss:mss]File'/package.json'doesnotexistaccordingtoearliercachedlookups.
369+
Infoseq[hh:mm:ss:mss]Reusingresolutionoftypereferencedirective'UpperCasePackage'from'/user/username/projects/myproject/lib/@app/lib/index.d.ts'ofoldprogram,itwassuccessfullyresolvedto'/user/username/projects/myproject/lib/@types/UpperCasePackage/index.d.ts'.
295370
Infoseq[hh:mm:ss:mss]FinishingupdateGraphWorker:Project:/user/username/projects/myproject/test/tsconfig.json projectStateVersion:2 projectProgramVersion:1 structureChanged:false structureIsReused::CompletelyElapsed::*ms
296371
Infoseq[hh:mm:ss:mss]Project'/user/username/projects/myproject/test/tsconfig.json'(Configured)
297372
Infoseq[hh:mm:ss:mss]Files(4)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp