File tree 2 files changed +41
-3
lines changed
2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -832,7 +832,7 @@ namespace ts {
832
832
*/
833
833
function parseNodeModuleFromPath ( path : string ) : { packageDirectory : string , subModuleName : string } | undefined {
834
834
path = normalizePath ( path ) ;
835
- const idx = path . indexOf ( nodeModulesPathPart ) ;
835
+ const idx = path . lastIndexOf ( nodeModulesPathPart ) ;
836
836
if ( idx === - 1 ) {
837
837
return undefined ;
838
838
}
@@ -843,12 +843,12 @@ namespace ts {
843
843
indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable ( path , indexAfterPackageName ) ;
844
844
}
845
845
const packageDirectory = path . slice ( 0 , indexAfterPackageName ) ;
846
- const subModuleName = removeExtensionAndIndex ( path . slice ( indexAfterPackageName ) ) ;
846
+ const subModuleName = removeExtensionAndIndex ( path . slice ( indexAfterPackageName + 1 ) ) ;
847
847
return { packageDirectory, subModuleName } ;
848
848
}
849
849
850
850
function moveToNextDirectorySeparatorIfAvailable ( path : string , prevSeparatorIndex : number ) : number {
851
- const nextSeparatorIndex = path . indexOf ( directorySeparator , prevSeparatorIndex ) ;
851
+ const nextSeparatorIndex = path . indexOf ( directorySeparator , prevSeparatorIndex + 1 ) ;
852
852
return nextSeparatorIndex === - 1 ? prevSeparatorIndex : nextSeparatorIndex ;
853
853
}
854
854
Original file line number Diff line number Diff line change
1
+ // @noImplicitReferences : true
2
+ // @traceResolution : true
3
+
4
+ // @Filename : /node_modules/a/node_modules/@foo/bar/package.json
5
+ {
6
+ "name" : "@foo/bar" ,
7
+ "version" : "1.2.3"
8
+ }
9
+
10
+ // @Filename : /node_modules/a/node_modules/@foo/bar/index.d.ts
11
+ export class C {
12
+ private x : number ;
13
+ }
14
+
15
+ // @Filename : /node_modules/a/index.d.ts
16
+ import { C } from "@foo/bar" ;
17
+ export const o : C ;
18
+
19
+ // @Filename : /node_modules/@foo/bar/use.d.ts
20
+ import { C } from "./index" ;
21
+ export function use ( o : C ) : void ;
22
+
23
+ // @Filename : /node_modules/@foo/bar/index.d.ts
24
+ export class C {
25
+ private x : number ;
26
+ }
27
+
28
+ // @Filename : /node_modules/@foo/bar/package.json
29
+ {
30
+ "name" : "@foo/bar" ,
31
+ "version" : "1.2.3"
32
+ }
33
+
34
+ // @Filename : /index.ts
35
+ import { use } from "@foo/bar/use" ;
36
+ import { o } from "a" ;
37
+
38
+ use ( o ) ;
You can’t perform that action at this time.
0 commit comments