From 0bd99e730fbb1f842199d7bcffdbc20e458e87b2 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 27 Jun 2025 09:36:33 +0100 Subject: [PATCH 1/2] feat(typecheck): support ts projects --- packages/nuxi/src/commands/typecheck.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/nuxi/src/commands/typecheck.ts b/packages/nuxi/src/commands/typecheck.ts index a13c62a05..3e009a09b 100644 --- a/packages/nuxi/src/commands/typecheck.ts +++ b/packages/nuxi/src/commands/typecheck.ts @@ -4,6 +4,7 @@ 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' @@ -41,13 +42,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(fileURLToPath(resolvedVueTsc), typeCheckArgs, { throwOnError: true, nodeOptions: { stdio: 'inherit', @@ -66,7 +70,7 @@ export default defineCommand({ }, ) - await x('bunx', 'vue-tsc --noEmit'.split(' '), { + await x('bunx', ['vue-tsc', ...typeCheckArgs], { throwOnError: true, nodeOptions: { stdio: 'inherit', @@ -77,7 +81,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 }, From 0a705d1bebcef7b74450530d1ca9c22347cc638f Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 27 Jun 2025 13:22:02 +0100 Subject: [PATCH 2/2] fix: do not use `fileURLToPath` --- packages/nuxi/src/commands/typecheck.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/nuxi/src/commands/typecheck.ts b/packages/nuxi/src/commands/typecheck.ts index 3e009a09b..a9945e24d 100644 --- a/packages/nuxi/src/commands/typecheck.ts +++ b/packages/nuxi/src/commands/typecheck.ts @@ -1,5 +1,4 @@ import process from 'node:process' -import { fileURLToPath } from 'node:url' import { defineCommand } from 'citty' import { resolveModulePath } from 'exsolve' @@ -51,7 +50,7 @@ export default defineCommand({ resolveModulePath('vue-tsc/bin/vue-tsc.js', { try: true }), ]) if (resolvedTypeScript && resolvedVueTsc) { - await x(fileURLToPath(resolvedVueTsc), typeCheckArgs, { + await x(resolvedVueTsc, typeCheckArgs, { throwOnError: true, nodeOptions: { stdio: 'inherit',