Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getTypeInfo should normalize slashes in path before querying our internal APIs for type info #1762

Merged
merged 2 commits into from May 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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