From 0fb62657b7f82c02c4bf9251754761a02f3cb4b2 Mon Sep 17 00:00:00 2001 From: Ben Southgate Date: Fri, 15 Sep 2017 10:15:21 -0400 Subject: [PATCH 1/3] feat: add basic typescript definitions --- index.d.ts | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..fb8f9d9 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,49 @@ +/** + * create html markdown + */ +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 From e22427979c5d58549e64ac308c34a85d858d3745 Mon Sep 17 00:00:00 2001 From: Ben Southgate Date: Fri, 15 Sep 2017 10:27:00 -0400 Subject: [PATCH 2/3] fix: add typings to package.json --- package.json | 1 + 1 file changed, 1 insertion(+) 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" From 8cb750d97580738126f75e3d1f8c1895714179dc Mon Sep 17 00:00:00 2001 From: Ben Southgate Date: Fri, 15 Sep 2017 12:27:45 -0400 Subject: [PATCH 3/3] fix: comment for `html` --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index fb8f9d9..981f336 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,5 +1,5 @@ /** - * create html markdown + * html string helper function, flattens array values */ declare function html( components: TemplateStringsArray,