diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..981f336 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,49 @@ +/** + * html string helper function, flattens array values + */ +declare function html( + components: TemplateStringsArray, + ...values: ( + | boolean + | void + | null + | string + | number + | (void | null | boolean | string | number)[])[] +): string; + +/** + * create application store from reducer + */ +declare function createStore( + reducer: (state: State, action: Action) => State +): { + /** + * dispatch an app action + */ + dispatch(action: Action, ...args: any[]): void; + + /** + * mount a component on an element + */ + attach string>( + component: Component, + root: Element + ): void; + + /** + * attach the app state to a component + */ + connect(component: (state: State) => string): () => string; + connect(component: (state: State, a: A) => string): (a: A) => string; + connect( + component: (state: State, a: A, b: B) => string + ): (a: A, b: B) => string; + connect( + component: (state: State, a: A, b: B, c: C) => string + ): (a: A, b: B, c: C) => string; + connect(component: (state: State, ...args: any[]) => string): (...args: any[]) => string; +}; + +export { createStore }; +export default html; \ No newline at end of file diff --git a/package.json b/package.json index a28caa1..03bfed3 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.1.1", "description": "A tiny view + state management solution using innerHTML", "main": "index.js", + "typings": "index.d.ts", "repository": { "type": "git", "url": "git+https://github.com/stasm/innerself.git"