[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) › typed

## Call Signature

```ts
function typed<Tag>(
  tag: ValidateTypedTag<Tag>,
): StrictObjectType<TypedProps<Tag, Readonly<Record<never, never>>>>;
```

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

Creates an [ObjectType](https://evolu.dev/docs/api-reference/common/Type/type-aliases/ObjectType) with a literal `type` property.

The discriminator belongs to `typed`, so additional properties cannot declare
`type`. The discriminator Input is `string`, inherited from [String](https://evolu.dev/docs/api-reference/common/Type/variables/String),
while its Output is the exact tag. Without a third argument, additional
properties are rejected. Pass a [record](https://evolu.dev/docs/api-reference/common/Type/functions/record) with the predefined `String`
key Type as the third argument to validate and preserve additional
string-keyed properties, just like [object](https://evolu.dev/docs/api-reference/common/Type/functions/object).

### Example

```ts
import {
  assertFalse,
  assertOk,
  assertType,
  String,
  discriminatedUnion,
  typed,
} from "@evolu/common";

const Loading = typed("Loading");
const Loaded = typed("Loaded", { value: String });
const State = discriminatedUnion(Loading, Loaded);

assertOk(State.fromUnknown({ type: "Loading" }), { type: "Loading" });
assertOk(State.fromUnknown({ type: "Loaded", value: "Evolu" }), {
  type: "Loaded",
  value: "Evolu",
});
assertFalse(Loading.is({ type: "Loading", progress: 1 }));
assertType<
  true,
  typeof Loading.Output extends { readonly type: "Loading" } ? true : false
>();
```

## Call Signature

```ts
function typed<Tag, Props>(
  tag: ValidateTypedTag<Tag>,
  props: Props,
  ...validation: [TypedValidationError<Props>] extends [never]
    ? []
    : [ValidationFailure<TypedValidationError<Props>>]
): StrictObjectType<TypedProps<Tag, Props>>;
```

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

Creates a Tagged Object Type with declared properties.

### Example

```ts

const Pending = typed("Pending", {
  label: String,
});

assertOk(Pending.fromUnknown({ type: "Pending", label: "Waiting" }), {
  type: "Pending",
  label: "Waiting",
});
```

## Call Signature

```ts
function typed<Tag, Props, Rest>(
  tag: ValidateTypedTag<Tag>,
  props: Props,
  record: Rest,
  ...validation: [
    | TypedValidationError<Props>
    | ObjectRecordValidationError<TypedProps<Tag, Props>, Rest>,
  ] extends [never]
    ? []
    : [
        ValidationFailure<
          | TypedValidationError<Props>
          | ObjectRecordValidationError<TypedProps<Tag, Props>, Rest>
        >,
      ]
): ObjectType<
  TypedProps<Tag, Props>,
  Rest extends ObjectRecordTypeNode ? Rest : never
>;
```

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

Creates a Tagged Object Type with additional record properties.

### Example

```ts

const Open = typed("Open", { label: String }, record(String, String));
const result = Open.fromUnknown({
  type: "Open",
  label: "Ready",
  note: "Connected",
});

assertOk(result, {
  type: "Open",
  label: "Ready",
  note: "Connected",
});
assertType<string | undefined, typeof result.value.note>();
```