Skip to content

isBoolean

Jason Godesky edited this page Aug 15, 2026 · 2 revisions

isBoolean is a type guard that lets Typescript know that the variable passed in is a boolean.

Parameters

candidate: unknown

Supply any variable to test if it’s a boolean or not.

Returns

A type predicate for a boolean (candidate is boolean).

Examples

import { isBoolean } from '@revolutionarygamesco/common'

isBoolean(true) // true
isBoolean(false) // true
isBoolean(1 + 1 === 2) // true
isBoolean('true') // false
isBoolean(0) // false
isBoolean({ a: true }) // false

Clone this wiki locally