type/require-typed-emits
Require type definition for defineEmits
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-emits": "warn"
},
"typeAware": true
},
},
});
vp run lint
Bad
The array-only defineEmits(["save"]) declares the event name without a typed payload contract.
<script setup lang="ts">
defineEmits(["save"]);
</script>
Good
defineEmits<{ save: [] }>() declares the typed save event with an empty payload tuple, explicitly stating that it takes no payload arguments.
<script setup lang="ts">
defineEmits<{ save: [] }>();
</script>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.