diff --git a/test/component.test.ts b/test/component.test.ts index 0376d91..849f9da 100644 --- a/test/component.test.ts +++ b/test/component.test.ts @@ -505,3 +505,4 @@ Component<{}, {}, { fn(): void }, []>({ } }) } + diff --git a/test/issue.test.ts b/test/issue.test.ts index 9390d0c..08e0d96 100644 --- a/test/issue.test.ts +++ b/test/issue.test.ts @@ -634,4 +634,25 @@ import WX = WechatMiniprogram }, } }) +} + +// https://github.com/wechat-miniprogram/api-typings/pull/351 +{ + type Properties = { + customProp: string + [key: string]: unknown; + [key: number]: string; + } + Component({ + lifetimes: { + created() { + this.properties[1] = '1'; + expectError(() => { + this.properties[2] = 2; + }); + expectError(this.properties.xxx); + this.properties.customProp = 'customProp'; + } + } + }) } \ No newline at end of file diff --git a/types/wx/lib.wx.component.d.ts b/types/wx/lib.wx.component.d.ts index ca0c53b..e713942 100644 --- a/types/wx/lib.wx.component.d.ts +++ b/types/wx/lib.wx.component.d.ts @@ -21,7 +21,9 @@ SOFTWARE. ***************************************************************************** */ declare namespace WechatMiniprogram.Component { - type FilterUnknownType = string extends keyof T ? {} : T + type FilterUnknownType = { + [P in keyof T as string extends P ? never : P]: T[P] + } type Instance< TData extends DataOption, TProperty extends PropertyOption,