Skip to content

Commit

Permalink
chore: set resolvedPath for fake source file
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed May 13, 2023
1 parent 0e859fa commit c8cd804
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions packages/typescript/src/getProgram.ts
Expand Up @@ -163,20 +163,9 @@ export function getProgram(
}
}
else {
let scriptTarget = ts.ScriptTarget.JSON;
if (
fileName.endsWith('.js')
|| fileName.endsWith('.ts')
|| fileName.endsWith('.jsx')
|| fileName.endsWith('.tsx')
|| fileName.endsWith('.mjs')
|| fileName.endsWith('.mts')
|| fileName.endsWith('.cjs')
|| fileName.endsWith('.cts')
) {
scriptTarget = ts.ScriptTarget.Latest;
}
file = ts.createSourceFile(fileName, docText, scriptTarget);
file = ts.createSourceFile(fileName, docText, ts.ScriptTarget.Latest, undefined, ts.ScriptKind.Deferred);
(file as any).parseDiagnostics = []; // not important
(file as any).resolvedPath = fileName; // fix https://github.com/vuejs/language-tools/issues/2622 for TS 5.0
}
}
const newDiagnostic: T = {
Expand Down

0 comments on commit c8cd804

Please sign in to comment.