---
title: "ifExpr(): function in Authoring, TypeShade API reference"
description: "ifExpr, a function in Authoring. Two-arm value dispatch on a condition: ifExpr(cond, () => a, () => b)."
url: https://typeshade.dev/api/ifexpr/
language: en
---

# `ifExpr()` deprecated

Function in Authoring

Two-arm value dispatch on a condition: `ifExpr`(cond, () => a, () => b).

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

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

## Syntax

```ts
function ifExpr<K extends string>(
  cond: ReadonlyNode<'bool'>,
  thenVal: () => ReadonlyNode<K>,
  elseVal: () => ReadonlyNode<K>,
): Node<K>
```

## Parameters

**`cond` `ReadonlyNode<'bool'>`**

**`thenVal` `() => ReadonlyNode<K>`**

**`elseVal` `() => ReadonlyNode<K>`**

## Return value

`Node<K>`

## Source

[`src/core/ir/builder.ts`, line 1769](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/builder.ts#L1769), at commit af54ddad5
