Skip to content

Commit c8cd804

Browse files
committed
chore: set resolvedPath for fake source file
close vuejs/language-tools#2622
1 parent 0e859fa commit c8cd804

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

packages/typescript/src/getProgram.ts

+3-14
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,9 @@ export function getProgram(
163163
}
164164
}
165165
else {
166-
let scriptTarget = ts.ScriptTarget.JSON;
167-
if (
168-
fileName.endsWith('.js')
169-
|| fileName.endsWith('.ts')
170-
|| fileName.endsWith('.jsx')
171-
|| fileName.endsWith('.tsx')
172-
|| fileName.endsWith('.mjs')
173-
|| fileName.endsWith('.mts')
174-
|| fileName.endsWith('.cjs')
175-
|| fileName.endsWith('.cts')
176-
) {
177-
scriptTarget = ts.ScriptTarget.Latest;
178-
}
179-
file = ts.createSourceFile(fileName, docText, scriptTarget);
166+
file = ts.createSourceFile(fileName, docText, ts.ScriptTarget.Latest, undefined, ts.ScriptKind.Deferred);
167+
(file as any).parseDiagnostics = []; // not important
168+
(file as any).resolvedPath = fileName; // fix https://github.com/vuejs/language-tools/issues/2622 for TS 5.0
180169
}
181170
}
182171
const newDiagnostic: T = {

0 commit comments

Comments
 (0)