oxc-project/oxc · error · OxcDiagnostic

`defineProps` has been called multiple times.

Error message

`defineProps` has been called multiple times.

What it means

Diagnostic from the oxlint rule `vue/valid-define-props`. The rule's `run_once` remembers the first `defineProps` call span in `found`; every subsequent `defineProps` call in the same program reports this diagnostic with two labels — the current call ('`defineProps` is called here') and the first one ('`defineProps` is called here too'). The Vue compiler allows exactly one `defineProps` per component; a second call fails compilation of `<script setup>`.

Source

Thrown at crates/oxc_linter/src/rules/vue/valid_define_props.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("`defineProps` 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("`defineProps` has been called multiple times.")
        .with_help("combine all `defineProps` calls into a single `defineProps` call.")
        .with_labels([
            span.label("`defineProps` is called here"),
            second_span.label("`defineProps` is called here too"),
        ])
}

fn events_not_defined(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Props are not defined.")
        .with_help("Define at least one prop in `defineProps`.")
        .with_label(span)
}

fn referencing_locally(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("`defineProps` 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

  1. Merge all prop declarations into a single `defineProps({ msg: String, count: Number })` (or one type-only `defineProps<{...}>()`).
  2. If you merged two files, delete the losing component's `defineProps` and fold its props into the survivor's call.
  3. Run the lint again to confirm the duplicate-call diagnostic (and its two labels) are gone.

Example fix

// before
<script setup>
defineProps({ msg: String })
defineProps({ count: Number })
</script>

// after
<script setup>
defineProps({ msg: String, count: Number })
</script>
Defensive patterns

Strategy: validation

Validate before calling

const count = (setup.match(/\bdefineProps\s*\(/g) ?? []).length;
if (count > 1) throw new Error(`Expected one defineProps call, found ${count}`);

Prevention

When it happens

Trigger: Two or more calls to `defineProps(...)` in one .vue program when the VueSetup framework option is active. Example from the fail tests: `defineProps({ msg: String }); defineProps({ count: Number })`. The rule matches any CallExpression whose callee is the identifier `defineProps`, including aliased local calls with that exact name.

Common situations: Merging two components or composables that each declared props; copy-pasting a prop block from another SFC; adding new props by writing a fresh `defineProps` instead of extending the existing one.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/3e33af7ff2242ea3. Report an issue: GitHub.