Vue 3 command line Type-Checking tool that extends TypeScript to understand Vue Single File Components
npx @tessl/cli install tessl/npm-vue-tsc@3.0.0Vue TSC is a command-line TypeScript compiler specifically designed for Vue 3 applications. It extends the standard TypeScript compiler to understand Vue Single File Components (.vue files), enabling type checking and declaration file generation for Vue projects with full type safety.
npm install vue-tsc typescriptimport { run } from "vue-tsc";For CommonJS:
const { run } = require("vue-tsc");CLI Usage (most common):
# Type checking only (recommended for CI/CD)
vue-tsc --noEmit
# Generate declaration files for Vue components
vue-tsc --declaration --emitDeclarationOnly
# Use with TypeScript build mode
vue-tsc --build
# Pass any TypeScript compiler options
vue-tsc --strict --target ES2020Programmatic Usage:
import { run } from "vue-tsc";
// Use default TypeScript compiler
run();
// Use custom TypeScript compiler path
run("/path/to/custom/typescript/lib/tsc");Vue TSC integrates several key components to provide Vue-aware TypeScript compilation:
tsc) with Vue language support@vue/language-core to parse and understand Vue Single File Components@volar/typescript for high-performance TypeScript language servicesCore function for integrating Vue TypeScript compilation into custom build tools or processes.
/**
* Executes TypeScript compilation with Vue Single File Component support
* @param tscPath - Optional path to TypeScript compiler executable
* @returns Result from the underlying TypeScript compilation process
*/
function run(tscPath?: string): any;The run function:
require.resolve('typescript/lib/tsc') when no path provided.vue file supportCommand-line tool that provides Vue-aware TypeScript compilation for development workflows.
# Primary CLI command
vue-tsc [typescript-options]
# Common usage patterns:
vue-tsc --noEmit # Type checking only
vue-tsc --declaration --emitDeclarationOnly # Generate .d.ts filesCLI Features:
tsconfig.json with Vue-specific extensions--build flag for TypeScript project references--noEmit, --declaration, and other output options// Return type from run() function - matches TypeScript compiler output
type CompilationResult = any;
// Internal Vue configuration options (from @vue/language-core)
interface VueCompilerOptions {
extensions: string[];
// Additional Vue-specific compiler options
}
// Vue language plugin configuration
interface VueLanguagePlugin {
// Plugin interface for TypeScript language service integration
}Vue TSC requires these peer and runtime dependencies:
>=5.0.0 (peer dependency)2.4.23 (TypeScript language service integration)3.0.6 (Vue language support and SFC parsing)The tool handles several error scenarios:
.vue file parsing errors through the Vue language coreDevelopment Workflow:
# Add to package.json scripts
{
"scripts": {
"type-check": "vue-tsc --noEmit",
"build-types": "vue-tsc --declaration --emitDeclarationOnly"
}
}CI/CD Pipeline:
# Type checking in continuous integration
npm run type-checkLibrary Development:
# Generate declaration files for Vue component libraries
vue-tsc --declaration --emitDeclarationOnly --outDir dist/types