[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Type](https://evolu.dev/docs/api-reference/common/Type) › assertType

## Call Signature

```ts
function assertType<Expected, Actual>(
  ...error: IsSameType<Expected, Actual> extends true
    ? []
    : ["⛔ assertType error: Expected and actual types must be identical"]
): void;
```

Defined in: [packages/common/src/Type.ts:1073](https://github.com/evoluhq/evolu/blob/037c390af081e9944d616ff298a729515c5c5ab7/packages/common/src/Type.ts#L1073)

Asserts exact compile-time type equality or that a value belongs to a
[Type](https://evolu.dev/docs/api-reference/common/Type/interfaces/Type) Output domain.

- `assertType<Expected, Actual>()` requires compiler-identical types without
  evaluating a value.
- `assertType(type, value)` validates and narrows a runtime value to the Type's
  Output.

Use the runtime form for internal invariants, not external input. Validate
external input with `Type.fromUnknown` so validation failures remain typed
values. A failed runtime assertion uses the Type name for its message and
preserves the exact Output validation error as the thrown Error's cause.

### Example

```ts
import {
  NonEmptyTrimmedString100,
  assertType,
  type Brand,
} from "@evolu/common";

const value: unknown = "Evolu";
assertType(NonEmptyTrimmedString100, value);
assertType<
  string & Brand<"Trimmed"> & Brand<"MinLength1"> & Brand<"MaxLength100">,
  typeof value
>();
```

## Call Signature

```ts
function assertType<T>(type: T, value: unknown): asserts value is T["Output"];
```

Defined in: [packages/common/src/Type.ts:1083](https://github.com/evoluhq/evolu/blob/037c390af081e9944d616ff298a729515c5c5ab7/packages/common/src/Type.ts#L1083)

Asserts exact compile-time type equality or that a value belongs to a
[Type](https://evolu.dev/docs/api-reference/common/Type/interfaces/Type) Output domain.

- `assertType<Expected, Actual>()` requires compiler-identical types without
  evaluating a value.
- `assertType(type, value)` validates and narrows a runtime value to the Type's
  Output.

Use the runtime form for internal invariants, not external input. Validate
external input with `Type.fromUnknown` so validation failures remain typed
values. A failed runtime assertion uses the Type name for its message and
preserves the exact Output validation error as the thrown Error's cause.

### Example

```ts
import {
  NonEmptyTrimmedString100,
  assertType,
  type Brand,
} from "@evolu/common";

const value: unknown = "Evolu";
assertType(NonEmptyTrimmedString100, value);
assertType<
  string & Brand<"Trimmed"> & Brand<"MinLength1"> & Brand<"MaxLength100">,
  typeof value
>();
```