oxc-project/oxc · info · OxcDiagnostic
Use type-based declaration instead of runtime declaration
Error message
Use type-based declaration instead of runtime declaration
What it means
Diagnostic from oxlint's vue/define-props-declaration rule (style category, since oxlint 1.15.0). It fires inside <script setup lang="ts"> when props are declared with the runtime object form defineProps({...}) while the rule enforces type-based declarations (DeclarationStyle::TypeBased, the default). Purely stylistic: it pushes teams toward one uniform way to declare props.
Source
Thrown at crates/oxc_linter/src/rules/vue/define_props_declaration.rs:21
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{
AstNode,
context::{ContextHost, LintContext},
frameworks::FrameworkOptions,
rule::{DefaultRuleConfig, Rule},
};
fn use_runtime_declaration_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Use runtime declaration instead of type-based declaration")
.with_label(span)
}
fn use_type_based_declaration_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Use type-based declaration instead of runtime declaration")
.with_label(span)
}
#[derive(Debug, Default, Clone, JsonSchema, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
enum DeclarationStyle {
/// Enforce type-based declaration.
#[default]
TypeBased,
/// Enforce runtime declaration.
Runtime,
}
#[derive(Debug, Default, Clone, Deserialize)]
pub struct DefinePropsDeclaration(DeclarationStyle);
declare_oxc_lint!(
/// ### What it doesView on GitHub (pinned to e1e7af627c)
Solutions
- Convert to the type-based form: defineProps<{ kind: string }>()
- Keep runtime form and set the rule option to "runtime" in .oxlintrc.json
- Disable the rule via an inline oxlint-disable comment if the file cannot be converted yet
Example fix
// before (option "type-based", the default)
const props = defineProps({ kind: { type: String } })
// after
const props = defineProps<{ kind: string }>() Defensive patterns
Strategy: validation
Validate before calling
# find runtime-style declarations before enforcing "type-based"
grep -rnE "defineProps\(\{" --include='*.vue' src Prevention
- Keep the rule option explicit in shared configs so new files cannot guess the wrong default
- Codemod defineProps styles in one commit rather than fixing file-by-file
When it happens
Trigger: Rule enabled with default or explicit "type-based" option, and the file contains `const props = defineProps({ kind: { type: String } })` in a script-setup TS block. The rule matches only CallExpressions whose callee identifier is exactly `defineProps`.
Common situations: Codebases migrating options/runtime-style components into <script setup>, or shared lint configs that enable the rule with its default; CI fails on newly copied Vue 2-style props objects.
Related errors
- Use runtime declaration instead of type-based declaration
- Prefer destructuring from `defineProps` directly.
- `VirtualFree` failed during cleanup: {err}
- Avoid destructuring from `defineProps`.
- Avoid using `withDefaults` with destructuring.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/a2f0250466adea05.
Report an issue: GitHub.