Skip to content

Commit 49c1772

Browse files
committed
fix: compatibility
1 parent 160a4e8 commit 49c1772

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

packages/tsc/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { runTsc } from '@volar/typescript/lib/quickstart/runTsc';
22
import * as vue from '@vue/language-core';
3+
import * as semver from 'semver';
34

45
const windowsPathReg = /\\/g;
56

6-
export function run(tscPath = require.resolve('typescript/lib/_tsc')) {
7+
export function run(tscPath = getTscPath()) {
78

89
let runExtensions = ['.vue'];
910

@@ -46,3 +47,14 @@ export function run(tscPath = require.resolve('typescript/lib/_tsc')) {
4647
}
4748
}
4849
}
50+
51+
function getTscPath() {
52+
const version = require('typescript/package.json').version as string;
53+
54+
if (semver.gte(version, '5.7.2')) {
55+
return require.resolve('typescript/lib/_tsc');
56+
}
57+
else {
58+
return require.resolve('typescript/lib/tsc');
59+
}
60+
}

packages/tsc/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"typescript": ">=5.0.0"
2626
},
2727
"devDependencies": {
28-
"@types/node": "latest"
28+
"@types/node": "latest",
29+
"@types/semver": "^7.5.4"
2930
}
3031
}

pnpm-lock.yaml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)