Skip to content

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.

/// <reference path="./types.d.ts" />
export const value = 1;
/// <reference types="node" />
const path = require("path");

This rule is not configurable.

In some cases, triple-slash directives are still necessary:

  • When working with global type augmentations in a codebase not set up with tsconfig.json file 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.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.