Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
run
✓ import { run } from 'vue-tsc'
✗ const { run } = require('vue-tsc')
The primary programmatic entry point for executing vue-tsc's CLI logic. Primarily an ESM package; CommonJS require() may lead to import errors. Accepts an options object to pass CLI arguments and tsc path.
VueCompilerOptions
✓ import type { VueCompilerOptions } from 'vue-tsc'
Inferred type for configuration options found in `tsconfig.json` under `vueCompilerOptions`. Useful for programmatic configuration or extending Vue language tools.
Diagnostic
✓ import type { Diagnostic } from 'vue-tsc'
Inferred type for diagnostic messages produced by the type checker, often for custom error handling or reporting. This type is likely a re-export from TypeScript's own Diagnostic type, potentially augmented for Vue-specific contexts.
Demonstrates programmatic execution of `vue-tsc --noEmit` to type-check Vue SFCs in a project. It sets up a minimal `tsconfig.json` and a `.vue` file for context.
import { run } from 'vue-tsc';
import * as path from 'path';
import * as fs from 'fs';
// Create a dummy tsconfig.json for demonstration if not present
const tsconfigPath = path.resolve('./tsconfig.json');
if (!fs.existsSync(tsconfigPath)) {
fs.writeFileSync(tsconfigPath, JSON.stringify({
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "bundler",
"strict": true,
"jsx": "preserve",
"lib": ["esnext", "dom"],
"types": ["node", "vue"]
},
"vueCompilerOptions": {
"extensions": [".vue"]
},
"include": ["./**/*.ts", "./**/*.d.ts", "./**/*.vue"]
}, null, 2));
}
// Create a dummy Vue SFC for type checking
const vueFilePath = path.resolve('./MyComponent.vue');
if (!fs.existsSync(vueFilePath)) {
fs.writeFileSync(vueFilePath, `
<script setup lang="ts">
import { ref } from 'vue';
const message: string = ref('Hello Vue 3 and TypeScript').value;
// Intentional error for demonstration: assign number to string
// const errorVal: string = 123;
</script>
<template>
<div>{{ message }}</div>
</template>
`);
}
console.log('Running vue-tsc programmatically with --noEmit...');
// Execute vue-tsc with command-line arguments
try {
run({
args: ['--noEmit', '--project', tsconfigPath] // Equivalent to 'vue-tsc --noEmit --project ./tsconfig.json'
});
console.log('vue-tsc completed successfully (noEmit). No type errors found.');
} catch (e) {
console.error('vue-tsc encountered an error:', e.message);
console.error('Check MyComponent.vue for type errors or tsconfig.json configuration.');
process.exit(1);
}
vue-tsc --version
Errors
Common errors & fixes
Module not found: Error: Can't resolve './MyComponent.vue' in '...' OR Cannot find module './MyComponent.vue' or its corresponding type declarations.
TypeScript (tsc) does not natively understand `.vue` file imports. This typically indicates `vue-tsc` is not correctly integrated or the project's `tsconfig.json` is misconfigured.
fixEnsure `vue-tsc` is installed and configured in your `package.json` scripts (e.g., `"type-check": "vue-tsc --noEmit"`) and that your `tsconfig.json` includes `"*.vue"` in its `include` array, along with appropriate `vueCompilerOptions`.
The 'typescript' package is not installed or its version is less than 5.0.0.
`vue-tsc` has a strict peer dependency on TypeScript version 5.0.0 or higher.
fixInstall or upgrade TypeScript to version 5.0.0 or newer: `npm install typescript@^5.0.0 --save-dev` (or `yarn add typescript@^5.0.0 --dev`).
Property 'someProp' does not exist on type 'VueComponentInstance' (or similar type error within a Vue template or script).
Incorrect type inference for props, data, or methods within a Vue component, often due to missing `defineProps` or `defineEmits`, or incorrect type definitions.
fixVerify that your Vue component's props and emits are correctly defined using `defineProps` and `defineEmits` with explicit generic type arguments in `<script setup>`, and ensure any custom types are properly imported and available.
Audit
Dependencies
typescriptrequiredRequired peer dependency for core type checking functionality. Specifies TypeScript >=5.0.0.