oxc-project/oxc · error · OxcDiagnostic
`defineEmits` has both a type-only emit and an argument.
Error message
`defineEmits` has both a type-only emit and an argument.
What it means
Emitted by run_once of the vue valid-define-emits rule (via check_define_macro_call_expression) when a defineEmits macro call supplies both a type-only declaration (type parameter) and a runtime argument. The two declaration forms conflict; only one should be used, and the runtime argument defeats the type inference of the type parameter.
Source
Thrown at crates/oxc_linter/src/rules/vue/valid_define_emits.rs:14
use oxc_ast::AstKind;
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)
}View on GitHub (pinned to e1e7af627c)
Solutions
- Remove the runtime argument and keep only the type-based declaration
- Or remove the type parameter and keep the runtime declaration if consistent with project style
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/vue/valid_define_emits.rs:14 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/f8bf67d115a42a62.
Report an issue: GitHub.