Skip to content

no-ts-suppression ​

A comment that switches TypeScript's own checks off: // @ts-nocheck (the whole file), // @ts-ignore (the next line), or // @ts-expect-error with no reason after it. On by default, as an error.

Why: Result, Option, Enum and the brands are types. They hold only where TypeScript checks them: under @ts-ignore, value.name on an unknown, an Option passed where a value is wanted, or a missing match arm all compile. @ts-ignore also stays when the error it was for is gone, and then hides the next, different one on that line. TypeScript's own advice is @ts-expect-error, which fails once there is no error to expect. A reason says which error is expected and why the line is fine, which is what a reviewer goes by.

❌ Rejected: the cast TypeScript would refuse, hidden

✕ Rejectedno-ts-suppression
ts
export function nameOf(value: unknown): string {
  // @ts-ignore
  return value.name;
}

❌ Rejected: an expected error, without saying which

✕ Rejectedno-ts-suppression
ts
export function scaled(n: number): number {
  // @ts-expect-error
  const scale: number = "2";
  return n * scale;
}

✅ Accepted: the value is checked, so nothing needs silencing

✓ Accepted0 diagnostics
ts
import { type JsonError, validate } from "@evobug_com/safe-ts-std/json";
import { q, type Result } from "@evobug_com/safe-ts-std/result";

type User = { readonly id: string; readonly name: string };

export function nameOf(value: unknown): Result<string, JsonError> {
  const user = q(validate<User>(value));
  return user.name;
}
ts
import { parseJsonWith as __jsonParse, validateWith as __jsonValidate, jsonFail as __jsonFail, isJsonErr as __jsonIsErr, isJsonObject as __jsonIsObject, type JsonResult as __JsonResult } from "@evobug_com/safe-ts-std/json"; import { type JsonError, validate } from "@evobug_com/safe-ts-std/json";
import { Err as __qErr } from "@evobug_com/safe-ts-std/result"; import { q, type Result } from "@evobug_com/safe-ts-std/result";

type User = { readonly id: string; readonly name: string };

export function nameOf(value: unknown): Result<string, JsonError> {
  const __q1 = __jsonValidate<User>(value, __v0); if (__q1 instanceof __qErr) return __q1; const user = __q1;
  return user.name;
}
// ---- generated by safe-ts: JSON validators ----
type __T0 = { "id": string; "name": string; };
function __v0(v: unknown, p: string): __JsonResult<__T0> {
  if (!__jsonIsObject(v)) return __jsonFail(p, "object", v);
  const __j1 = v["id"];
  if (typeof __j1 !== "string") return __jsonFail(p + ".id", "string", __j1);
  const __j2 = __j1;
  const __j3 = v["name"];
  if (typeof __j3 !== "string") return __jsonFail(p + ".name", "string", __j3);
  const __j4 = __j3;
  const out: { "id": string; "name": string; } = { "id": __j2, "name": __j4 };
  return out;
}

✅ Also accepted: one line TypeScript can't type yet, with the reason

✓ Accepted0 diagnostics
ts
export function scaled(n: number): number {
  // @ts-expect-error: the legacy config declares `scale` as a number and stores a string; `*` converts it
  const scale: number = "2";
  return n * scale;
}

Each of the three comments is counted in safe-ts check's escape-hatch line (and in --json --summary, escapeHatches), the accepted @ts-expect-error <reason> too, and a baseline holds the counts down.

Test files ​

In a test file (*.test.*, *.spec.*, a file in a test, tests, __tests__ or __mocks__ directory of its package, or one importing a test runner; see test-only-helper), // @ts-expect-error <reason> is how a compile-time test says "this must not compile": tsc fails the test once the line compiles. So those are counted apart, as @ts-expect-error (and N in test files) (testExpectErrors in the JSON). A test file's @ts-ignore, @ts-nocheck and reasonless @ts-expect-error are reported like any other.

What counts ​

  • @ts-ignore and @ts-expect-error where TypeScript reads them: right after // (or ///), at the end of a line of code too, or at the start of the last line of a /* */ comment (/* @ts-ignore */, a JSDoc block whose last line is * @ts-expect-error */). As in TypeScript, the name is a prefix: @ts-ignored is an @ts-ignore.
  • @ts-nocheck in a // comment before the first statement, in any case (// @TS-NOCHECK). TypeScript 5 and 7 ignore it in a block comment and after the first statement, and so does the rule. In a Vue component, anywhere in its <script>.
  • A reason is any text after the name (: why, -- why, why), or above it in the same block comment.
  • In a Vue template, vue-tsc's own comments: <!-- @vue-ignore --> (counted with @ts-ignore, reported), <!-- @vue-expect-error <reason> --> (counted with @ts-expect-error, reported without a reason) and <!-- @vue-skip --> (the element and everything inside it unchecked: counted as @vue-skip comment(s), vueSkips in the JSON, reported).
  • Not in // @safe-ts legacy and // @safe-ts std files, which are counted whole.

Quick fix ​

Use @ts-expect-error on a @ts-ignore that already says why: the name is replaced, the reason stays. A @ts-ignore without a reason gets no fix, since the result would need one.

What the rule can't see ​

  • Whether the reason is true. It only has to be there.
  • skipLibCheck, strict: false or other compiler options: tsconfig.json is the project's.

Related: safe-ts-ignore, SAFE-TS's own ignore comment, which works the same way: a rule and a reason. Guide: Escape hatches.

MIT OR Apache-2.0 · Docs by Gemini 4 Neon Extra