From 3c28190d61d3d15649d0ca7d9355cebea2d9f512 Mon Sep 17 00:00:00 2001 From: mango Date: Wed, 11 Jun 2025 18:05:33 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96FilterUnknownType?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/wx/lib.wx.component.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/wx/lib.wx.component.d.ts b/types/wx/lib.wx.component.d.ts index ca0c53b..22d9cf3 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]: string extends P ? never : T[P] + } type Instance< TData extends DataOption, TProperty extends PropertyOption, From 2176c76bb9a4a2ae3f91ef62647a11110058223e Mon Sep 17 00:00:00 2001 From: mango Date: Wed, 11 Jun 2025 19:44:49 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E5=B0=86FilterUnknownType=E7=9A=84?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BF=AE=E6=AD=A3=E4=B8=BA=E9=80=9A=E8=BF=87?= =?UTF-8?q?key=E8=BF=87=E6=BB=A4=E4=BB=A5=E7=A1=AE=E4=BF=9DTS=E8=83=BD?= =?UTF-8?q?=E5=AF=B9=E6=9C=AA=E7=9F=A5=E7=B1=BB=E5=9E=8B=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/wx/lib.wx.component.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/wx/lib.wx.component.d.ts b/types/wx/lib.wx.component.d.ts index 22d9cf3..e713942 100644 --- a/types/wx/lib.wx.component.d.ts +++ b/types/wx/lib.wx.component.d.ts @@ -22,7 +22,7 @@ SOFTWARE. declare namespace WechatMiniprogram.Component { type FilterUnknownType = { - [P in keyof T]: string extends P ? never : T[P] + [P in keyof T as string extends P ? never : P]: T[P] } type Instance< TData extends DataOption, From e289e931c39ae266d72b6ce556ab5cf6a8d2ef43 Mon Sep 17 00:00:00 2001 From: mango Date: Thu, 12 Jun 2025 11:24:08 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20FilterUnknownT?= =?UTF-8?q?ype=20=E7=9A=84=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/component.test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/component.test.ts b/test/component.test.ts index 0376d91..2fc2334 100644 --- a/test/component.test.ts +++ b/test/component.test.ts @@ -505,3 +505,24 @@ Component<{}, {}, { fn(): void }, []>({ } }) } + +// FilterUnknownType test +{ + 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'; + } + } + }) +} From 74041169a97c2b90c47ade2715bd3012c377b42b Mon Sep 17 00:00:00 2001 From: mango Date: Thu, 12 Jun 2025 11:27:09 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=E5=B0=86=20FilterUnknownType=20?= =?UTF-8?q?=E7=9A=84=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E8=87=B3=20issue.test.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/component.test.ts | 20 -------------------- test/issue.test.ts | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/test/component.test.ts b/test/component.test.ts index 2fc2334..849f9da 100644 --- a/test/component.test.ts +++ b/test/component.test.ts @@ -506,23 +506,3 @@ Component<{}, {}, { fn(): void }, []>({ }) } -// FilterUnknownType test -{ - 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'; - } - } - }) -} diff --git a/test/issue.test.ts b/test/issue.test.ts index 9390d0c..6ff5434 100644 --- a/test/issue.test.ts +++ b/test/issue.test.ts @@ -634,4 +634,25 @@ import WX = WechatMiniprogram }, } }) +} + +// FilterUnknownType test +{ + 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 From 66649c0fe4d3c87f5637da471f45224d7176c56e Mon Sep 17 00:00:00 2001 From: mango Date: Thu, 12 Jun 2025 11:30:50 +0800 Subject: [PATCH 5/5] =?UTF-8?q?docs:=20=E5=B0=86=20FilterUnknownType=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E6=B3=A8=E9=87=8A=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=B8=BApr=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/issue.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/issue.test.ts b/test/issue.test.ts index 6ff5434..08e0d96 100644 --- a/test/issue.test.ts +++ b/test/issue.test.ts @@ -636,7 +636,7 @@ import WX = WechatMiniprogram }) } -// FilterUnknownType test +// https://github.com/wechat-miniprogram/api-typings/pull/351 { type Properties = { customProp: string