hyperapp v2 の TypeScript 用型定義を書いた
読了まで:約1分
とり
出来上がった hyperapp 型定義ファイル
/// <reference lib="es2015,dom" />
export as namespace hyperapp;
export interface VNode<A> {
name: string;
props: A;
children: [VNode | string];
node: HTMLElement;
type: number;
key: any;
}
export function View<S>(props: S): VNode;
export type Event<V> = (event: HTMLElement) => V | V;
export function Dispatch<S, P>(
fn: (state: S, payload: P) => P,
payload: P
): void;
export type Effect<S, P> = [Dispatch<S, P>, P];
export function Action<S, V, P>(state: S, value: Event<V>): [S, Effect<S, P>];
export function Action<S, P>(state: S): [S, Effect<S, P>];
export function Action<S, V>(state: S, value: Event<V>): S;
export function Action<S>(state: S): S;
export type Subscription<S, P> = Effect<S, P>;
export function Subscriptions<S, P>(state: S): [Subscription<S, P>];
export type Attr<V> = Event<V> | V;
export interface Attrs<V> {
[key: string]: Attr<V>;
}
export function app<S, P>(props: {
init: S;
view: View<S>;
subscriptions?: Subscriptions<S, P>;
node: HTMLElement;
}): void;
export function h<A>(
name: string,
attrs: Attrs<A>,
children?: [VNode | string] | VNode | string
): VNode;
それでこれ何?
JavaScript での
とhyperapp
を
自由に使って良いの?
基本的に
あとhyperapp
の
以上
ちなみに
とはhyperapp
を
また
を
とはhyperapp
を
と