TypeScript Syntax

@ts-expect-error — expect a next-line diagnostic

Suppresses diagnostics on the next line and reports an unused directive when no diagnostic occurs there. It is useful for selected negative tests, but does not by itself establish a particular diagnostic code or cause. The example deliberately accepts a wrong assignment only to demonstrate the directive. Observed output: 'string'. Local verification: TypeScript 5.8.3, strict mode, ES2022, CommonJS, Node.js 22.16.0. Disposable library declarations are enabled for the fixture suite.

Formal Syntax & Structure

typescript syntaxtypescript
// @ts-expect-errorstatement

Working Example

Example Snippettypescript
// @ts-expect-errorconst count: number = "ready";console.log(typeof count);
TypeScript Reference