Skip to content

Commit a19c095

Browse files
fix(overmind-components): fix typing of children
1 parent 0eb9d19 commit a19c095

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

packages/node_modules/overmind-components/src/Component.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { Null } from './Null'
22
import { TApp, Configuration } from 'overmind'
33

4-
export type TComponent<
5-
Config extends Configuration,
6-
Props = {},
7-
Children = any
8-
> = (
9-
props: {
10-
state: TApp<Config>['state']
11-
actions: TApp<Config>['actions']
12-
children?: Children
13-
} & Props
4+
export type TComponent<Config extends Configuration, Props = {}> = (
5+
props: Props extends { children: any }
6+
? {
7+
state: TApp<Config>['state']
8+
actions: TApp<Config>['actions']
9+
} & Props
10+
: {
11+
state: TApp<Config>['state']
12+
actions: TApp<Config>['actions']
13+
} & Props & { children: any }
1414
) => any
1515

1616
export type FormEvent<T> = {

packages/overmind-website/src/app/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ declare module 'overmind' {
1616
interface IConfig extends TConfig<typeof config> {}
1717
}
1818

19-
export type Component<Props = {}, Children = any> = TComponent<
20-
typeof config,
21-
Props,
22-
Children
23-
>
19+
export type Component<Props = {}> = TComponent<typeof config, Props>
2420

2521
const app = new Overmind(config)
2622

packages/overmind-website/src/components/Icon/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { h } from 'overmind-components'
22
import { Component } from '../../app'
33
import { icon, icons } from './styles'
44

5-
const Icon: Component<{}, keyof typeof icons> = ({ children }) => (
5+
type Props = {
6+
children: keyof typeof icons
7+
}
8+
9+
const Icon: Component<Props> = ({ children }) => (
610
<span className={icon(String(children))} />
711
)
812

0 commit comments

Comments
 (0)