Skip to content
Merged
Changes from all 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
11 changes: 7 additions & 4 deletions packages/nuxi/src/commands/typecheck.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import process from 'node:process'
import { fileURLToPath } from 'node:url'

import { defineCommand } from 'citty'
import { resolveModulePath } from 'exsolve'
import { resolve } from 'pathe'
import { readTSConfig } from 'pkg-types'
import { isBun } from 'std-env'
import { x } from 'tinyexec'

Expand Down Expand Up @@ -41,13 +41,16 @@ export default defineCommand({
await buildNuxt(nuxt)
await nuxt.close()

const supportsProjects = await readTSConfig(cwd).then(r => !!(r.references?.length))
const typeCheckArgs = supportsProjects ? ['-b', '--noEmit'] : ['--noEmit']

// Prefer local install if possible
const [resolvedTypeScript, resolvedVueTsc] = await Promise.all([
resolveModulePath('typescript', { try: true }),
resolveModulePath('vue-tsc/bin/vue-tsc.js', { try: true }),
])
if (resolvedTypeScript && resolvedVueTsc) {
await x(fileURLToPath(resolvedVueTsc), ['--noEmit'], {
await x(resolvedVueTsc, typeCheckArgs, {
throwOnError: true,
nodeOptions: {
stdio: 'inherit',
Expand All @@ -66,7 +69,7 @@ export default defineCommand({
},
)

await x('bunx', 'vue-tsc --noEmit'.split(' '), {
await x('bunx', ['vue-tsc', ...typeCheckArgs], {
throwOnError: true,
nodeOptions: {
stdio: 'inherit',
Expand All @@ -77,7 +80,7 @@ export default defineCommand({
else {
await x(
'npx',
'-p vue-tsc -p typescript vue-tsc --noEmit'.split(' '),
['-p', 'vue-tsc', '-p', 'typescript', 'vue-tsc', ...typeCheckArgs],
{
throwOnError: true,
nodeOptions: { stdio: 'inherit', cwd },
Expand Down