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

```ts
type RefinementWithIndex<A, B> = (a: A, index: number) => a is B;
```

Defined in: [packages/common/src/Types.ts:113](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Types.ts#L113)

A type guard function that refines type `A` to a narrower type `B` at a given
index.

Useful for callbacks that need both the element and its position while
maintaining type narrowing.

### Example

```ts
type Item = { type: "number" | "string"; value: unknown };

const isNumberItem: RefinementWithIndex<Item, Item & { type: "number" }> =
  (item, index): item is Item & { type: "number" } =>
    index > 0 && item.type === "number";

const items: ReadonlyArray<Item> = [...];
const [numbers, others] = partitionArray(items, isNumberItem);
```