Skip to content

Commit cf908f7

Browse files
committed
Update types to be more usable
1 parent 89fd093 commit cf908f7

6 files changed

Lines changed: 19 additions & 26 deletions

File tree

dist/hyperapp-devtools.es.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/hyperapp-devtools.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/hyperapp-devtools.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/hoa.d.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { ActionsType } from "hyperapp";
21
export declare const guid: () => any;
3-
export interface View<AppState = any, AppActions = any> {
4-
(state: AppState, actions: AppActions): any;
2+
export interface View {
3+
(state: any, actions: any): any;
54
}
6-
export interface App<AppState = any, AppActions = any> {
7-
(state: AppState, actions: ActionsType<AppState, AppActions>, view: View<AppState, AppActions>, container: Element | null): AppActions;
5+
export interface HypperApp {
6+
(state: any, actions: any, view: View, container: Element | null): any;
87
}
9-
export declare function hoa<AppState, AppActions>(app: App): App<AppState, AppActions>;
8+
export declare function hoa<App extends HypperApp>(app: App): App;
109
export default hoa;

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
"main": "dist/hyperapp-devtools.js",
99
"minified:main": "dist/hyperapp-devtools.min.js",
1010
"jsnext:main": "dist/hyperapp-devtools.es.js",
11-
"module": "dist/hyperapp-devtools.es.js",
11+
"module": "dist/hyperapp-devtools.js",
1212
"typings": "dist/src/index.d.ts",
1313
"scripts": {
1414
"clean": "rimraf dist .rpt2_cache",
1515
"start": "rollup -c -w --serve",
16-
"build":
17-
"npm run clean && npm run build:module && npm run build:main && npm run build:min",
16+
"build": "npm run clean && npm run build:main && npm run build:min",
1817
"build:main": "rollup -c && rimraf .rpt2_cache",
1918
"build:min": "rollup -c --min && rimraf .rpt2_cache",
2019
"build:module": "rollup -c --es && rimraf .rpt2_cache",
2120
"release":
2221
"npm run build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
2322
},
2423
"dependencies": {
25-
"hyperapp": "^1.2.5",
26-
"spectre.css": "^0.5.1"
24+
"spectre.css": "^0.5.1",
25+
"hyperapp": "^1.2.5"
2726
},
2827
"devDependencies": {
2928
"cpx": "^1.5.0",

src/hoa.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h, ActionsType } from "hyperapp"
1+
import { h } from "hyperapp"
22

33
import { Actions } from "./api"
44
import { state } from "./state"
@@ -18,27 +18,22 @@ export const guid = () =>
1818

1919
// rewrite the view more permissive than HA to allow for multiple VNode implementation
2020
// e.g. the one in HA 1.1.2 and the on in HA 1.2.5
21-
export interface View<AppState = any, AppActions = any> {
22-
(state: AppState, actions: AppActions): any
21+
export interface View {
22+
(state: any, actions: any): any
2323
}
2424

25-
export interface App<AppState = any, AppActions = any> {
26-
(
27-
state: AppState,
28-
actions: ActionsType<AppState, AppActions>,
29-
view: View<AppState, AppActions>,
30-
container: Element | null
31-
): AppActions
25+
export interface HypperApp {
26+
(state: any, actions: any, view: View, container: Element | null): any
3227
}
3328

34-
export function hoa<AppState, AppActions>(app: App): App<AppState, AppActions> {
29+
export function hoa<App extends HypperApp>(app: App): App {
3530
const div = document.createElement("div")
3631
div.id = "hyperapp-devtools"
3732
document.body.appendChild(div)
3833

3934
const devtoolsApp: Actions = app(state, actions, view, div)
4035

41-
return function(state: any, actions: any, view, element) {
36+
return <App>function(state: any, actions: any, view, element) {
4237
const runId = guid()
4338
actions = enhanceActions(devtoolsApp.logAction, runId, actions)
4439
actions.$__SET_STATE = state => state

0 commit comments

Comments
 (0)