Skip to content

Commit 6d763a9

Browse files
committed
fix: relax ComponentPublicInstanceConstructor type for class components
1 parent 31b99a9 commit 6d763a9

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

packages/runtime-core/src/componentPublicInstance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export type ComponentPublicInstanceConstructor<
107107
__isFragment?: never
108108
__isTeleport?: never
109109
__isSuspense?: never
110-
new (): T
110+
new (...args: never[]): T
111111
}
112112

113113
export type CreateComponentPublicInstance<

packages/runtime-core/src/h.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ interface Constructor<P = any> {
6565
__isFragment?: never
6666
__isTeleport?: never
6767
__isSuspense?: never
68-
new (): { $props: P }
68+
new (...args: never[]): { $props: P }
6969
}
7070

7171
// The following is a series of overloads for providing props validation of

test-dts/defineComponent.test-d.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('with object props', () => {
9494
// default + function
9595
ffff: {
9696
type: Function as PropType<(a: number, b: string) => { a: boolean }>,
97-
default: (a: number, b: string) => ({ a: true })
97+
default: (_a: number, _b: string) => ({ a: true })
9898
},
9999
validated: {
100100
type: String,
@@ -701,6 +701,16 @@ describe('defineComponent', () => {
701701
components: { comp }
702702
})
703703
})
704+
705+
test('should accept class components with receiving constructor arguments', () => {
706+
class Comp {
707+
static __vccOpts = {}
708+
constructor(_props: { foo: string }) {}
709+
}
710+
defineComponent({
711+
components: { Comp }
712+
})
713+
})
704714
})
705715

706716
describe('emits', () => {

0 commit comments

Comments
 (0)