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

```ts
function map<KeyType, ValueType>(
  key: ValidateMapKeyType<KeyType>,
  value: ValidateMapValueType<ValueType>,
): MapType<KeyType, ValueType>;
```

Defined in: [packages/common/src/Type.ts:8305](https://github.com/evoluhq/evolu/blob/f0109fb501a593010e858e39248dde1200eeb2d7/packages/common/src/Type.ts#L8305)

Map [Type](https://evolu.dev/docs/api-reference/common/Type/interfaces/Type) whose keys and values must match their respective Types.

Maps from this or another realm are accepted. A Map must have no own
properties; its entries are validated in iteration order. When distinct input
keys decode to the same output key, validation fails instead of discarding
one associated value. Classification uses the realm-neutral object tag under
Evolu Type's trusted JavaScript policy.

### Example

```ts

const Scores = map(String, PositiveInt);
const scores = new Map([
  ["Ada", 10],
  ["Grace", 20],
]);

assertOk(Scores.fromUnknown(scores), scores);
```