oxc-project/oxc · error · OxcDiagnostic

Prop "{name}" should define at least its type.

Error message

Prop "{name}" should define at least its type.

What it means

Emitted by check_define_model, check_props, and check_array_props in the vue require-prop-types rule when a prop is declared without any type information — as a bare key in an array or an object entry lacking a type field. It is a validation guard: untyped props skip Vue's runtime validation and make components harder to reason about.

Source

Thrown at crates/oxc_linter/src/rules/vue/require_prop_types.rs:15

use oxc_ast::{
    AstKind,
    ast::{
        ArrayExpression, CallExpression, ExportDefaultDeclaration, ExportDefaultDeclarationKind,
        Expression, NewExpression, ObjectExpression, ObjectPropertyKind,
    },
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};

use crate::{AstNode, context::LintContext, frameworks::FrameworkOptions, rule::Rule};

fn require_type_diagnostic(span: Span, name: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("Prop \"{name}\" should define at least its type."))
        .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct RequirePropTypes;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// This rule enforces that a props statement contains a type definition.
    ///
    /// ### Why is this bad?
    ///
    /// In committed code, prop definitions should always be as detailed as
    /// possible, specifying at least type(s).
    ///
    /// ### Examples
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Add a type to the prop, e.g. props: { foo: { type: String, required: true } }
  2. Give array-syntax props object entries with a type field
  3. In type-based defineProps, annotate the prop's type instead of using unknown/any
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/vue/require_prop_types.rs:15 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/2993d744df07deb9. Report an issue: GitHub.