Skip to content

Commit

Permalink
fix(tsc): point to shimmed tsc entry point to support ts 5.7 (#5020)
Browse files Browse the repository at this point in the history
Co-authored-by: KazariEX <[email protected]>
Co-authored-by: 山吹色御守 <[email protected]>
Co-authored-by: Danila Rodichkin <[email protected]>
  • Loading branch information
4 people authored Dec 9, 2024
1 parent 5784131 commit 3fb59af
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
14 changes: 13 additions & 1 deletion packages/tsc/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { runTsc } from '@volar/typescript/lib/quickstart/runTsc';
import * as vue from '@vue/language-core';
import * as semver from 'semver';

const windowsPathReg = /\\/g;

export function run(tscPath = require.resolve('typescript/lib/tsc')) {
export function run(tscPath = getTscPath()) {

let runExtensions = ['.vue'];

Expand Down Expand Up @@ -46,3 +47,14 @@ export function run(tscPath = require.resolve('typescript/lib/tsc')) {
}
}
}

function getTscPath() {
const version = require('typescript/package.json').version as string;

if (semver.gte(version, '5.7.0')) {
return require.resolve('typescript/lib/_tsc');
}
else {
return require.resolve('typescript/lib/tsc');
}
}
3 changes: 2 additions & 1 deletion packages/tsc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"typescript": ">=5.0.0"
},
"devDependencies": {
"@types/node": "latest"
"@types/node": "latest",
"@types/semver": "^7.5.4"
}
}
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3fb59af

Please sign in to comment.