Skip to content

Commit 67b6e0f

Browse files
authored
fix(types): relax ComponentPublicInstanceConstructor type for class components (#1943)
1 parent 955450f commit 67b6e0f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
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: any[]): 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: any[]): { $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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)