oxc-project/oxc · warning · OxcDiagnostic

{pronoun} is {verb} but only used as a type.{suffix}

Error message

{pronoun} is {verb} but only used as a type.{suffix}

What it means

Diagnostic of no-unused-vars: the binding's only references are in type positions (TS type annotations, typeof types, interfaces), so it is unused as a runtime value. {verb} is 'declared' for normal bindings or 'caught' for catch parameters; {suffix} appends ignore-pattern guidance.

Source

Thrown at crates/oxc_linter/src/rules/eslint/no_unused_vars/diagnostic.rs:80

pub fn declared<R>(
    symbol: &Symbol<'_, '_>,
    pat: &IgnorePattern<R>,
    only_used_as_type: bool,
) -> OxcDiagnostic
where
    R: fmt::Display,
{
    let (verb, help) = if symbol.flags().is_catch_variable() {
        ("caught", "Consider handling this error.")
    } else {
        ("declared", "Consider removing this declaration.")
    };
    let name = symbol.name();
    let (pronoun, pronoun_plural) = pronoun_for_symbol(symbol.flags());
    let suffix = pat.diagnostic_help(pronoun_plural);

    OxcDiagnostic::warn(if only_used_as_type {
        format!("{pronoun} is {verb} but only used as a type.{suffix}")
    } else {
        format!("{pronoun} '{name}' is {verb} but never used.{suffix}")
    })
    .with_label(symbol.span().label(format!("'{name}' is declared here")))
    .with_help(help)
}

/// Variable 'x' is assigned a value but never used.
pub fn assign<R>(
    symbol: &Symbol<'_, '_>,
    assign_span: Span,
    pat: &IgnorePattern<R>,
) -> OxcDiagnostic
where
    R: fmt::Display,
{
    let name = symbol.name();
    let (pronoun, pronoun_plural) = pronoun_for_symbol(symbol.flags());

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove the runtime declaration and express the type directly (e.g. export type Greeting = 'hello').
  2. For imports used only as types, switch to import type { X }.
  3. If intentional, match it with varsIgnorePattern or prefix the name with an underscore.

Example fix

// before
const Greeting = 'hello';
type G = typeof Greeting;
// after
export type Greeting = 'hello';
type G = Greeting;
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: const Greeting = 'hello'; referenced only via type T = typeof Greeting; a catch parameter only used inside a type annotation; type-level constants whose value is never read.

Common situations: Migrating value constants to type-only usage during a TS refactor; codegen emitting runtime constants only consumed by types; keeping values around after switching to literal types.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/18b749631e0f778f. Report an issue: GitHub.