{"record":{"id":"21e99b61a405e248","repo":"oxc-project/oxc","slug":"parameter-name-is-declared-but-only-used-as-a","errorCode":null,"errorMessage":"Parameter '{name}' is declared but only used as a type.{suffix}","messagePattern":"Parameter '(.+?)' is declared but only used as a type\\.(.+?)","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/no_unused_vars/diagnostic.rs","lineNumber":126,"sourceCode":"\n/// Parameter 'x' is declared but never used.\npub fn param<R>(\n    symbol: &Symbol<'_, '_>,\n    pat: &IgnorePattern<R>,\n    only_used_as_type: bool,\n) -> OxcDiagnostic\nwhere\n    R: fmt::Display,\n{\n    let name = symbol.name();\n    let suffix = if name == \"_\" && pat.is_default() {\n        std::borrow::Cow::Borrowed(\"\")\n    } else {\n        pat.diagnostic_help(\"parameters\")\n    };\n\n    OxcDiagnostic::warn(if only_used_as_type {\n        format!(\"Parameter '{name}' is declared but only used as a type.{suffix}\")\n    } else {\n        format!(\"Parameter '{name}' is declared but never used.{suffix}\")\n    })\n    .with_label(symbol.span().label(format!(\"'{name}' is declared here\")))\n    .with_help(\"Consider removing this parameter.\")\n}\n\n/// Identifier 'x' imported but never used.\npub fn imported(symbol: &Symbol<'_, '_>) -> OxcDiagnostic {\n    let (pronoun, _) = pronoun_for_symbol(symbol.flags());\n    let name = symbol.name();\n\n    OxcDiagnostic::warn(format!(\"{pronoun} '{name}' is imported but never used.\"))\n        .with_label(symbol.span().label(format!(\"'{name}' is imported here\")))\n        .with_help(\"Consider removing this import.\")\n}\n","sourceCodeStart":108,"sourceCodeEnd":143,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_unused_vars/diagnostic.rs#L108-L143","documentation":"no-unused-vars parameter variant: a function parameter's only references are in type positions, so it is unused as a value. The suffix is suppressed for the exact name '_' under the default pattern; otherwise ignore-pattern guidance is appended.","triggerScenarios":"function handler(event: Event) where the body only uses it as type E = typeof event; callback parameters kept for the signature but only referenced in annotations.","commonSituations":"TypeScript inference helpers; callbacks whose parameters exist to satisfy a signature; refactors that moved value uses out but left type aliases behind.","solutions":["Remove the parameter (and update call sites) when it serves no purpose.","Rename to _name or _ so it matches the default argsIgnorePattern convention.","Re-derive the type from the annotation instead of the parameter: type E = Event.","Adjust argsIgnorePattern in the rule options for project-wide conventions."],"exampleFix":"// before\nfunction handler(event: Event) {\n  type E = typeof event;\n  register<E>();\n}\n// after\ntype E = Event;\nfunction handler() { register<E>(); }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive types from annotations (type E = Event) instead of from parameters (typeof event).","Rename type-only-unused params to _name to match argsIgnorePattern.","Remove parameters whose only purpose was feeding type aliases."],"tags":["eslint","oxlint","unused-vars","parameters","typescript"],"backgroundTag":"unused-parameter-type-only","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}