From 35228c1a3ed56b68c1441a50fbc0d325b4936560 Mon Sep 17 00:00:00 2001 From: Xc Date: Thu, 12 May 2022 20:42:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=92=8Cnode=E4=B8=AD=E7=9A=84=E5=B0=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/features/node.js | 2 +- lib/platforms/wechatMp/index.d.ts | 4 +-- src/features/node.ts | 4 +-- src/platforms/wechatMp/index.ts | 4 +-- src/typings/wx.polyfill.d.ts | 5 ++-- test/test.ts | 45 +++++++++++++++++++------------ 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/lib/features/node.js b/lib/features/node.js index f9a7ad0c..6f56a922 100644 --- a/lib/features/node.js +++ b/lib/features/node.js @@ -749,7 +749,7 @@ class RunningNode extends Feature_1.Feature { let value = await node.getValue(); if (node.isDirty()) { const operation = await node.composeOperation(); - const projection = node.getProjection(); + const projection = await node.getProjection(); value = (await this.applyOperation(node.getEntity(), value, operation, projection, path)); } if (value instanceof Array) { diff --git a/lib/platforms/wechatMp/index.d.ts b/lib/platforms/wechatMp/index.d.ts index a46a76a6..9d4c89da 100644 --- a/lib/platforms/wechatMp/index.d.ts +++ b/lib/platforms/wechatMp/index.d.ts @@ -105,6 +105,6 @@ export declare function initialize = Partial & Partial> & Partial> & Partial & Partial & ThisType>; -export declare type MakeOakPage, AD extends Record>, FD extends Record>> = (options: OakPageOption, componentOptions: OakWechatMpOptions, OakPageData, OakPageInstanceProperties, IS, true>) => string; -export declare type MakeOakComponent, AD extends Record>, FD extends Record>> = (options: OakComponentOption, componentOptions: OakWechatMpOptions, OakComponentData, OakComponentInstanceProperties, IS, true>) => string; +export declare type MakeOakPage, AD extends Record>, FD extends Record>> = (options: OakPageOption, componentOptions: OakWechatMpOptions, OakPageData & FormedData, OakPageInstanceProperties, IS, true>) => string; +export declare type MakeOakComponent, AD extends Record>, FD extends Record>> = (options: OakComponentOption, componentOptions: OakWechatMpOptions, OakComponentData & FormedData, OakComponentInstanceProperties, IS, true>) => string; export {}; diff --git a/src/features/node.ts b/src/features/node.ts index e87d67fa..37841d09 100644 --- a/src/features/node.ts +++ b/src/features/node.ts @@ -689,7 +689,7 @@ export class RunningNode, AD exte private async applyOperation( entity: T, value: Partial | Partial[] | undefined, operation: DeduceOperation | DeduceOperation[], - projection: DeduceSelection['data'], + projection: ED[T]['Selection']['data'], scene: string): Promise | Partial[] | undefined> { if (operation instanceof Array) { assert(value instanceof Array); @@ -853,7 +853,7 @@ export class RunningNode, AD exte let value = await node.getValue(); if (node.isDirty()) { const operation = await node.composeOperation(); - const projection = node.getProjection(); + const projection = await node.getProjection(); value = (await this.applyOperation(node.getEntity(), value, operation!, projection as any, path)); } diff --git a/src/platforms/wechatMp/index.ts b/src/platforms/wechatMp/index.ts index d1ab98ab..91fbcfe2 100644 --- a/src/platforms/wechatMp/index.ts +++ b/src/platforms/wechatMp/index.ts @@ -955,7 +955,7 @@ export type MakeOakPage< M, OakPageProperties, OakPageMethods, - OakPageData, + OakPageData & FormedData, OakPageInstanceProperties, IS, true @@ -983,7 +983,7 @@ export type MakeOakComponent< M, OakComponentProperties, OakComponentMethods, - OakComponentData, + OakComponentData & FormedData, OakComponentInstanceProperties, IS, true diff --git a/src/typings/wx.polyfill.d.ts b/src/typings/wx.polyfill.d.ts index 11db7866..f37dd8a1 100644 --- a/src/typings/wx.polyfill.d.ts +++ b/src/typings/wx.polyfill.d.ts @@ -1,6 +1,7 @@ /// -declare namespace WechatMiniprogram.Component { +// 这样写就是不行,必须要写到platform/wechatMp/index.ts中去,不知道为什么…… +declare namespace OakMiniprogram { type OakOptions< TData extends DataOption, FormedData extends DataOption, @@ -8,7 +9,7 @@ declare namespace WechatMiniprogram.Component { TMethod extends MethodOption, TCustomInstanceProperty extends IAnyObject = {}, TIsPage extends boolean = false - > = Partial> & + > = Partial> & Partial> & Partial> & Partial & diff --git a/test/test.ts b/test/test.ts index 841b3549..0dfd66a9 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,22 +1,33 @@ -import { OakException, OakUserException } from 'oak-domain/lib/types'; -const e = new OakUserException(); - -console.log(e instanceof OakException); -type Tessst = { - name: string; - no: number; - friends?: Array; +type OakPageData = { + oakFullpath: string; + oakExecuting: boolean; + oakFocused: object; + oakDirty: boolean; + oakError: { + type: 'warning' | 'error' | 'success' | 'primary'; + msg: string; + }; + oakLegalActions: string[], }; -type Eliminate = Tessst & { - [k in K]: never; +type A = { + name: string; + method: Function, +} & ThisType<{ + data: OakPageData +}>; + +const a: A = { + name: 'xc', + method() { + } +}; + +function tt>(p: Partial) { + console.log(p); } -type TT = Eliminate<'name'>; - -type Deduce> = { - [K in keyof T]: T[K] extends Array ? string : number; -}; - -type DD = Deduce; +tt({ + oakExecuting: false, +}) \ No newline at end of file