Skip to content

Commit bd34f1e

Browse files
christianalfonigitbook-bot
authored andcommitted
GitBook: [v23] one page modified
1 parent 4b630f8 commit bd34f1e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

core/typescript.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,30 @@ export const state: State = {
170170
{% endtab %}
171171
{% endtabs %}
172172

173+
Note that the type argument you pass is the object the derived is attached to, so with nested derived:
174+
175+
{% tabs %}
176+
{% tab title="overmind/state.ts" %}
177+
```typescript
178+
importderived } from 'overmind'
179+
180+
type State = {
181+
foo: string
182+
nested: {
183+
shoutedFoo string
184+
}
185+
}
186+
187+
export const state: State = {
188+
foo: 'bar',
189+
nested: {
190+
shoutedFoo: derived<State['nested']>(state => state.foo + '!!!')
191+
}
192+
}
193+
```
194+
{% endtab %}
195+
{% endtabs %}
196+
173197
## Actions
174198

175199
The action type takes either an input type, an output type, or both.

0 commit comments

Comments
 (0)