oxc-project/oxc · error · OxcDiagnostic
Do not use a triple slash reference for {ref_kind}, use `imp
Error message
Do not use a triple slash reference for {ref_kind}, use `import` style instead. What it means
Raised by typescript/triple-slash-reference when a triple-slash directive (/// <reference .../>) is used for the given kind (types, path, or lib) instead of an ES import. Triple-slash references bypass module resolution tooling.
Source
Thrown at crates/oxc_linter/src/rules/typescript/triple_slash_reference.rs:16
use oxc_ast::ast::{Statement, TSModuleReference};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use rustc_hash::FxHashMap;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{
context::{ContextHost, LintContext},
rule::{DefaultRuleConfig, Rule},
utils::AlwaysNever,
};
fn triple_slash_reference_diagnostic(ref_kind: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("Do not use a triple slash reference for {ref_kind}, use `import` style instead."))
.with_help("Use of triple-slash reference type directives is generally discouraged in favor of ECMAScript Module imports.")
.with_label(span)
}
#[derive(Debug, Default, Clone, Deserialize)]
pub struct TripleSlashReference(Box<TripleSlashReferenceConfig>);
#[derive(Debug, Clone, Default, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct TripleSlashReferenceConfig {
/// What to enforce for `/// <reference lib="..." />` references.
lib: AlwaysNever,
/// What to enforce for `/// <reference path="..." />` references.
path: PathOption,
/// What to enforce for `/// <reference types="..." />` references.
types: TypesOption,
}
View on GitHub (pinned to e1e7af627c)
Solutions
- Replace the triple-slash reference with an import statement (import type / import).
- Use tsconfig types/lib options instead of /// <reference>.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/typescript/triple_slash_reference.rs:16 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/d09eadd836bf4f10.
Report an issue: GitHub.