oxc-project/oxc · info · OxcDiagnostic
Use runtime declaration instead of type-based declaration
Error message
Use runtime declaration instead of type-based 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 type-based form defineProps<{...}>() while the rule is configured to enforce the runtime form. The rule only enforces a single consistent declaration style; the code is not incorrect otherwise.
Source
Thrown at crates/oxc_linter/src/rules/vue/define_props_declaration.rs:16
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
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,
}
View on GitHub (pinned to e1e7af627c)
Solutions
- Convert the call to runtime form: defineProps({ kind: { type: String, required: true } })
- If the team actually prefers generics, change the rule option to "type-based" (the default) in .oxlintrc.json
- Disable the rule for the file with an oxlint-disable comment or scope the lint globs
Example fix
// before (option "runtime")
const props = defineProps<{ kind: string }>()
// after
const props = defineProps({
kind: { type: String, required: true },
}) Defensive patterns
Strategy: validation
Validate before calling
# count type-based usages before flipping the style to "runtime" grep -rn "defineProps<" --include='*.vue' src | wc -l
Prevention
- Decide the defineProps style once in .oxlintrc.json and encode it with this rule instead of relying on review
- Run oxlint with the vue plugin in a pre-commit hook so style drift is caught before CI
When it happens
Trigger: Config sets "vue/define-props-declaration": ["error", "runtime"] (the enum is DeclarationStyle::Runtime, serde kebab-case "runtime") and the file contains a call like `const props = defineProps<{ kind: string }>()` in a TypeScript script-setup block.
Common situations: A team standardizes on runtime declarations so the SFC works without TS tooling, or a config is copied from another repo where the option was flipped; mixed-style codebases then fail lint/CI when this rule runs.
Related errors
- Use type-based declaration instead of runtime 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/8037142c01868c4c.
Report an issue: GitHub.