Skip to content

Commit 382891f

Browse files
author
Andy
authored
Merge pull request microsoft#11926 from Microsoft/module_resolution_fixes
When looking up modules in @types, only look for `index.d.ts` and `pa…
2 parents 1bc4ab0 + ce9e5f5 commit 382891f

14 files changed

+70
-324
lines changed

src/compiler/moduleNameResolver.ts

Lines changed: 70 additions & 72 deletions
Large diffs are not rendered by default.

src/harness/unittests/moduleResolution.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,9 @@ namespace ts {
197197
"/a/b/c/d/node_modules/foo/index.tsx",
198198
"/a/b/c/d/node_modules/foo/index.d.ts",
199199

200-
"/a/b/c/d/node_modules/@types/foo.ts",
201-
"/a/b/c/d/node_modules/@types/foo.tsx",
202200
"/a/b/c/d/node_modules/@types/foo.d.ts",
203201
"/a/b/c/d/node_modules/@types/foo/package.json",
204202

205-
"/a/b/c/d/node_modules/@types/foo/index.ts",
206-
"/a/b/c/d/node_modules/@types/foo/index.tsx",
207203
"/a/b/c/d/node_modules/@types/foo/index.d.ts",
208204

209205
"/a/b/c/node_modules/foo.ts",
@@ -215,13 +211,9 @@ namespace ts {
215211
"/a/b/c/node_modules/foo/index.tsx",
216212
"/a/b/c/node_modules/foo/index.d.ts",
217213

218-
"/a/b/c/node_modules/@types/foo.ts",
219-
"/a/b/c/node_modules/@types/foo.tsx",
220214
"/a/b/c/node_modules/@types/foo.d.ts",
221215
"/a/b/c/node_modules/@types/foo/package.json",
222216

223-
"/a/b/c/node_modules/@types/foo/index.ts",
224-
"/a/b/c/node_modules/@types/foo/index.tsx",
225217
"/a/b/c/node_modules/@types/foo/index.d.ts",
226218
]);
227219
}
@@ -257,13 +249,9 @@ namespace ts {
257249
"/a/node_modules/b/c/node_modules/d/node_modules/foo/index.tsx",
258250
"/a/node_modules/b/c/node_modules/d/node_modules/foo/index.d.ts",
259251

260-
"/a/node_modules/b/c/node_modules/d/node_modules/@types/foo.ts",
261-
"/a/node_modules/b/c/node_modules/d/node_modules/@types/foo.tsx",
262252
"/a/node_modules/b/c/node_modules/d/node_modules/@types/foo.d.ts",
263253
"/a/node_modules/b/c/node_modules/d/node_modules/@types/foo/package.json",
264254

265-
"/a/node_modules/b/c/node_modules/d/node_modules/@types/foo/index.ts",
266-
"/a/node_modules/b/c/node_modules/d/node_modules/@types/foo/index.tsx",
267255
"/a/node_modules/b/c/node_modules/d/node_modules/@types/foo/index.d.ts",
268256

269257
"/a/node_modules/b/c/node_modules/foo.ts",
@@ -275,13 +263,9 @@ namespace ts {
275263
"/a/node_modules/b/c/node_modules/foo/index.tsx",
276264
"/a/node_modules/b/c/node_modules/foo/index.d.ts",
277265

278-
"/a/node_modules/b/c/node_modules/@types/foo.ts",
279-
"/a/node_modules/b/c/node_modules/@types/foo.tsx",
280266
"/a/node_modules/b/c/node_modules/@types/foo.d.ts",
281267
"/a/node_modules/b/c/node_modules/@types/foo/package.json",
282268

283-
"/a/node_modules/b/c/node_modules/@types/foo/index.ts",
284-
"/a/node_modules/b/c/node_modules/@types/foo/index.tsx",
285269
"/a/node_modules/b/c/node_modules/@types/foo/index.d.ts",
286270

287271
"/a/node_modules/b/node_modules/foo.ts",
@@ -293,13 +277,9 @@ namespace ts {
293277
"/a/node_modules/b/node_modules/foo/index.tsx",
294278
"/a/node_modules/b/node_modules/foo/index.d.ts",
295279

296-
"/a/node_modules/b/node_modules/@types/foo.ts",
297-
"/a/node_modules/b/node_modules/@types/foo.tsx",
298280
"/a/node_modules/b/node_modules/@types/foo.d.ts",
299281
"/a/node_modules/b/node_modules/@types/foo/package.json",
300282

301-
"/a/node_modules/b/node_modules/@types/foo/index.ts",
302-
"/a/node_modules/b/node_modules/@types/foo/index.tsx",
303283
"/a/node_modules/b/node_modules/@types/foo/index.d.ts",
304284

305285
"/a/node_modules/foo.ts",
@@ -709,13 +689,9 @@ import b = require("./moduleB");
709689
"/root/folder1/node_modules/file6/index.tsx",
710690
"/root/folder1/node_modules/file6/index.d.ts",
711691

712-
"/root/folder1/node_modules/@types/file6.ts",
713-
"/root/folder1/node_modules/@types/file6.tsx",
714692
"/root/folder1/node_modules/@types/file6.d.ts",
715693

716694
"/root/folder1/node_modules/@types/file6/package.json",
717-
"/root/folder1/node_modules/@types/file6/index.ts",
718-
"/root/folder1/node_modules/@types/file6/index.tsx",
719695
"/root/folder1/node_modules/@types/file6/index.d.ts",
720696
// success on /root/node_modules/file6.ts
721697
], /*isExternalLibraryImport*/ true);

src/harness/unittests/reuseProgramStructure.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -394,26 +394,14 @@ namespace ts {
394394
"File '/fs.ts' does not exist.",
395395
"File '/fs.tsx' does not exist.",
396396
"File '/fs.d.ts' does not exist.",
397-
"File '/a/b/node_modules/@types/fs.ts' does not exist.",
398-
"File '/a/b/node_modules/@types/fs.tsx' does not exist.",
399397
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
400398
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
401-
"File '/a/b/node_modules/@types/fs/index.ts' does not exist.",
402-
"File '/a/b/node_modules/@types/fs/index.tsx' does not exist.",
403399
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
404-
"File '/a/node_modules/@types/fs.ts' does not exist.",
405-
"File '/a/node_modules/@types/fs.tsx' does not exist.",
406400
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
407401
"File '/a/node_modules/@types/fs/package.json' does not exist.",
408-
"File '/a/node_modules/@types/fs/index.ts' does not exist.",
409-
"File '/a/node_modules/@types/fs/index.tsx' does not exist.",
410402
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
411-
"File '/node_modules/@types/fs.ts' does not exist.",
412-
"File '/node_modules/@types/fs.tsx' does not exist.",
413403
"File '/node_modules/@types/fs.d.ts' does not exist.",
414404
"File '/node_modules/@types/fs/package.json' does not exist.",
415-
"File '/node_modules/@types/fs/index.ts' does not exist.",
416-
"File '/node_modules/@types/fs/index.tsx' does not exist.",
417405
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
418406
"File '/a/b/fs.js' does not exist.",
419407
"File '/a/b/fs.jsx' does not exist.",
@@ -448,26 +436,14 @@ namespace ts {
448436
"File '/fs.ts' does not exist.",
449437
"File '/fs.tsx' does not exist.",
450438
"File '/fs.d.ts' does not exist.",
451-
"File '/a/b/node_modules/@types/fs.ts' does not exist.",
452-
"File '/a/b/node_modules/@types/fs.tsx' does not exist.",
453439
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
454440
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
455-
"File '/a/b/node_modules/@types/fs/index.ts' does not exist.",
456-
"File '/a/b/node_modules/@types/fs/index.tsx' does not exist.",
457441
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
458-
"File '/a/node_modules/@types/fs.ts' does not exist.",
459-
"File '/a/node_modules/@types/fs.tsx' does not exist.",
460442
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
461443
"File '/a/node_modules/@types/fs/package.json' does not exist.",
462-
"File '/a/node_modules/@types/fs/index.ts' does not exist.",
463-
"File '/a/node_modules/@types/fs/index.tsx' does not exist.",
464444
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
465-
"File '/node_modules/@types/fs.ts' does not exist.",
466-
"File '/node_modules/@types/fs.tsx' does not exist.",
467445
"File '/node_modules/@types/fs.d.ts' does not exist.",
468446
"File '/node_modules/@types/fs/package.json' does not exist.",
469-
"File '/node_modules/@types/fs/index.ts' does not exist.",
470-
"File '/node_modules/@types/fs/index.tsx' does not exist.",
471447
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
472448
"File '/a/b/fs.js' does not exist.",
473449
"File '/a/b/fs.jsx' does not exist.",

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,12 +1662,8 @@ namespace ts.projectSystem {
16621662
"File '/a/b/node_modules/lib/index.ts' does not exist.",
16631663
"File '/a/b/node_modules/lib/index.tsx' does not exist.",
16641664
"File '/a/b/node_modules/lib/index.d.ts' does not exist.",
1665-
"File '/a/b/node_modules/@types/lib.ts' does not exist.",
1666-
"File '/a/b/node_modules/@types/lib.tsx' does not exist.",
16671665
"File '/a/b/node_modules/@types/lib.d.ts' does not exist.",
16681666
"File '/a/b/node_modules/@types/lib/package.json' does not exist.",
1669-
"File '/a/b/node_modules/@types/lib/index.ts' does not exist.",
1670-
"File '/a/b/node_modules/@types/lib/index.tsx' does not exist.",
16711667
"File '/a/b/node_modules/@types/lib/index.d.ts' does not exist.",
16721668
"File '/a/node_modules/lib.ts' does not exist.",
16731669
"File '/a/node_modules/lib.tsx' does not exist.",
@@ -1676,12 +1672,8 @@ namespace ts.projectSystem {
16761672
"File '/a/node_modules/lib/index.ts' does not exist.",
16771673
"File '/a/node_modules/lib/index.tsx' does not exist.",
16781674
"File '/a/node_modules/lib/index.d.ts' does not exist.",
1679-
"File '/a/node_modules/@types/lib.ts' does not exist.",
1680-
"File '/a/node_modules/@types/lib.tsx' does not exist.",
16811675
"File '/a/node_modules/@types/lib.d.ts' does not exist.",
16821676
"File '/a/node_modules/@types/lib/package.json' does not exist.",
1683-
"File '/a/node_modules/@types/lib/index.ts' does not exist.",
1684-
"File '/a/node_modules/@types/lib/index.tsx' does not exist.",
16851677
"File '/a/node_modules/@types/lib/index.d.ts' does not exist.",
16861678
"File '/node_modules/lib.ts' does not exist.",
16871679
"File '/node_modules/lib.tsx' does not exist.",
@@ -1690,59 +1682,32 @@ namespace ts.projectSystem {
16901682
"File '/node_modules/lib/index.ts' does not exist.",
16911683
"File '/node_modules/lib/index.tsx' does not exist.",
16921684
"File '/node_modules/lib/index.d.ts' does not exist.",
1693-
"File '/node_modules/@types/lib.ts' does not exist.",
1694-
"File '/node_modules/@types/lib.tsx' does not exist.",
16951685
"File '/node_modules/@types/lib.d.ts' does not exist.",
16961686
"File '/node_modules/@types/lib/package.json' does not exist.",
1697-
"File '/node_modules/@types/lib/index.ts' does not exist.",
1698-
"File '/node_modules/@types/lib/index.tsx' does not exist.",
16991687
"File '/node_modules/@types/lib/index.d.ts' does not exist.",
17001688
"Loading module 'lib' from 'node_modules' folder.",
17011689
"File '/a/b/node_modules/lib.js' does not exist.",
17021690
"File '/a/b/node_modules/lib.jsx' does not exist.",
17031691
"File '/a/b/node_modules/lib/package.json' does not exist.",
17041692
"File '/a/b/node_modules/lib/index.js' does not exist.",
17051693
"File '/a/b/node_modules/lib/index.jsx' does not exist.",
1706-
"File '/a/b/node_modules/@types/lib.js' does not exist.",
1707-
"File '/a/b/node_modules/@types/lib.jsx' does not exist.",
1708-
"File '/a/b/node_modules/@types/lib/package.json' does not exist.",
1709-
"File '/a/b/node_modules/@types/lib/index.js' does not exist.",
1710-
"File '/a/b/node_modules/@types/lib/index.jsx' does not exist.",
17111694
"File '/a/node_modules/lib.js' does not exist.",
17121695
"File '/a/node_modules/lib.jsx' does not exist.",
17131696
"File '/a/node_modules/lib/package.json' does not exist.",
17141697
"File '/a/node_modules/lib/index.js' does not exist.",
17151698
"File '/a/node_modules/lib/index.jsx' does not exist.",
1716-
"File '/a/node_modules/@types/lib.js' does not exist.",
1717-
"File '/a/node_modules/@types/lib.jsx' does not exist.",
1718-
"File '/a/node_modules/@types/lib/package.json' does not exist.",
1719-
"File '/a/node_modules/@types/lib/index.js' does not exist.",
1720-
"File '/a/node_modules/@types/lib/index.jsx' does not exist.",
17211699
"File '/node_modules/lib.js' does not exist.",
17221700
"File '/node_modules/lib.jsx' does not exist.",
17231701
"File '/node_modules/lib/package.json' does not exist.",
17241702
"File '/node_modules/lib/index.js' does not exist.",
17251703
"File '/node_modules/lib/index.jsx' does not exist.",
1726-
"File '/node_modules/@types/lib.js' does not exist.",
1727-
"File '/node_modules/@types/lib.jsx' does not exist.",
1728-
"File '/node_modules/@types/lib/package.json' does not exist.",
1729-
"File '/node_modules/@types/lib/index.js' does not exist.",
1730-
"File '/node_modules/@types/lib/index.jsx' does not exist.",
17311704
"======== Module name 'lib' was not resolved. ========",
17321705
`Auto discovery for typings is enabled in project '${proj.getProjectName()}'. Running extra resolution pass for module 'lib' using cache location '/a/cache'.`,
1733-
"File '/a/cache/node_modules/lib.ts' does not exist.",
1734-
"File '/a/cache/node_modules/lib.tsx' does not exist.",
17351706
"File '/a/cache/node_modules/lib.d.ts' does not exist.",
17361707
"File '/a/cache/node_modules/lib/package.json' does not exist.",
1737-
"File '/a/cache/node_modules/lib/index.ts' does not exist.",
1738-
"File '/a/cache/node_modules/lib/index.tsx' does not exist.",
17391708
"File '/a/cache/node_modules/lib/index.d.ts' does not exist.",
1740-
"File '/a/cache/node_modules/@types/lib.ts' does not exist.",
1741-
"File '/a/cache/node_modules/@types/lib.tsx' does not exist.",
17421709
"File '/a/cache/node_modules/@types/lib.d.ts' does not exist.",
17431710
"File '/a/cache/node_modules/@types/lib/package.json' does not exist.",
1744-
"File '/a/cache/node_modules/@types/lib/index.ts' does not exist.",
1745-
"File '/a/cache/node_modules/@types/lib/index.tsx' does not exist.",
17461711
"File '/a/cache/node_modules/@types/lib/index.d.ts' exist - use it as a name resolution result.",
17471712
]);
17481713
checkProjectActualFiles(proj, [file1.path, lib.path]);

tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99
"File '/node_modules/shortid/index.ts' does not exist.",
1010
"File '/node_modules/shortid/index.tsx' does not exist.",
1111
"File '/node_modules/shortid/index.d.ts' does not exist.",
12-
"File '/node_modules/@types/shortid.ts' does not exist.",
13-
"File '/node_modules/@types/shortid.tsx' does not exist.",
1412
"File '/node_modules/@types/shortid.d.ts' does not exist.",
1513
"File '/node_modules/@types/shortid/package.json' does not exist.",
16-
"File '/node_modules/@types/shortid/index.ts' does not exist.",
17-
"File '/node_modules/@types/shortid/index.tsx' does not exist.",
1814
"File '/node_modules/@types/shortid/index.d.ts' does not exist.",
1915
"Loading module 'shortid' from 'node_modules' folder.",
2016
"File '/node_modules/shortid.js' does not exist.",

tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99
"File '/node_modules/js/index.ts' does not exist.",
1010
"File '/node_modules/js/index.tsx' does not exist.",
1111
"File '/node_modules/js/index.d.ts' does not exist.",
12-
"File '/node_modules/@types/js.ts' does not exist.",
13-
"File '/node_modules/@types/js.tsx' does not exist.",
1412
"File '/node_modules/@types/js.d.ts' does not exist.",
1513
"File '/node_modules/@types/js/package.json' does not exist.",
16-
"File '/node_modules/@types/js/index.ts' does not exist.",
17-
"File '/node_modules/@types/js/index.tsx' does not exist.",
1814
"File '/node_modules/@types/js/index.d.ts' does not exist.",
1915
"Loading module 'js' from 'node_modules' folder.",
2016
"File '/node_modules/js.js' does not exist.",

tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@
3333
"File 'c:/root/folder2/node_modules/file4/index.ts' does not exist.",
3434
"File 'c:/root/folder2/node_modules/file4/index.tsx' does not exist.",
3535
"File 'c:/root/folder2/node_modules/file4/index.d.ts' does not exist.",
36-
"File 'c:/root/folder2/node_modules/@types/file4.ts' does not exist.",
37-
"File 'c:/root/folder2/node_modules/@types/file4.tsx' does not exist.",
3836
"File 'c:/root/folder2/node_modules/@types/file4.d.ts' does not exist.",
3937
"File 'c:/root/folder2/node_modules/@types/file4/package.json' does not exist.",
40-
"File 'c:/root/folder2/node_modules/@types/file4/index.ts' does not exist.",
41-
"File 'c:/root/folder2/node_modules/@types/file4/index.tsx' does not exist.",
4238
"File 'c:/root/folder2/node_modules/@types/file4/index.d.ts' does not exist.",
4339
"File 'c:/root/node_modules/file4.ts' does not exist.",
4440
"File 'c:/root/node_modules/file4.tsx' does not exist.",
@@ -47,12 +43,8 @@
4743
"File 'c:/root/node_modules/file4/index.ts' does not exist.",
4844
"File 'c:/root/node_modules/file4/index.tsx' does not exist.",
4945
"File 'c:/root/node_modules/file4/index.d.ts' does not exist.",
50-
"File 'c:/root/node_modules/@types/file4.ts' does not exist.",
51-
"File 'c:/root/node_modules/@types/file4.tsx' does not exist.",
5246
"File 'c:/root/node_modules/@types/file4.d.ts' does not exist.",
5347
"File 'c:/root/node_modules/@types/file4/package.json' does not exist.",
54-
"File 'c:/root/node_modules/@types/file4/index.ts' does not exist.",
55-
"File 'c:/root/node_modules/@types/file4/index.tsx' does not exist.",
5648
"File 'c:/root/node_modules/@types/file4/index.d.ts' does not exist.",
5749
"File 'c:/node_modules/file4.ts' does not exist.",
5850
"File 'c:/node_modules/file4.tsx' does not exist.",

tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@
3333
"File 'c:/root/folder2/node_modules/file4/index.ts' does not exist.",
3434
"File 'c:/root/folder2/node_modules/file4/index.tsx' does not exist.",
3535
"File 'c:/root/folder2/node_modules/file4/index.d.ts' does not exist.",
36-
"File 'c:/root/folder2/node_modules/@types/file4.ts' does not exist.",
37-
"File 'c:/root/folder2/node_modules/@types/file4.tsx' does not exist.",
3836
"File 'c:/root/folder2/node_modules/@types/file4.d.ts' does not exist.",
3937
"File 'c:/root/folder2/node_modules/@types/file4/package.json' does not exist.",
40-
"File 'c:/root/folder2/node_modules/@types/file4/index.ts' does not exist.",
41-
"File 'c:/root/folder2/node_modules/@types/file4/index.tsx' does not exist.",
4238
"File 'c:/root/folder2/node_modules/@types/file4/index.d.ts' does not exist.",
4339
"File 'c:/root/node_modules/file4.ts' does not exist.",
4440
"File 'c:/root/node_modules/file4.tsx' does not exist.",
@@ -47,12 +43,8 @@
4743
"File 'c:/root/node_modules/file4/index.ts' does not exist.",
4844
"File 'c:/root/node_modules/file4/index.tsx' does not exist.",
4945
"File 'c:/root/node_modules/file4/index.d.ts' does not exist.",
50-
"File 'c:/root/node_modules/@types/file4.ts' does not exist.",
51-
"File 'c:/root/node_modules/@types/file4.tsx' does not exist.",
5246
"File 'c:/root/node_modules/@types/file4.d.ts' does not exist.",
5347
"File 'c:/root/node_modules/@types/file4/package.json' does not exist.",
54-
"File 'c:/root/node_modules/@types/file4/index.ts' does not exist.",
55-
"File 'c:/root/node_modules/@types/file4/index.tsx' does not exist.",
5648
"File 'c:/root/node_modules/@types/file4/index.d.ts' does not exist.",
5749
"File 'c:/node_modules/file4.ts' does not exist.",
5850
"File 'c:/node_modules/file4.tsx' does not exist.",

0 commit comments

Comments
 (0)