Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typecheck): use resolve vue-tsc and typescript path #264

Merged
merged 9 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"semver": "^7.5.4",
"unbuild": "^2.0.0",
"unws": "^0.2.4",
"vue-tsc": "^2.0.6",
"ws": "^8.14.2"
},
"optionalDependencies": {
Expand Down
126 changes: 118 additions & 8 deletions pnpm-lock.yaml

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

12 changes: 6 additions & 6 deletions src/commands/typecheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { execa } from 'execa'
import { resolve } from 'pathe'
// we are deliberately inlining this code as a backup in case user has `@nuxt/schema<3.7`
import { writeTypes as writeTypesLegacy } from '@nuxt/kit'

import { tryResolveModule } from '../utils/esm'
import { loadKit } from '../utils/kit'
import { defineCommand } from 'citty'
Expand Down Expand Up @@ -43,11 +42,12 @@ export default defineCommand({
await nuxt.close()

// Prefer local install if possible
const hasLocalInstall =
(await tryResolveModule('typescript', cwd)) &&
(await tryResolveModule('vue-tsc/package.json', cwd))
if (hasLocalInstall) {
await execa('vue-tsc', ['--noEmit'], {
const [resolvedTypeScript, resolvedVueTsc] = await Promise.all([
tryResolveModule('typescript'),
tryResolveModule('vue-tsc/bin/vue-tsc.js'),
])
if (resolvedTypeScript && resolvedVueTsc) {
await execa(resolvedVueTsc, ['--noEmit'], {
preferLocal: true,
stdio: 'inherit',
cwd,
Expand Down