Skip to content

Commit

Permalink
fix: compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Nov 25, 2024
1 parent 160a4e8 commit 49c1772
Show file tree
Hide file tree
Showing 3 changed files with 27 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.2')) {
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"
}
}
12 changes: 12 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 49c1772

Please sign in to comment.