diff --git a/packages/runtime-core/src/apiDefineComponent.ts b/packages/runtime-core/src/apiDefineComponent.ts index ef08d3c6533..9b85638c2dd 100644 --- a/packages/runtime-core/src/apiDefineComponent.ts +++ b/packages/runtime-core/src/apiDefineComponent.ts @@ -94,8 +94,8 @@ export function defineComponent< Props = {}, RawBindings = {}, D = {}, - C extends ComputedOptions = ComputedOptions, - M extends MethodOptions = MethodOptions, + C extends ComputedOptions = {}, + M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index 0ff710c36c6..69f1f2afd1e 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -166,8 +166,7 @@ export type ComponentOptionsWithoutProps< Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, - EE extends string = string, - Defaults = {} + EE extends string = string > = ComponentOptionsBase< Props, RawBindings, @@ -178,23 +177,11 @@ export type ComponentOptionsWithoutProps< Extends, E, EE, - Defaults + {} > & { props?: undefined } & ThisType< - CreateComponentPublicInstance< - {}, - RawBindings, - D, - C, - M, - Mixin, - Extends, - E, - Readonly, - Defaults, - false - > + CreateComponentPublicInstance<{}, RawBindings, D, C, M, Mixin, Extends, E> > export type ComponentOptionsWithArrayProps< diff --git a/test-dts/component.test-d.ts b/test-dts/component.test-d.ts index 990e370518b..30b3b8e5f53 100644 --- a/test-dts/component.test-d.ts +++ b/test-dts/component.test-d.ts @@ -190,6 +190,12 @@ describe('object props', () => { expectType(setup.setupProps.ggg) expectType(setup.setupProps.ffff) expectType(setup.setupProps.validated) + + // instance + const instance = new MyComponent() + expectType(instance.setupA) + // @ts-expect-error + instance.notExist }) describe('options', () => { @@ -356,6 +362,12 @@ describe('no props', () => { expectType(rawBindings.setupA) expectType(setup.setupA) + + // instance + const instance = new MyComponent() + expectType(instance.setupA) + // @ts-expect-error + instance.notExist }) describe('options', () => {