diff --git a/packages/tsc/index.ts b/packages/tsc/index.ts index 1ba58bdf9a..8eae1f29be 100644 --- a/packages/tsc/index.ts +++ b/packages/tsc/index.ts @@ -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']; @@ -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'); + } +} diff --git a/packages/tsc/package.json b/packages/tsc/package.json index 774bc9c716..66d3a0a565 100644 --- a/packages/tsc/package.json +++ b/packages/tsc/package.json @@ -25,6 +25,7 @@ "typescript": ">=5.0.0" }, "devDependencies": { - "@types/node": "latest" + "@types/node": "latest", + "@types/semver": "^7.5.4" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f73e9b1fbe..077ad763ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -282,6 +282,9 @@ importers: '@types/node': specifier: latest version: 22.10.1 + '@types/semver': + specifier: ^7.5.4 + version: 7.5.8 packages/typescript-plugin: dependencies: