---
title: "bool(): IR builder function in typeshade/core/ir, TypeShade"
description: "bool, an IR builder function in typeshade/core/ir. A bool literal node, the condition type for .select(), select() and control flow (If, While)."
url: https://typeshade.dev/api/bool/
language: en
---

# `bool()`

Function in Values

A bool literal node, the condition type for .select(), `select()` and control flow (If, While).

`import { bool } from 'typeshade/core/ir'`

This export returns an IR node. A `"use typeshade"` file calls the builtin itself: [`bool()`](https://typeshade.dev/reference/functions/bool/)

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
const bool: (v: boolean) => Node<"bool">
```

## Parameters

**`v` `boolean`**

## Return value

`Node<'bool'>`

## Exceptions

**`TypeError`**

`v` is not a JS boolean.

## Description

Only a JS boolean is accepted, so a stray `bool(someNode)` fails at the call site instead of coercing to `true`.

## Examples

### Example

```ts
import { bool } from 'typeshade/core/ir'

const flag = bool(true)  // Node<'bool'>
```

## In the guide

- [Values and mutation](https://typeshade.dev/guide/internals/values-and-mutation/)
- [Control flow](https://typeshade.dev/guide/internals/control-flow/)
- [The CPU oracle](https://typeshade.dev/guide/internals/the-cpu-oracle/)

## See also

- [`bool()`](https://typeshade.dev/reference/functions/bool/)

## Source

[`src/core/ir/node.ts`, line 879](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L879), at commit af54ddad5
