From 222c3e7eb94cb20f4455317854cdb10166974bfc Mon Sep 17 00:00:00 2001 From: hhh <1340545944@qq.com> Date: Wed, 30 Jan 2019 22:05:05 +0800 Subject: [PATCH] improve type declarations --- index.d.ts | 343 ++++++++++++++++++++--------------------- src/core/HNode.ts | 28 ++-- src/core/HUI.ts | 55 +++++-- src/core/Store.ts | 11 +- src/core/registry.ts | 20 +-- src/core/render.ts | 18 +-- src/ext/Fragment.ts | 3 +- src/ext/Portal.ts | 5 +- test/src/CatchTest.tsx | 4 +- test/src/Dialog.tsx | 2 +- test/src/Greeting.tsx | 6 +- test/src/Inspector.ts | 2 +- test/src/TestInput.tsx | 2 +- test/src/ThrowTest.tsx | 2 +- test/src/Timer.tsx | 2 +- test/src/test.tsx | 10 +- 16 files changed, 271 insertions(+), 242 deletions(-) diff --git a/index.d.ts b/index.d.ts index 54791e3..926f4b1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,5 +1,4 @@ import HUI from "./typings/index"; -import { EleProps } from "./typings/core/propHandlers"; export as namespace HUI; @@ -13,179 +12,179 @@ declare global { interface IntrinsicElements { - [name: string]: EleProps; + [name: string]: HUI.EleProps; - a: EleProps; - abbr: EleProps; - address: EleProps; - area: EleProps; - article: EleProps; - aside: EleProps; - audio: EleProps; - b: EleProps; - base: EleProps; - bdi: EleProps; - bdo: EleProps; - big: EleProps; - blockquote: EleProps; - body: EleProps; - br: EleProps; - button: EleProps; - canvas: EleProps; - caption: EleProps; - cite: EleProps; - code: EleProps; - col: EleProps; - colgroup: EleProps; - data: EleProps; - datalist: EleProps; - dd: EleProps; - del: EleProps; - details: EleProps; - dfn: EleProps; - dialog: EleProps; - div: EleProps; - dl: EleProps; - dt: EleProps; - em: EleProps; - embed: EleProps; - fieldset: EleProps; - figcaption: EleProps; - figure: EleProps; - footer: EleProps; - form: EleProps; - h1: EleProps; - h2: EleProps; - h3: EleProps; - h4: EleProps; - h5: EleProps; - h6: EleProps; - head: EleProps; - header: EleProps; - hgroup: EleProps; - hr: EleProps; - html: EleProps; - i: EleProps; - iframe: EleProps; - img: EleProps; - input: EleProps; - ins: EleProps; - kbd: EleProps; - keygen: EleProps; - label: EleProps; - legend: EleProps; - li: EleProps; - link: EleProps; - main: EleProps; - map: EleProps; - mark: EleProps; - menu: EleProps; - menuitem: EleProps; - meta: EleProps; - meter: EleProps; - nav: EleProps; - noindex: EleProps; - noscript: EleProps; - object: EleProps; - ol: EleProps; - optgroup: EleProps; - option: EleProps; - output: EleProps; - p: EleProps; - param: EleProps; - picture: EleProps; - pre: EleProps; - progress: EleProps; - q: EleProps; - rp: EleProps; - rt: EleProps; - ruby: EleProps; - s: EleProps; - samp: EleProps; - script: EleProps; - section: EleProps; - select: EleProps; - small: EleProps; - source: EleProps; - span: EleProps; - strong: EleProps; - style: EleProps; - sub: EleProps; - summary: EleProps; - sup: EleProps; - table: EleProps; - tbody: EleProps; - td: EleProps; - textarea: EleProps; - tfoot: EleProps; - th: EleProps; - thead: EleProps; - time: EleProps; - title: EleProps; - tr: EleProps; - track: EleProps; - u: EleProps; - ul: EleProps; - var: EleProps; - video: EleProps; - wbr: EleProps; - webview: EleProps; + a: HUI.EleProps; + abbr: HUI.EleProps; + address: HUI.EleProps; + area: HUI.EleProps; + article: HUI.EleProps; + aside: HUI.EleProps; + audio: HUI.EleProps; + b: HUI.EleProps; + base: HUI.EleProps; + bdi: HUI.EleProps; + bdo: HUI.EleProps; + big: HUI.EleProps; + blockquote: HUI.EleProps; + body: HUI.EleProps; + br: HUI.EleProps; + button: HUI.EleProps; + canvas: HUI.EleProps; + caption: HUI.EleProps; + cite: HUI.EleProps; + code: HUI.EleProps; + col: HUI.EleProps; + colgroup: HUI.EleProps; + data: HUI.EleProps; + datalist: HUI.EleProps; + dd: HUI.EleProps; + del: HUI.EleProps; + details: HUI.EleProps; + dfn: HUI.EleProps; + dialog: HUI.EleProps; + div: HUI.EleProps; + dl: HUI.EleProps; + dt: HUI.EleProps; + em: HUI.EleProps; + embed: HUI.EleProps; + fieldset: HUI.EleProps; + figcaption: HUI.EleProps; + figure: HUI.EleProps; + footer: HUI.EleProps; + form: HUI.EleProps; + h1: HUI.EleProps; + h2: HUI.EleProps; + h3: HUI.EleProps; + h4: HUI.EleProps; + h5: HUI.EleProps; + h6: HUI.EleProps; + head: HUI.EleProps; + header: HUI.EleProps; + hgroup: HUI.EleProps; + hr: HUI.EleProps; + html: HUI.EleProps; + i: HUI.EleProps; + iframe: HUI.EleProps; + img: HUI.EleProps; + input: HUI.EleProps; + ins: HUI.EleProps; + kbd: HUI.EleProps; + keygen: HUI.EleProps; + label: HUI.EleProps; + legend: HUI.EleProps; + li: HUI.EleProps; + link: HUI.EleProps; + main: HUI.EleProps; + map: HUI.EleProps; + mark: HUI.EleProps; + menu: HUI.EleProps; + menuitem: HUI.EleProps; + meta: HUI.EleProps; + meter: HUI.EleProps; + nav: HUI.EleProps; + noindex: HUI.EleProps; + noscript: HUI.EleProps; + object: HUI.EleProps; + ol: HUI.EleProps; + optgroup: HUI.EleProps; + option: HUI.EleProps; + output: HUI.EleProps; + p: HUI.EleProps; + param: HUI.EleProps; + picture: HUI.EleProps; + pre: HUI.EleProps; + progress: HUI.EleProps; + q: HUI.EleProps; + rp: HUI.EleProps; + rt: HUI.EleProps; + ruby: HUI.EleProps; + s: HUI.EleProps; + samp: HUI.EleProps; + script: HUI.EleProps; + section: HUI.EleProps; + select: HUI.EleProps; + small: HUI.EleProps; + source: HUI.EleProps; + span: HUI.EleProps; + strong: HUI.EleProps; + style: HUI.EleProps; + sub: HUI.EleProps; + summary: HUI.EleProps; + sup: HUI.EleProps; + table: HUI.EleProps; + tbody: HUI.EleProps; + td: HUI.EleProps; + textarea: HUI.EleProps; + tfoot: HUI.EleProps; + th: HUI.EleProps; + thead: HUI.EleProps; + time: HUI.EleProps; + title: HUI.EleProps; + tr: HUI.EleProps; + track: HUI.EleProps; + u: HUI.EleProps; + ul: HUI.EleProps; + var: HUI.EleProps; + video: HUI.EleProps; + wbr: HUI.EleProps; + webview: HUI.EleProps; - svg: EleProps; - animate: EleProps; - animateTransform: EleProps; - circle: EleProps; - clipPath: EleProps; - defs: EleProps; - desc: EleProps; - ellipse: EleProps; - feBlend: EleProps; - feColorMatrix: EleProps; - feComponentTransfer: EleProps; - feComposite: EleProps; - feConvolveMatrix: EleProps; - feDiffuseLighting: EleProps; - feDisplacementMap: EleProps; - feDistantLight: EleProps; - feFlood: EleProps; - feFuncA: EleProps; - feFuncB: EleProps; - feFuncG: EleProps; - feFuncR: EleProps; - feGaussianBlur: EleProps; - feImage: EleProps; - feMerge: EleProps; - feMergeNode: EleProps; - feMorphology: EleProps; - feOffset: EleProps; - fePointLight: EleProps; - feSpecularLighting: EleProps; - feSpotLight: EleProps; - feTile: EleProps; - feTurbulence: EleProps; - filter: EleProps; - foreignObject: EleProps; - g: EleProps; - image: EleProps; - line: EleProps; - linearGradient: EleProps; - marker: EleProps; - mask: EleProps; - metadata: EleProps; - path: EleProps; - pattern: EleProps; - polygon: EleProps; - polyline: EleProps; - radialGradient: EleProps; - rect: EleProps; - stop: EleProps; - switch: EleProps; - symbol: EleProps; - text: EleProps; - textPath: EleProps; - tspan: EleProps; - use: EleProps; - view: EleProps; + svg: HUI.EleProps; + animate: HUI.EleProps; + animateTransform: HUI.EleProps; + circle: HUI.EleProps; + clipPath: HUI.EleProps; + defs: HUI.EleProps; + desc: HUI.EleProps; + ellipse: HUI.EleProps; + feBlend: HUI.EleProps; + feColorMatrix: HUI.EleProps; + feComponentTransfer: HUI.EleProps; + feComposite: HUI.EleProps; + feConvolveMatrix: HUI.EleProps; + feDiffuseLighting: HUI.EleProps; + feDisplacementMap: HUI.EleProps; + feDistantLight: HUI.EleProps; + feFlood: HUI.EleProps; + feFuncA: HUI.EleProps; + feFuncB: HUI.EleProps; + feFuncG: HUI.EleProps; + feFuncR: HUI.EleProps; + feGaussianBlur: HUI.EleProps; + feImage: HUI.EleProps; + feMerge: HUI.EleProps; + feMergeNode: HUI.EleProps; + feMorphology: HUI.EleProps; + feOffset: HUI.EleProps; + fePointLight: HUI.EleProps; + feSpecularLighting: HUI.EleProps; + feSpotLight: HUI.EleProps; + feTile: HUI.EleProps; + feTurbulence: HUI.EleProps; + filter: HUI.EleProps; + foreignObject: HUI.EleProps; + g: HUI.EleProps; + image: HUI.EleProps; + line: HUI.EleProps; + linearGradient: HUI.EleProps; + marker: HUI.EleProps; + mask: HUI.EleProps; + metadata: HUI.EleProps; + path: HUI.EleProps; + pattern: HUI.EleProps; + polygon: HUI.EleProps; + polyline: HUI.EleProps; + radialGradient: HUI.EleProps; + rect: HUI.EleProps; + stop: HUI.EleProps; + switch: HUI.EleProps; + symbol: HUI.EleProps; + text: HUI.EleProps; + textPath: HUI.EleProps; + tspan: HUI.EleProps; + use: HUI.EleProps; + view: HUI.EleProps; } diff --git a/src/core/HNode.ts b/src/core/HNode.ts index 497821f..6469300 100644 --- a/src/core/HNode.ts +++ b/src/core/HNode.ts @@ -1,4 +1,4 @@ -import { Store, createStore, HandlerMap, PartialHandlers } from "./Store"; +import { Store, createStore, PartialHandlers, StoreType, StoreHandlers } from "./Store"; import { _document, _isArray, _Infinity, _Map, _entries, _createTextNode } from "../utils/refCache"; import { toArr, isHNode } from "../utils/helpers"; import { handleProp } from "./handleProp"; @@ -27,25 +27,25 @@ export type HProps

= { children: unknown[]; }); -export interface HDesc

