{"record":{"id":"62487c3d7522e61e","repo":"oxc-project/oxc","slug":"defineprops-has-both-a-type-only-emit-and-an-arg","errorCode":null,"errorMessage":"`defineProps` has both a type-only emit and an argument.","messagePattern":"`defineProps` has both a type-only emit and an argument\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vue/valid_define_props.rs","lineNumber":14,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    context::LintContext,\n    frameworks::FrameworkOptions,\n    rule::Rule,\n    utils::{DefineMacroProblem, check_define_macro_call_expression, has_default_exports_property},\n};\n\nfn has_type_and_arguments_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`defineProps` has both a type-only emit and an argument.\")\n        .with_help(\"remove the argument for better type inference.\")\n        .with_label(span)\n}\n\nfn called_multiple_times(span: Span, second_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`defineProps` has been called multiple times.\")\n        .with_help(\"combine all `defineProps` calls into a single `defineProps` call.\")\n        .with_labels([\n            span.label(\"`defineProps` is called here\"),\n            second_span.label(\"`defineProps` is called here too\"),\n        ])\n}\n\nfn events_not_defined(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Props are not defined.\")\n        .with_help(\"Define at least one prop in `defineProps`.\")\n        .with_label(span)\n}","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vue/valid_define_props.rs#L1-L32","documentation":"Diagnostic from the oxlint rule `vue/valid-define-props` (crates/oxc_linter/src/rules/vue/valid_define_props.rs). The rule delegates each `defineProps` call to the shared helper `check_define_macro_call_expression`; when the call has BOTH a literal type parameter (type-only declaration) and a runtime argument, the helper returns `DefineMacroProblem::HasTypeAndArguments`. Passing both makes the runtime argument win and silently discards the type-only declaration, degrading type inference.","triggerScenarios":"A `defineProps` call (VueSetup framework option) shaped like `defineProps<{ msg?: string }>({ msg: String })` — i.e. `call.type_arguments` present AND at least one runtime argument. Reported on the whole call span with help 'remove the argument for better type inference.'","commonSituations":"Migrating a runtime-props component to type-based props and forgetting to delete the old object argument; merging tutorial snippets that use both styles; refactors where a defaults object was pasted next to a newly added type parameter.","solutions":["Delete the runtime argument and keep the type-only form: `defineProps<{ msg?: string }>()`.","If you need prop defaults with types, use `withDefaults(defineProps<{ msg?: string }>(), { msg: 'hi' })` instead of a second argument.","If the runtime object is the source of truth, drop the type parameter instead: `defineProps({ msg: String })`."],"exampleFix":"// before\n<script setup lang=\"ts\">\ndefineProps<{ msg?: string }>({ msg: String })\n</script>\n\n// after\n<script setup lang=\"ts\">\ndefineProps<{ msg?: string }>()\n</script>","handlingStrategy":"validation","validationCode":"if (/\\bdefineProps\\s*<[^>]*>\\s*\\(\\s*\\S/.test(src)) {\n  throw new Error('defineProps has both a type parameter and a runtime argument — remove one');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one declaration style per component: type-only or runtime object, never both.","Use withDefaults(defineProps<T>(), {...}) for defaults instead of adding a second argument."],"tags":["vue","typescript","script-setup","compiler-macro","defineprops","lint"],"backgroundTag":"vue-script-setup-macro-misuse","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}