TS2605: тип элемента JSX 'VNode <Attributes>|Посмотретьне является функцией конструктора для элементов JSX - PullRequest
0 голосов
/ 25 декабря 2018

файл hyperapp.d.ts

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
    }
  }
}

мой код

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>
)

Сообщение об ошибке

* TS2605: тип элемента JSX 'VNode |View 'не является функцией конструктора для элементов JSX.Тип «Вид» не может быть назначен типу «Элемент».

TS2605: Тип элемента JSX 'Вид |VNode <{}> 'не является функцией конструктора для элементов JSX.Тип «Вид» не может быть назначен типу «Элемент». *

...