= any, CH extends HandlerMap = any> { +export interface HDesc

{ defaultProps?: Partial

; - defaultStore?: Partial; - storeHandlers?: PartialHandlers>; - state?: Array; - context?: Array; - init?: (this: HNode, props: HProps

, store: Store, context: Store) => void; - render: (this: HNode, props: HProps

, store: Store, context: Store) => unknown; - clear?: (this: HNode, props: HProps

, store: Store, context: Store) => void; - catch?: (this: HNode, err: any, props: HProps

, store: Store, context: Store) => unknown; + defaultStore?: Partial>; + storeHandlers?: PartialHandlers, S>; + state?: Array>; + context?: Array>; + init?: (this: HNode, props: HProps

, store: S, context: C) => void; + render: (this: HNode, props: HProps

, store: S, context: C) => unknown; + clear?: (this: HNode, props: HProps

, store: S, context: C) => void; + catch?: (this: HNode, err: any, props: HProps

, store: S, context: C) => unknown; } -export interface HNode

= any, CH extends HandlerMap = any> { +export interface HNode

{ isHN: true; type: unknown; - desc?: HDesc; + desc?: HDesc; props: HProps

; - sto?: Store; - ctx?: Store; + sto?: S; + ctx?: C; owner?: HNode; ownNode?: Node; out?: unknown[]; diff --git a/src/core/HUI.ts b/src/core/HUI.ts index 4252de3..d0460d2 100644 --- a/src/core/HUI.ts +++ b/src/core/HUI.ts @@ -1,22 +1,23 @@ -import { HNode, HProps } from "./HNode"; -import { registry, define, HType } from "./registry"; +import { HProps as _HProps, HDesc as _HDesc, HNode as _HNode } from "./HNode"; +import { registry, define, HType as _HType } from "./registry"; import { _assign, _Infinity, _requestAnimationFrame } from "../utils/refCache"; -import { createStore, HandlerMap } from "./Store"; -import { renderToDOM } from "./render"; -import { propHandlers, EleProps } from "./propHandlers"; -import { Portal } from "../ext/Portal"; +import { Store as _Store, createStore, HandlerMap as _HandlerMap, Setter as _Setter, SetterRecord as _SetterRecord, StoreType as _StoreType, StoreHandlers as _StoreHandlers, PartialHandlers as _PartialHandlers } from "./Store"; +import { RenderOptions as _RenderOptions, renderToDOM } from "./render"; +import { propHandlers, EleProps as _EleProps, PropHandler as _PropHandler, RefCallback as _RefCallback, AttributeMap as _AttributeMap } from "./propHandlers"; +import { EventRecord as _EventRecord, EventMap as _EventMap } from "./events"; +import { Portal, PortalProps as _PortalProps, PortalStore as _PortalStore } from "../ext/Portal"; +import { Fragment, FragmentProps as _FragmentProps } from "../ext/Fragment"; import { defer } from "../ticker/ticker"; import { compare } from "../utils/cmp"; -import { Fragment } from "../ext/Fragment"; import { noCmpProps } from "../ticker/patch"; -export const HUI =

= any, CH extends HandlerMap = any>( - type: HType | string, props?: P | null, ...children: unknown[] -): HNode => ({ +export const HUI =

( + type: _HType | string, props?: P | null, ...children: unknown[] +): _HNode => ({ isHN: true, type, - desc: registry.get(type), - props: _assign({ children: children.flat(_Infinity) }, props) as unknown as HProps

, + desc: registry.get(type as any), + props: _assign({ children: children.flat(_Infinity) }, props) as unknown as _HProps

, active: true }); @@ -38,3 +39,33 @@ HUI.Portal = Portal; HUI.Fragment = Fragment; HUI.cmp = compare; + +export namespace HUI { + + export type HProps

= _HProps

; + export type HDesc

= _HDesc; + export type HNode

= _HNode; + + export type HType

= _HType; + + export type Store = _Store; + export type HandlerMap = _HandlerMap; + export type Setter = _Setter; + export type SetterRecord = _SetterRecord; + + export type RenderOptions = _RenderOptions; + + export type EleProps = _EleProps; + export type PropHandler = _PropHandler; + export type RefCallback = _RefCallback; + export type AttributeMap = _AttributeMap; + + export type EventRecord = _EventRecord; + export type EventMap = _EventMap; + + export type FragmentProps = _FragmentProps; + + export type PortalProps = _PortalProps; + export type PortalStore = _PortalStore; + +} diff --git a/src/core/Store.ts b/src/core/Store.ts index a1c8e15..90a9bc9 100644 --- a/src/core/Store.ts +++ b/src/core/Store.ts @@ -9,7 +9,7 @@ type MapOf = Map>; type InjectThis any, T> = (this: T, ...args: Parameters) => ReturnType; export type Setter = (value: T) => void; -export type SetterRecord = [Setter | undefined, Setter | undefined]; +export type SetterRecord = [Setter | undefined, Setter | undefined]; export interface HandlerMap { [name: string]: (this: Store>, ...args: any[]) => any; @@ -17,11 +17,14 @@ export interface HandlerMap { export type PartialHandlers = { [K in keyof H]?: InjectThis | null }; +export type StoreType = S extends Store ? T : never; +export type StoreHandlers = S extends Store ? H : never; + export interface Store = any> { valueMap: MapOf; bindingMap: Map[]>; - setterMap: Map; + setterMap: Map>; handlerMap: MapOf; bind(hNode: HNode, subscriptions: Array): this; @@ -54,7 +57,7 @@ export const createStore = function crtSto< const valueMap = new _Map(), bindingMap = new _Map[]>(), - setterMap = new _Map(), + setterMap = new _Map>(), handlerMap = new _Map(); const store: Store = { @@ -120,7 +123,7 @@ export const createStore = function crtSto< const setters = new Array(); - setterMap.set(key, setters as SetterRecord); + setterMap.set(key, setters as SetterRecord); return setters[index] = function setter(value: any) { store.set(key, value, force); diff --git a/src/core/registry.ts b/src/core/registry.ts index 49aec67..d17f4e5 100644 --- a/src/core/registry.ts +++ b/src/core/registry.ts @@ -1,24 +1,20 @@ import { HDesc } from "./HNode"; import { _Map, _Symbol } from "../utils/refCache"; -import { Store, HandlerMap } from "./Store"; +import { Store } from "./Store"; -export interface HType

= any, CH extends HandlerMap = any> { - (props: P, store: Store, context: Store): any; +export interface HType

{ + (props: P, store: S, context: C): any; }; export const registry = new _Map | string, HDesc>(); -export const define = function < - P extends object = any, - S extends object = any, - C extends object = any, - SH extends HandlerMap = any, - CH extends HandlerMap = any ->(name: string, desc: HDesc): HType { +export const define = function

( + name: string, desc: HDesc +): HType { - const type = _Symbol(name) as unknown as HType; + const type = _Symbol(name) as unknown as HType; - registry.set(type, desc); + registry.set(type as any, desc as any); return type; diff --git a/src/core/render.ts b/src/core/render.ts index ec750f6..ac87902 100644 --- a/src/core/render.ts +++ b/src/core/render.ts @@ -1,27 +1,27 @@ import { toNodeArr, HNode } from "./HNode"; import { _document, _assign, _from } from "../utils/refCache"; -import { createStore, Store, HandlerMap, PartialHandlers } from "./Store"; +import { createStore, Store, PartialHandlers, StoreType, StoreHandlers } from "./Store"; import { toFrag } from "../utils/helpers"; import { DeferCallback, reqTick, willTick } from "../ticker/ticker"; export const renderCallbacks = new Array>(); -export interface RenderOptions = any> { +export interface RenderOptions { clear?: boolean; - context?: Store; - defaultContext?: Partial; - contextHandlers?: PartialHandlers>; + context?: C; + defaultContext?: Partial>; + contextHandlers?: PartialHandlers, C>; parent?: Node; - owner?: HNode; + owner?: HNode; sync?: boolean; } -export const renderToDOM = function render = any>( - src: any, options: RenderOptions = {} +export const renderToDOM = function render( + src: any, options: RenderOptions = {} ) { const { parent = _document.body, - clear, owner, context = createStore(), + clear, owner, context = createStore, StoreHandlers>() as C, defaultContext, contextHandlers } = options; if (defaultContext) { diff --git a/src/ext/Fragment.ts b/src/ext/Fragment.ts index dc9e5be..e975b3a 100644 --- a/src/ext/Fragment.ts +++ b/src/ext/Fragment.ts @@ -1,10 +1,11 @@ import { define } from "../core/registry"; +import { Store } from "../core/Store"; export interface FragmentProps { children: unknown; } -export const Fragment = define('HUI.Fragment', { +export const Fragment = define, Store<{}>>('HUI.Fragment', { render: function frag_render(props) { return props.children; } diff --git a/src/ext/Portal.ts b/src/ext/Portal.ts index eef8be6..426e50c 100644 --- a/src/ext/Portal.ts +++ b/src/ext/Portal.ts @@ -5,6 +5,7 @@ import { clear } from "../utils/clear"; import { HNode } from "../core/HNode"; import { FragmentProps, Fragment } from "./Fragment"; import { HUI } from "../core/HUI"; +import { Store } from "../core/Store"; export interface PortalProps { parent?: Node; @@ -13,10 +14,10 @@ export interface PortalProps { export interface PortalStore { p: Node; - f: HNode; + f: HNode, Store<{}>>; } -export const Portal = define('HUI.Portal', { +export const Portal = define, Store<{}>>('HUI.Portal', { init: function port_init(props, store) { store.set('p', props.parent || _document.body); diff --git a/test/src/CatchTest.tsx b/test/src/CatchTest.tsx index 9fdcfc4..9a5359a 100644 --- a/test/src/CatchTest.tsx +++ b/test/src/CatchTest.tsx @@ -2,13 +2,13 @@ interface ThrowerProps { msg: string; } -const Thrower = HUI.define('Thrower', { +const Thrower = HUI.define, HUI.Store<{}>>('Thrower', { render(props) { throw props.msg; } }); -const CatchTest = HUI.define<{}, {}, {}>('CatchTest', { +const CatchTest = HUI.define<{}, HUI.Store<{}>, HUI.Store<{}>>('CatchTest', { render() { return ( diff --git a/test/src/Dialog.tsx b/test/src/Dialog.tsx index cff15b9..bcc8009 100644 --- a/test/src/Dialog.tsx +++ b/test/src/Dialog.tsx @@ -6,7 +6,7 @@ type DialogStoreHandlers = { toggle: () => void; } -const Dialog = HUI.define<{}, DialogStore, {}, DialogStoreHandlers>('Dialog', { +const Dialog = HUI.define<{}, HUI.Store, HUI.Store<{}>>('Dialog', { state: ['on'], diff --git a/test/src/Greeting.tsx b/test/src/Greeting.tsx index 2ccf615..4b33d89 100644 --- a/test/src/Greeting.tsx +++ b/test/src/Greeting.tsx @@ -2,7 +2,7 @@ interface GreetingProps { children: string; } -const Greeting = HUI.define('Greeting', { +const Greeting = HUI.define, TestContext>('Greeting', { context: ['target'], init(props, store, context) { context.set('target', props.children[0]); @@ -43,7 +43,7 @@ const Greeting = HUI.define('ShowTarget', { +const ShowTarget = HUI.define<{}, HUI.Store<{}>, TestContext>('ShowTarget', { context: ['target'], render(props, store, context) { return `context.target: ${context.get('target')}`; @@ -55,7 +55,7 @@ interface RefTestStore { ref?: HTMLParagraphElement; } -const RefTest = HUI.define<{}, RefTestStore, {}>('RefTest', { +const RefTest = HUI.define<{}, HUI.Store, HUI.Store<{}>>('RefTest', { state: ['msg'], diff --git a/test/src/Inspector.ts b/test/src/Inspector.ts index 1b8b8f7..c1d5d21 100644 --- a/test/src/Inspector.ts +++ b/test/src/Inspector.ts @@ -8,7 +8,7 @@ interface InspectorProps { children: unknown; } -const Inspector = HUI.define('Inspector', { +const Inspector = HUI.define, HUI.Store<{}>>('Inspector', { render(props) { HUI.defer((self) => { diff --git a/test/src/TestInput.tsx b/test/src/TestInput.tsx index a8e8cb3..0e93d25 100644 --- a/test/src/TestInput.tsx +++ b/test/src/TestInput.tsx @@ -7,7 +7,7 @@ interface TestInputStore { value: string; } -const TestInput = HUI.define('TestInput', { +const TestInput = HUI.define, HUI.Store<{}>>('TestInput', { state: ['value'], diff --git a/test/src/ThrowTest.tsx b/test/src/ThrowTest.tsx index cc9fea6..9ebe609 100644 --- a/test/src/ThrowTest.tsx +++ b/test/src/ThrowTest.tsx @@ -2,7 +2,7 @@ interface ThrowTestStore { msg: string; } -const ThrowTest = HUI.define<{}, ThrowTestStore, {}>('ThrowTest', { +const ThrowTest = HUI.define<{}, HUI.Store, HUI.Store<{}>>('ThrowTest', { state: ['msg'], diff --git a/test/src/Timer.tsx b/test/src/Timer.tsx index d417ac5..484db69 100644 --- a/test/src/Timer.tsx +++ b/test/src/Timer.tsx @@ -11,7 +11,7 @@ type TimerStoreHandlers = { setInterval: (interval: number) => any; } -const Timer = HUI.define('Timer', { +const Timer = HUI.define, HUI.Store<{}>>('Timer', { state: ['time'], diff --git a/test/src/test.tsx b/test/src/test.tsx index cd4f012..d42e583 100644 --- a/test/src/test.tsx +++ b/test/src/test.tsx @@ -1,17 +1,15 @@ /// -interface TestContext { +type TestContext = HUI.Store<{ target: string; 'greeting-color': string; -} - -type TestContextHandlers = { +}, { changeTarget: (newTarget: string) => string; -}; +}>; const SVG_NS = 'http://www.w3.org/2000/svg'; -HUI.render( +HUI.render( (