tripleSlashReferences
Reports triple-slash reference directives.
✅ This rule is included in the ts logical presets.
Triple-slash reference directives (/// <reference />) are an older TypeScript feature for declaring dependencies between files.
With modern ECMAScript modules and tsconfig.json configuration, these directives are rarely needed.
This rule reports on uses of triple-slash references.
Examples
Section titled “Examples”/// <reference path="./types.d.ts" />export const value = 1;/// <reference types="node" />const path = require("path");import type { MyType } from "./types";export const value: MyType = 1;import * as path from "path";Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”In some cases, triple-slash directives are still necessary:
- When working with global type augmentations in a codebase not set up with
tsconfig.jsonfile inclusions - When a file needs to reference a specific declaration file that cannot be resolved through normal module resolution
- When using
/// <reference lib="..." />for lib references in a codebase that overrides them
You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.