TypeScript Types

boolean — truth values

A boolean annotation allows true and false; a truthy string or a numeric 1 is not a boolean. JavaScript still performs truthiness conversion in conditions, but assigning a non-boolean value to a boolean binding is a separate static check. Use explicit comparison when the result should describe a condition. Example output: "true". The example was designed for strict checking with an ES2022 target; type annotations do not add runtime validation.

Formal Syntax & Structure

typescript syntaxtypescript
let flag: boolean;

Working Example

Example Snippettypescript
const complete: boolean = 3 > 1;console.log(complete);
TypeScript Reference