type/require-typed-props
Require type definition for defineProps
Default severity: warning
Presets: happy-path, nuxt, ecosystem, opinionated
Automatic fix: None; review the suggested change
Applies to: Type information in Vue SFC scripts and templates, for the constructs shown below
Options: No rule-specific options. Severity and preset selection are configurable.
Type-aware checks use the native Corsa runtime and the TypeScript project. typeAware alone does not enable an opt-in rule.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"type/require-typed-props": "warn"
},
"typeAware": true
},
},
});
vp run lint
Bad
The array-only defineProps(["title"]) declares title by name without giving it a type.
<script setup lang="ts">
defineProps(["title"]);
</script>
Good
defineProps<{ title: string }>() gives title an explicit string type instead of a name-only runtime declaration.
<script setup lang="ts">
defineProps<{ title: string }>();
</script>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.