oxc-project/oxc · error · OxcDiagnostic
`defineEmits` has been called multiple times.
Error message
`defineEmits` has been called multiple times.
What it means
Emitted by run_once of the vue valid-define-emits rule when the defineEmits macro is invoked more than once in the same <script setup> block. The compiler only supports one declaration; both call sites are labeled in the diagnostic.
Source
Thrown at crates/oxc_linter/src/rules/vue/valid_define_emits.rs:20
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use crate::{
context::LintContext,
frameworks::FrameworkOptions,
rule::Rule,
utils::{DefineMacroProblem, check_define_macro_call_expression, has_default_exports_property},
};
fn has_type_and_arguments_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("`defineEmits` has both a type-only emit and an argument.")
.with_help("remove the argument for better type inference.")
.with_label(span)
}
fn called_multiple_times(span: Span, second_span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("`defineEmits` has been called multiple times.")
.with_help("combine all events into a single `defineEmits` call.")
.with_labels([
span.label("`defineEmits` is called here"),
second_span.label("`defineEmits` is called here too"),
])
}
fn events_not_defined(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Custom events are not defined.")
.with_help("Define at least one event in `defineEmits`.")
.with_label(span)
}
fn referencing_locally(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("`defineEmits` is referencing locally declared variables.")
.with_help("inline the variable or import it from another module.")
.with_label(span)
}View on GitHub (pinned to e1e7af627c)
Solutions
- Merge all events into a single defineEmits call, e.g. defineEmits(['change', 'input']) or one combined type literal
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/vue/valid_define_emits.rs:20 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/52b6f371aa030b55.
Report an issue: GitHub.