Skip to content

Commit

Permalink
chore: use generic parameter instead of satisfies in changeset
Browse files Browse the repository at this point in the history
Promote the use of a generic parameter of `cache.modify` over using
`satisfies` which requires importing the `Modifers` type.
  • Loading branch information
Gelio committed Jun 12, 2023
1 parent 4c12626 commit 18e8bf9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions .changeset/afraid-zebras-punch.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"@apollo/client": minor
---

Add generic type parameter for the cache `Modifiers` type. Improves TypeScript
type inference for that type's fields and values of those fields.
Add generic type parameter for the entity modified in `cache.modify`. Improves
TypeScript type inference for that type's fields and values of those fields.

Example:

```ts
cache.modify({
cache.modify<Book>({
id: cache.identify(someBook),
fields: {
title: (title) => {
Expand All @@ -19,9 +19,6 @@ cache.modify({
// author has type `Reference | Book["author"]`.
// It used to be `any`.
},
} satisfies Modifiers<Book>,
},
});
```

To take advantage of the type inference, use [the `satisfies Modifiers<...>`
operator](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html).

0 comments on commit 18e8bf9

Please sign in to comment.