Skip to content

Commit b3b97bf

Browse files
fix(overmind-react): use typeof config to type provider createConnect
1 parent fa39f17 commit b3b97bf

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

packages/node_modules/overmind-react/src/index.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,24 @@ export const createHook = <Config extends IConfiguration>(
154154
}
155155
}
156156

157-
export const createConnect = <A extends Overmind<IConfiguration>>(
158-
overmindInstance?: A
157+
export const createConnect = <ThisConfig extends IConfiguration>(
158+
overmindInstance?: Overmind<ThisConfig>
159159
) => {
160160
return <Props>(
161161
component: IReactComponent<
162-
Props & { overmind: { state: A['state']; actions: A['actions'] } }
162+
Props & {
163+
overmind: {
164+
state: Overmind<ThisConfig>['state']
165+
actions: Overmind<ThisConfig>['actions']
166+
}
167+
}
168+
>
169+
): IReactComponent<
170+
Omit<
171+
Props & IConnect<Overmind<ThisConfig>>,
172+
keyof IConnect<Overmind<ThisConfig>>
163173
>
164-
): IReactComponent<Omit<Props & IConnect<A>, keyof IConnect<A>>> => {
174+
> => {
165175
let componentInstanceId = 0
166176
const name = component.name
167177
const populatedComponent = component as any

packages/overmind-website/examples/guide/usingovermindwithreact/hoc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ declare module 'overmind' {
2020
2121
export interface Connect extends IConnect<typeof config> {}
2222
23-
const overmind = new Overmind(config)
24-
2523
export const connect = createConnect(overmind)
24+
25+
const overmind = new Overmind(config)
2626
`,
2727
},
2828
{

packages/overmind-website/examples/guide/usingovermindwithreact/hoc_provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ declare module 'overmind' {
2020
2121
export interface Connect extends IConnect<typeof config> {}
2222
23-
export const connect = createConnect()
23+
export const connect = createConnect<typeof config>()
2424
`,
2525
},
2626
{

0 commit comments

Comments
 (0)