Skip to content
← Back to rules

vue/require-prop-type-constructor Correctness

🛠️ An auto-fix is available for this rule.

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.

Examples

Examples of incorrect code for this rule:

vue
<script>
export default {
  props: {
    foo: "String",
    bar: { type: "Number" },
  },
};
</script>

Examples of correct code for this rule:

vue
<script>
export default {
  props: {
    foo: String,
    bar: { type: Number },
  },
};
</script>

How to use

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["vue"],
  "rules": {
    "vue/require-prop-type-constructor": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["vue"],
  rules: {
    "vue/require-prop-type-constructor": "error",
  },
});
bash
oxlint --deny vue/require-prop-type-constructor --vue-plugin

Version

This rule was added in vnext.

References