oxc-project/oxc · warning · OxcDiagnostic
Parameter '{name}' is declared but only used as a type.{suff
Error message
Parameter '{name}' is declared but only used as a type.{suffix} What it means
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.
Source
Thrown at crates/oxc_linter/src/rules/eslint/no_unused_vars/diagnostic.rs:126
/// Parameter 'x' is declared but never used.
pub fn param<R>(
symbol: &Symbol<'_, '_>,
pat: &IgnorePattern<R>,
only_used_as_type: bool,
) -> OxcDiagnostic
where
R: fmt::Display,
{
let name = symbol.name();
let suffix = if name == "_" && pat.is_default() {
std::borrow::Cow::Borrowed("")
} else {
pat.diagnostic_help("parameters")
};
OxcDiagnostic::warn(if only_used_as_type {
format!("Parameter '{name}' is declared but only used as a type.{suffix}")
} else {
format!("Parameter '{name}' is declared but never used.{suffix}")
})
.with_label(symbol.span().label(format!("'{name}' is declared here")))
.with_help("Consider removing this parameter.")
}
/// Identifier 'x' imported but never used.
pub fn imported(symbol: &Symbol<'_, '_>) -> OxcDiagnostic {
let (pronoun, _) = pronoun_for_symbol(symbol.flags());
let name = symbol.name();
OxcDiagnostic::warn(format!("{pronoun} '{name}' is imported but never used."))
.with_label(symbol.span().label(format!("'{name}' is imported here")))
.with_help("Consider removing this import.")
}
View on GitHub (pinned to e1e7af627c)
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.
Example fix
// before
function handler(event: Event) {
type E = typeof event;
register<E>();
}
// after
type E = Event;
function handler() { register<E>(); } Defensive patterns
Strategy: validation
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: TypeScript inference helpers; callbacks whose parameters exist to satisfy a signature; refactors that moved value uses out but left type aliases behind.
Related errors
- {pronoun} is {verb} but only used as a type.{suffix}
- Parameter '{name}' is declared but never used.{suffix}
- Default parameters should be last
- Function '{}' has too many parameters ({}). Maximum allowed
- Function has too many parameters ({}). Maximum allowed is {}
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/21e99b61a405e248.
Report an issue: GitHub.