Skip to content

Commit

Permalink
fix: patch tsc to not crash on composite project errors
Browse files Browse the repository at this point in the history
Fixes vuejs#2622

I don't know the exact detail of the crash, but I find that tsc crashed
because the `diagnostic.file` object is somehow missing a `resolvedPath`
field. Meanwhile, the `fileName` field is always present. So I just
added a fallback to `fileName` in the patch.

Maybe related: microsoft/TypeScript#54057

I only add it to the 5.0 branch because I haven't tested it on 4.x,
so let's play it safe.
  • Loading branch information
sodatea committed May 12, 2023
1 parent 21b68a7 commit 5dd3a1a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/vue-tsc/bin/vue-tsc.js
Expand Up @@ -25,6 +25,8 @@ fs.readFileSync = (...args) => {
.filter(file => !file.toLowerCase().includes('__vls_'))
.map(file => file.replace(/\.vue\.(j|t)sx?$/i, '.vue'))
) {`);

tryReplace(`relativeToBuildInfo(file.resolvedPath)`, `relativeToBuildInfo(file.resolvedPath || file.fileName)`);
}

return tsc;
Expand Down

0 comments on commit 5dd3a1a

Please sign in to comment.