oxc-project/oxc · error · OxcDiagnostic

The "{prop_name}" property should be a constructor.

Error message

The "{prop_name}" property should be a constructor.

What it means

Emitted by check_and_report in the vue require-prop-type-constructor rule when a prop's type entry in the props definition is a string or expression that is not a native constructor (String, Number, Boolean, Function, Object, Array, Symbol or a class/constructor function). Vue relies on constructors for prop validation, so arbitrary values break it.

Source

Thrown at crates/oxc_linter/src/rules/vue/require_prop_type_constructor.rs:23

        TemplateLiteral,
    },
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use oxc_syntax::identifier::is_identifier_name;

use crate::{
    AstNode,
    context::LintContext,
    fixer::{RuleFix, RuleFixer},
    frameworks::FrameworkOptions,
    rule::Rule,
    utils::{find_property, is_vue_component_options_object_excluding_instance},
};

fn require_prop_type_constructor_diagnostic(prop_name: &str, span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("The \"{prop_name}\" property should be a constructor."))
        .with_label(span)
}

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

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Require `props` type values to be a constructor function (e.g. `String`,
    /// `Number`, `Boolean`) rather than a string, number, or other literal.
    ///
    /// ### Why is this bad?
    ///
    /// Vue uses the prop type for runtime validation and dev-time warnings. A
    /// string like `'String'` looks like the constructor but is never matched
    /// against an actual value, silently disabling the check.
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Use a constructor for the prop type, e.g. props: { count: Number }
  2. For custom classes, reference the class constructor directly instead of a string name
  3. List multiple constructors in an array, e.g. type: [String, Number]
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/vue/require_prop_type_constructor.rs:23 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/47752bbb9003eb44. Report an issue: GitHub.