# Function: assertCondition()

> **assertCondition**(`condition`, `message?`): `asserts condition`

Defined in: [helpers/ensure.ts:79](https://github.com/coda/packs-sdk/blob/deb4919caa7d1b65e0f43e2f143683f797b50a5f/helpers/ensure.ts#L79)

Helper to apply a TypeScript assertion to subsequent code. TypeScript can infer type information from many expressions, and this helper applies those inferences to all code that follows call to this function.

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions

## Example

```
function foo(value: string | number) {
  assertCondition(typeof value === 'string');
  // TypeScript would otherwise complain, because `value` could have been number,
  // but the above assertion refines the type based on the `typeof` expression.
  return value.toUpperCase();
}
```

## Parameters

| Parameter | Type | | --- | --- | | `condition` | `any` | | `message?` | `string` |

## Returns

`asserts condition`
