Skip to content

triple-slash-reference

Reports a /// <reference path="x" /> or /// <reference types="x" /> before the first statement of the file; for types only when the file also imports that module. A directive after the first statement is not reported.

Triple-slash references are the older way to include files and types before modules. An import states the dependency where it is used, is followed by bundlers and other tools, and does not depend on the order of directives.

To fix, replace the reference with an import (an import type where only types are needed).

Reported
/// <reference path="a.d.ts" />
/// <reference types="b" />
/// <reference types="c" />
/// <reference lib="es2020" />
import "b";
js:
lint:
rules:
triple-slash-reference: warn # off (default), warn, error

Enabled by the presets: js/typescript-eslint-recommended, js/oxlint.

Suppress one line with sudsy-disable-next-line triple-slash-reference in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
typescript-eslint triple-slash-reference partial the options (lib, path, types) keep their defaults