Skip to content

Commit 5521f80

Browse files
authored
getTypeInfo should normalize slashes in path before querying our internal APIs for type info (#1762)
* Fix bug * fix bug
1 parent a449373 commit 5521f80

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/index.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -1097,9 +1097,13 @@ export function createFromPreloadedConfig(
10971097
};
10981098

10991099
getTypeInfo = (code: string, fileName: string, position: number) => {
1100-
updateMemoryCache(code, fileName);
1100+
const normalizedFileName = normalizeSlashes(fileName);
1101+
updateMemoryCache(code, normalizedFileName);
11011102

1102-
const info = service.getQuickInfoAtPosition(fileName, position);
1103+
const info = service.getQuickInfoAtPosition(
1104+
normalizedFileName,
1105+
position
1106+
);
11031107
const name = ts.displayPartsToString(info ? info.displayParts : []);
11041108
const comment = ts.displayPartsToString(info ? info.documentation : []);
11051109

@@ -1283,9 +1287,10 @@ export function createFromPreloadedConfig(
12831287
};
12841288

12851289
getTypeInfo = (code: string, fileName: string, position: number) => {
1286-
updateMemoryCache(code, fileName);
1290+
const normalizedFileName = normalizeSlashes(fileName);
1291+
updateMemoryCache(code, normalizedFileName);
12871292

1288-
const sourceFile = builderProgram.getSourceFile(fileName);
1293+
const sourceFile = builderProgram.getSourceFile(normalizedFileName);
12891294
if (!sourceFile)
12901295
throw new TypeError(`Unable to read file: ${fileName}`);
12911296

0 commit comments

Comments
 (0)