Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
5 changes: 5 additions & 0 deletions types/wx/lib.wx.component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ declare namespace WechatMiniprogram.Component {
| BooleanConstructor
| ArrayConstructor
| ObjectConstructor
| FunctionConstructor
| null
type ValueType<T extends PropertyType> = T extends null
? any
Expand All @@ -172,6 +173,8 @@ declare namespace WechatMiniprogram.Component {
? any[]
: T extends ObjectConstructor
? IAnyObject
: T extends FunctionConstructor
? (...args: any[]) => any
: never
type SimpleValueType<T extends PropertyType, V> = T extends null
? V
Expand Down Expand Up @@ -210,13 +213,15 @@ declare namespace WechatMiniprogram.Component {
| FullProperty<BooleanConstructor, any>
| FullProperty<ArrayConstructor, any>
| FullProperty<ObjectConstructor, any>
| FullProperty<FunctionConstructor, any>
| FullProperty<null, any>
type ShortProperty =
| StringConstructor
| NumberConstructor
| BooleanConstructor
| ArrayConstructor
| ObjectConstructor
| FunctionConstructor
| null
type AllProperty = AllFullProperty | ShortProperty
type PropertyToData<T extends AllProperty> = T extends ShortProperty
Expand Down
Loading