the hyperapp.d.ts file
export interface VNode<Attributes = {}> {
nodeName: string
attributes?: Attributes
children: Array<VNode | string>
key: string
}
export interface Component<Attributes = {}, State = {}, Actions = {}> {
(attributes: Attributes, children: Array<VNode | string>):
| VNode<Attributes>
| View<State, Actions>
}
declare global {
namespace JSX {
interface Element extends VNode<any> {}
interface IntrinsicElements {
[elemName: string]: any
}
}
}
my code
export const Up: Component<Attributes, State, Actions> = ({ by }) => (_, actions) => (
<button onclick={() => actions.up(by)}>+ {by}</button>
)
export const Down: Component<Attributes, State, Actions> = ({ by }) => (_, actions) => (
<button onclick={() => actions.down(by)}>- {by}</button>
)
export const Double: Component<{}, State, Actions> = () => (state, actions) => (
<button onclick={() => actions.up(state.count)}>+ {state.count}</button>
)
export const view: View<State, Actions> = state => (
<div>
<h1>{state.count}</h1>
<Up by={2} />
<Down by={1} />
<Double />
</div>
)
The error message
*TS2605: JSX element type 'VNode | View' is not a constructor function for JSX elements. Type 'View' is not assignable to type 'Element'.
TS2605: JSX element type 'View | VNode<{}>' is not a constructor function for JSX elements. Type 'View' is not assignable to type 'Element'.*