From 5521f807094d337485f0f5218bb78e82b50a88e2 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Fri, 20 May 2022 16:26:55 -0400 Subject: [PATCH] `getTypeInfo` should normalize slashes in path before querying our internal APIs for type info (#1762) * Fix bug * fix bug --- src/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index a0079bd24..976c1ca89 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 : []); @@ -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}`);