[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<Actual, Expected>(
  ...error: IsSameType<Actual, Expected> extends true
    ? []
    : ["⛔ assertType error: Actual and expected types must be identical"]
): void;
```

Defined in: [packages/common/src/Type.ts:1191](https://github.com/evoluhq/evolu/blob/dd96d79f1dbe9a49fa12ce8e0aa7d3d0177795ca/packages/common/src/Type.ts#L1191)

Asserts type equality or validates a value with a [Type](https://evolu.dev/docs/api-reference/common/Type/interfaces/Type).

- `assertType<Actual, Expected>()` requires compiler-identical types without
  evaluating a value. It is Evolu's platform-agnostic equivalent of Vitest's
  `expectTypeOf(...).toEqualTypeOf<...>()` and does not require a test
  runner.
- `assertType(type, value)` validates and narrows a runtime value to the Type's
  Output.

Use the runtime form for code-correctness invariants, not expected validation
failures. Validate external input with `Type.fromUnknown` so validation
failures remain typed values.

### Example

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

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

## Call Signature

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

Defined in: [packages/common/src/Type.ts:1201](https://github.com/evoluhq/evolu/blob/dd96d79f1dbe9a49fa12ce8e0aa7d3d0177795ca/packages/common/src/Type.ts#L1201)

Asserts type equality or validates a value with a [Type](https://evolu.dev/docs/api-reference/common/Type/interfaces/Type).

- `assertType<Actual, Expected>()` requires compiler-identical types without
  evaluating a value. It is Evolu's platform-agnostic equivalent of Vitest's
  `expectTypeOf(...).toEqualTypeOf<...>()` and does not require a test
  runner.
- `assertType(type, value)` validates and narrows a runtime value to the Type's
  Output.

Use the runtime form for code-correctness invariants, not expected validation
failures. Validate external input with `Type.fromUnknown` so validation
failures remain typed values.

### Example

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

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