From 4b6a20052f7dedf46b1dec1a1590071f0ed0949e Mon Sep 17 00:00:00 2001 From: Yang Mingshan Date: Tue, 3 Nov 2026 15:42:04 +0800 Subject: [PATCH 1/2] feat: add function type to property --- types/wx/lib.wx.component.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/wx/lib.wx.component.d.ts b/types/wx/lib.wx.component.d.ts index ef12c09..79ae024 100644 --- a/types/wx/lib.wx.component.d.ts +++ b/types/wx/lib.wx.component.d.ts @@ -159,6 +159,7 @@ declare namespace WechatMiniprogram.Component { | BooleanConstructor | ArrayConstructor | ObjectConstructor + | FunctionConstructor | null type ValueType = T extends null ? any @@ -172,6 +173,8 @@ declare namespace WechatMiniprogram.Component { ? any[] : T extends ObjectConstructor ? IAnyObject + : T extends FunctionConstructor + ? (...args: any[]) => any : never type SimpleValueType = T extends null ? V @@ -210,6 +213,7 @@ declare namespace WechatMiniprogram.Component { | FullProperty | FullProperty | FullProperty + | FullProperty | FullProperty type ShortProperty = | StringConstructor @@ -217,6 +221,7 @@ declare namespace WechatMiniprogram.Component { | BooleanConstructor | ArrayConstructor | ObjectConstructor + | FunctionConstructor | null type AllProperty = AllFullProperty | ShortProperty type PropertyToData = T extends ShortProperty From 1b8d24d1d63f0c1a757fcdfb020d965bd854ae1c Mon Sep 17 00:00:00 2001 From: Yang Mingshan Date: Tue, 3 Nov 2026 16:25:51 +0800 Subject: [PATCH 2/2] test: function type property --- test/component.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/component.test.ts b/test/component.test.ts index 130dda1..a3ffa89 100644 --- a/test/component.test.ts +++ b/test/component.test.ts @@ -275,6 +275,22 @@ Component({ }, }) +Component({ + properties: { + f: Function, + f2: { + type: Function, + value: () => {}, + }, + }, + methods: { + m() { + expectType<(...args: any[]) => any>(this.data.f) + expectType<() => void>(this.data.f2) + }, + }, +}) + expectError( Component({ data: {