Skip to content

Commit 28bac43

Browse files
docs(website): update typing docs and add typescript guide
1 parent cdcee9e commit 28bac43

File tree

15 files changed

+131
-21
lines changed

15 files changed

+131
-21
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
TOperator,
2020
TReaction,
2121
TValueContext,
22+
TOnInitialize,
2223
} from './types'
2324

2425
export * from './types'
@@ -41,9 +42,7 @@ export type Derive<Parent extends object, Value> = TDerive<
4142

4243
export type Reaction = TReaction<TheConfig>
4344

44-
export type OnInitialize = (
45-
context: TValueContext<TheConfig, ResolveActions<TheConfig['actions']>>
46-
) => void
45+
export type OnInitialize = TOnInitialize<TheConfig>
4746

4847
const isPlainObject = require('is-plain-object')
4948
const IS_PRODUCTION = process.env.NODE_ENV === 'production'

packages/node_modules/overmind/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ export type TReaction<Config extends Configuration> = (
5656
action: TAction<Config, void> | TOperator<Config, void, any>
5757
) => any
5858
) => any
59+
60+
export type TOnInitialize<Config extends Configuration> = (
61+
context: TValueContext<Config, ResolveActions<Config['actions']>>
62+
) => void

packages/overmind-website/examples/api/config_merge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default (ts, view) =>
44
{
55
fileName: 'app.ts',
66
code: `
7-
import { Overmind, TApp } from 'overmind'
7+
import { Overmind, TConfig } from 'overmind'
88
import { merge } from 'overmind/config'
99
import * as moduleA from './moduleA'
1010
import * as moduleB from './moduleB'
@@ -15,7 +15,7 @@ const config = merge({
1515
})
1616
1717
declare module 'overmind' {
18-
interface IApp extends TApp<typeof config> {}
18+
interface IConfig extends TConfig<typeof config> {}
1919
}
2020
2121
const app = new Overmind(config)

packages/overmind-website/examples/api/config_namespaced.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default (ts, view) =>
44
{
55
fileName: 'app.ts',
66
code: `
7-
import { Overmind, TApp } from 'overmind'
7+
import { Overmind, TConfig } from 'overmind'
88
import { namespaced } from 'overmind/config'
99
import * as moduleA from './moduleA'
1010
import * as moduleB from './moduleB'
@@ -15,7 +15,7 @@ const config = namespaced({
1515
})
1616
1717
declare module 'overmind' {
18-
interface IApp extends TApp<typeof config> {}
18+
interface IConfig extends TConfig<typeof config> {}
1919
}
2020
2121
const app = new Overmind(config)

packages/overmind-website/examples/guide/routing/router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default (ts, view) =>
44
{
55
fileName: 'app/actions.ts',
66
code: `
7-
import { Overmind, TApp } from 'overmind'
7+
import { Overmind, TConfig } from 'overmind'
88
import { createConnect, TConnect } from 'overmind-${view}'
99
import * as page from 'page'
1010
import { state } from './state'
@@ -18,7 +18,7 @@ const config = {
1818
}
1919
2020
declare module 'overmind' {
21-
interface App extends TApp<typeof config> {}
21+
interface IConfig extends TConfig<typeof config> {}
2222
}
2323
2424
export const app = new Overmind(config)

packages/overmind-website/examples/guide/structuringtheapp/namespaced.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default (ts, view) =>
44
{
55
fileName: 'app/index.ts',
66
code: `
7-
import { Overmind, TApp } from 'overmind'
7+
import { Overmind, TConfig } from 'overmind'
88
import { namespaced } from 'overmind/config'
99
import * as posts from './posts'
1010
import * as admin from './admin'
@@ -15,7 +15,7 @@ const config = namespaced({
1515
})
1616
1717
declare module 'overmind' {
18-
interface IApp extends TApp<typeof config> {}
18+
interface IConfig extends TConfig<typeof config> {}
1919
}
2020
2121
const app = new Overmind(config)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default () => [
2+
{
3+
code: `
4+
import { TConfig } from 'overmind'
5+
6+
const config = {}
7+
8+
declare module 'overmind' {
9+
interface IConfig extends TConfig<typeof config> {}
10+
}
11+
`,
12+
},
13+
]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export default () => [
2+
{
3+
code: `
4+
import {
5+
Action,
6+
Operator,
7+
Reaction,
8+
Derive,
9+
pipe,
10+
map,
11+
filter,
12+
...
13+
} from 'overmind'
14+
`,
15+
},
16+
]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
export default () => [
2+
{
3+
code: `
4+
import {
5+
TConfig,
6+
TOnInitialize,
7+
TAction,
8+
TOperator,
9+
TDerive,
10+
TReaction
11+
} from 'overmind'
12+
13+
const config = {}
14+
15+
export type Config = TConfig<typeof config>
16+
17+
export type OnInitialize = TOnInitialize<Config>
18+
19+
export type Action<Input> = TAction<Config, Input>
20+
21+
export type Operator<Input, Output> = TOperator<Config, Input, Output>
22+
23+
export type Derive<Parent extends object, Output> = TDerive<Config, Parent, Output>
24+
25+
export type Reaction = TReaction<Config>
26+
`,
27+
},
28+
]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export default () => [
2+
{
3+
code: `
4+
import { pipe, map, run } from 'overmind'
5+
import { Config, Operator } from '../'
6+
7+
const toUpperCase = map<string, string, Config>(...)
8+
const doSomething = run<string, Config>(...)
9+
10+
export const doThis: Operator<string, string> = pipe(
11+
toUpperCase,
12+
doSomething
13+
)
14+
`,
15+
},
16+
]

0 commit comments

Comments
 (0)