Skip to content

Commit a59f129

Browse files
committed
When using cached sourceFile from the info, make sure the scriptKind is same
This is needed esp with externalFiles since they may not use actual scriptInfo and text at all Fixes #57631
1 parent ac376fc commit a59f129

2 files changed

Lines changed: 388 additions & 1 deletion

File tree

src/services/documentRegistry.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
getKeyForCompilerOptions,
1414
getOrUpdate,
1515
getSetExternalModuleIndicator,
16+
getSnapshotText,
1617
identity,
1718
IScriptSnapshot,
1819
isDeclarationFileName,
@@ -300,7 +301,7 @@ export function createDocumentRegistryInternal(useCaseSensitiveFileNames?: boole
300301
let entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
301302
if (!entry && externalCache) {
302303
const sourceFile = externalCache.getDocument(keyWithMode, path);
303-
if (sourceFile) {
304+
if (sourceFile && sourceFile.scriptKind === scriptKind && sourceFile.text === getSnapshotText(scriptSnapshot)) {
304305
Debug.assert(acquiring);
305306
entry = {
306307
sourceFile,

0 commit comments

Comments
 (0)