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: { 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