Skip to content

Commit 6580ddf

Browse files
committed
refactor(overmind): use Config instead of App for generic types
This removes some confusion when we mixed resolved and unresolved types (App and Parent in Derive) for example.
1 parent d9baf31 commit 6580ddf

File tree

8 files changed

+159
-145
lines changed

8 files changed

+159
-145
lines changed

packages/node_modules/overmind-devtools/src/app/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Overmind, TApp } from 'overmind'
1+
import { Overmind, TConfig } from 'overmind'
22
import { TConnect, createConnect } from 'overmind-react'
33

44
import * as actions from './actions'
@@ -13,7 +13,7 @@ const config = {
1313
}
1414

1515
declare module 'overmind' {
16-
interface IApp extends TApp<typeof config> {}
16+
interface IConfig extends TConfig<typeof config> {}
1717
}
1818

1919
const app = new Overmind(config, {

packages/node_modules/overmind-react/src/index.test.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Overmind, TAction, TApp } from 'overmind'
1+
import { Overmind, TAction } from 'overmind'
22
import * as React from 'react'
33
import * as renderer from 'react-test-renderer'
44

@@ -19,18 +19,18 @@ describe('React', () => {
1919
},
2020
}
2121

22-
type IApp = TApp<{
22+
type IConfig = {
2323
state: {
2424
foo: typeof config.state.foo
2525
}
2626
actions: {
2727
doThis: typeof doThis
2828
}
29-
}>
29+
}
3030

3131
const app = new Overmind(config)
3232

33-
type Action<Input = void> = TAction<IApp, Input>
33+
type Action<Input = void> = TAction<IConfig, Input>
3434

3535
const connect = createConnect(app)
3636

@@ -58,18 +58,18 @@ describe('React', () => {
5858
},
5959
}
6060

61-
type IApp = TApp<{
61+
type IConfig = {
6262
state: {
6363
foo: typeof config.state.foo
6464
}
6565
actions: {
6666
doThis: typeof doThis
6767
}
68-
}>
68+
}
6969

7070
const app = new Overmind(config)
7171

72-
type Action<Input = void> = TAction<IApp, Input>
72+
type Action<Input = void> = TAction<IConfig, Input>
7373

7474
const connect = createConnect(app)
7575

@@ -130,18 +130,18 @@ describe('React', () => {
130130
doThis,
131131
},
132132
}
133-
type IApp = TApp<{
133+
type IConfig = {
134134
state: {
135135
foo: typeof config.state.foo
136136
}
137137
actions: {
138138
doThis: typeof doThis
139139
}
140-
}>
140+
}
141141

142142
const app = new Overmind(config)
143143

144-
type Action<Input = void> = TAction<IApp, Input>
144+
type Action<Input = void> = TAction<IConfig, Input>
145145

146146
const connect = createConnect(app)
147147

packages/node_modules/overmind/src/derived.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Overmind, TAction, TApp, TDerive } from './'
1+
import { Overmind, TAction, TDerive } from './'
22

33
type State = {
44
foo: string
@@ -19,11 +19,11 @@ describe('Derived', () => {
1919
state,
2020
}
2121

22-
type IApp = TApp<{
22+
type Config = {
2323
state: typeof state
24-
}>
24+
}
2525

26-
type Derive<Parent extends object, Value> = TDerive<IApp, Parent, Value>
26+
type Derive<Parent extends object, Value> = TDerive<Config, Parent, Value>
2727

2828
const app = new Overmind(config)
2929

@@ -48,15 +48,15 @@ describe('Derived', () => {
4848
changeFoo,
4949
},
5050
}
51-
type IApp = TApp<{
51+
type Config = {
5252
state: {
5353
foo: string
5454
upperFoo: string
5555
}
5656
actions: typeof config.actions
57-
}>
58-
type Action<Input = void> = TAction<IApp, Input>
59-
type Derive<Parent extends object, Value> = TDerive<IApp, Parent, Value>
57+
}
58+
type Action<Input = void> = TAction<Config, Input>
59+
type Derive<Parent extends object, Value> = TDerive<Config, Parent, Value>
6060

6161
const app = new Overmind(config)
6262
function render() {
@@ -92,15 +92,15 @@ describe('Derived', () => {
9292
changeFoo,
9393
},
9494
}
95-
type IApp = TApp<{
95+
type Config = {
9696
state: {
9797
foo: string
9898
upperFoo: string
9999
}
100100
actions: typeof config.actions
101-
}>
102-
type Action<Input = void> = TAction<IApp, Input>
103-
type Derive<Parent extends object, Value> = TDerive<IApp, Parent, Value>
101+
}
102+
type Action<Input = void> = TAction<Config, Input>
103+
type Derive<Parent extends object, Value> = TDerive<Config, Parent, Value>
104104

105105
const app = new Overmind(config)
106106

@@ -125,15 +125,15 @@ describe('Derived', () => {
125125
changeFoo,
126126
},
127127
}
128-
type IApp = TApp<{
128+
type Config = {
129129
state: {
130130
foo: string
131131
upperFoo: string
132132
}
133133
actions: typeof config.actions
134-
}>
135-
type Action<Input = void> = TAction<IApp, Input>
136-
type Derive<Parent extends object, Value> = TDerive<IApp, Parent, Value>
134+
}
135+
type Action<Input = void> = TAction<Config, Input>
136+
type Derive<Parent extends object, Value> = TDerive<Config, Parent, Value>
137137

138138
const app = new Overmind(config)
139139

packages/node_modules/overmind/src/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EventType, Overmind, TAction, TApp } from './'
1+
import { EventType, Overmind, TAction } from './'
22
import { namespaced } from './config'
33

44
function toJSON(obj) {
@@ -60,12 +60,12 @@ function createDefaultApp() {
6060
effects,
6161
}
6262

63-
type App = TApp<{
63+
type Config = {
6464
state: typeof state
6565
actions: typeof actions
6666
effects: typeof effects
67-
}>
68-
type Action<Value = void> = TAction<App, Value>
67+
}
68+
type Action<Value = void> = TAction<Config, Value>
6969

7070
return new Overmind(config)
7171
}

0 commit comments

Comments
 (0)