TypeScript Syntax

@ts-check — opt a JavaScript file into checking

Enables checking for a JavaScript source file included in a TypeScript project, even without checkJs enabled globally. JSDoc can describe types without changing JavaScript runtime syntax. This fixture uses allowJs and checkJs false, and checks an invalid assignment in a separate negative file. JavaScript file with JSDoc; use allowJs and an output directory. Observed output: '4'. 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-check// JavaScript with JSDoc

Working Example

Example Snippettypescript
// @ts-check/** @type {number} */let count = 4;console.log(count);
TypeScript Reference