From 4ac55bfae6c76b58490297f048d0ab7ebf7d5f39 Mon Sep 17 00:00:00 2001
From: hhh <1340545944@qq.com>
Date: Thu, 31 Jan 2019 07:52:54 +0800
Subject: [PATCH] improve the types
---
src/core/HUI.ts | 2 +-
src/core/Store.ts | 12 ++++++------
src/core/registry.ts | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/core/HUI.ts b/src/core/HUI.ts
index f30895d..b4fabe9 100644
--- a/src/core/HUI.ts
+++ b/src/core/HUI.ts
@@ -16,7 +16,7 @@ export const HUI =
=> ({
isHN: true,
type,
- desc: registry.get(type as any),
+ desc: registry.get(type as _HType),
props: _assign({ children: children.flat(_Infinity) }, props) as unknown as _HProps
,
active: true
});
diff --git a/src/core/Store.ts b/src/core/Store.ts
index 081d5d9..1f7f93a 100644
--- a/src/core/Store.ts
+++ b/src/core/Store.ts
@@ -42,7 +42,7 @@ export interface Store = any> {
push(key: K, ...items: AssertArray): this;
unshift(key: K, ...items: AssertArray): this;
- slice(key: keyof T, start: number, end: number): this;
+ slice(key: keyof T, start: number, end?: number): this;
splice(key: K, start: number, deleteCount?: number): this;
splice(key: K, start: number, deleteCount: number, ...items: AssertArray): this;
@@ -143,7 +143,7 @@ export const createStore = function crtSto<
},
toggle: function s_toggle(key) {
- return store.set(key, !store.get(key) as any);
+ return store.set(key, !store.get(key) as unknown as T[keyof T]);
},
inc: function s_inc(key, addition = 1) {
@@ -151,21 +151,21 @@ export const createStore = function crtSto<
},
push: function s_push(key, ...items) {
- return store.set(key, (store.get(key) as unknown as any[]).concat(items) as any);
+ return store.set(key, (store.get(key) as unknown as any[]).concat(items) as unknown as T[keyof T]);
},
unshift: function s_unshift(key, ...items) {
- return store.set(key, items.concat(store.get(key)) as any);
+ return store.set(key, items.concat(store.get(key)) as unknown as T[keyof T]);
},
slice: function s_slice(key, start, end) {
- return store.set(key, (store.get(key) as unknown as any[]).slice(start, end) as any);
+ return store.set(key, (store.get(key) as unknown as any[]).slice(start, end) as unknown as T[keyof T]);
},
splice: function s_splice(key: keyof T, start: number, deleteCount: number, ...items: any[]) {
const arr = (store.get(key) as unknown as any[]).slice();
_splice.apply(arr, [start, deleteCount].concat(items) as SpliceArgs);
- return store.set(key, arr as any);
+ return store.set(key, arr as unknown as T[keyof T]);
},
handle: function s_handle(name, handler) {
diff --git a/src/core/registry.ts b/src/core/registry.ts
index d17f4e5..36f2479 100644
--- a/src/core/registry.ts
+++ b/src/core/registry.ts
@@ -14,7 +14,7 @@ export const define = function ;
- registry.set(type as any, desc as any);
+ registry.set(type as HType, desc as HDesc);
return type;