Skip to content

Commit

Permalink
getTypeInfo should normalize slashes in path before querying our in…
Browse files Browse the repository at this point in the history
…ternal APIs for type info (#1762)

* Fix bug

* fix bug
  • Loading branch information
cspotcode committed May 20, 2022
1 parent a449373 commit 5521f80
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/index.ts
Expand Up @@ -1097,9 +1097,13 @@ export function createFromPreloadedConfig(
};

getTypeInfo = (code: string, fileName: string, position: number) => {
updateMemoryCache(code, fileName);
const normalizedFileName = normalizeSlashes(fileName);
updateMemoryCache(code, normalizedFileName);

const info = service.getQuickInfoAtPosition(fileName, position);
const info = service.getQuickInfoAtPosition(
normalizedFileName,
position
);
const name = ts.displayPartsToString(info ? info.displayParts : []);
const comment = ts.displayPartsToString(info ? info.documentation : []);

Expand Down Expand Up @@ -1283,9 +1287,10 @@ export function createFromPreloadedConfig(
};

getTypeInfo = (code: string, fileName: string, position: number) => {
updateMemoryCache(code, fileName);
const normalizedFileName = normalizeSlashes(fileName);
updateMemoryCache(code, normalizedFileName);

const sourceFile = builderProgram.getSourceFile(fileName);
const sourceFile = builderProgram.getSourceFile(normalizedFileName);
if (!sourceFile)
throw new TypeError(`Unable to read file: ${fileName}`);

Expand Down

0 comments on commit 5521f80

Please sign in to comment.