{"record":{"id":"ae2520395e13dac0","repo":"oxc-project/oxc","slug":"defineoptions-cannot-accept-type-arguments","errorCode":null,"errorMessage":"`defineOptions()` cannot accept type arguments.","messagePattern":"`defineOptions\\(\\)` cannot accept type arguments\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vue/valid_define_options.rs","lineNumber":36,"sourceCode":"}\n\nfn multiple_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`defineOptions` has been called multiple times.\").with_label(span)\n}\n\nfn not_defined_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Options are not defined.\").with_label(span)\n}\n\nfn disallow_prop_diagnostic(span: Span, prop_name: &str, instead_macro: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"`defineOptions()` cannot be used to declare `{prop_name}`. Use `{instead_macro}()` instead.\"\n    ))\n    .with_label(span)\n}\n\nfn type_args_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`defineOptions()` cannot accept type arguments.\").with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct ValidDefineOptions;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforce valid use of the `defineOptions` compiler macro.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// `defineOptions` is a compiler macro for `<script setup>`. It must be called\n    /// with a single object literal containing component options that are evaluable\n    /// at compile time. Misuse such as referencing locally declared variables,\n    /// declaring `props`/`emits`/`expose`/`slots`, calling without arguments, or\n    /// passing type arguments cannot be processed by the compiler.\n    ///","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vue/valid_define_options.rs#L18-L54","documentation":"Diagnostic from the oxlint rule `vue/valid-define-options`. In `check_call`, if `call.type_arguments` is present the rule reports that `defineOptions()` cannot accept type arguments. Unlike `defineProps`/`defineEmits`, `defineOptions` has no type-parameter form in the Vue compiler — passing `defineOptions<{...}>()` is a compile error because the compiler macro signature only takes a runtime object literal.","triggerScenarios":"A .vue file (VueSetup) containing `defineOptions<SomeType>()` — i.e. the call has a `<...>` type argument list, regardless of whether a runtime argument follows. Typical case: `<script setup lang=\"ts\"> defineOptions<{ name: 'Foo' }>() </script>`. The diagnostic span is the type-arguments span.","commonSituations":"Developers who know `defineProps<T>()`/`defineEmits<T>()` assume `defineOptions<T>()` follows the same pattern; IDE autocomplete inserting type parameters; porting type-driven code from `defineProps` style.","solutions":["Remove the type argument list and pass the options as a runtime object literal: `defineOptions({ name: 'Foo' })`.","If you wanted typed props, switch to `defineProps<{ msg?: string }>()` instead of `defineOptions`.","If you need the object typed, annotate a separate const in a sibling `<script>` block or cast values (`as`) inside the object literal."],"exampleFix":"// before\n<script setup lang=\"ts\">\ndefineOptions<{ name: 'Foo' }>()\n</script>\n\n// after\n<script setup lang=\"ts\">\ndefineOptions({ name: 'Foo' })\n</script>","handlingStrategy":"validation","validationCode":"if (/\\bdefineOptions\\s*</.test(src)) {\n  throw new Error('defineOptions cannot take type arguments — pass a runtime object literal');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember only defineProps/defineEmits (and withDefaults) have type-parameter forms; defineOptions does not.","Enable vue/valid-define-options in the editor so the mistake is flagged as you type."],"tags":["vue","typescript","script-setup","compiler-macro","defineoptions","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"}