From b4bf4c52ad31e02307cfd4d643dc5610c893e3ba Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 18 Aug 2022 15:32:12 +0800 Subject: [PATCH] fix(types): allow attaching unknown options to defined component fix #12742 --- types/test/v3/define-component-test.tsx | 4 ++++ types/v3-component-options.d.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/types/test/v3/define-component-test.tsx b/types/test/v3/define-component-test.tsx index 42d0f32eb0d..481a2d11ac7 100644 --- a/types/test/v3/define-component-test.tsx +++ b/types/test/v3/define-component-test.tsx @@ -1165,3 +1165,7 @@ defineComponent({ return h('div', {}, [...this.$slots.default!]) } }) + +// #12742 allow attaching custom properties (consistent with v3) +const Foo = defineComponent({}) +Foo.foobar = 123 diff --git a/types/v3-component-options.d.ts b/types/v3-component-options.d.ts index d8c64ab13ab..e2da34e753f 100644 --- a/types/v3-component-options.d.ts +++ b/types/v3-component-options.d.ts @@ -88,6 +88,9 @@ export interface ComponentOptionsBase< 'data' | 'computed' | 'methods' | 'setup' | 'props' | 'mixins' | 'extends' >, ComponentCustomOptions { + // allow any options + [key: string]: any + // rewrite options api types data?: ( this: CreateComponentPublicInstance,