fix(types): relax ComponentPublicInstanceConstructor type for class components (#1943)

This commit is contained in:
Katashin 2020-08-25 09:53:30 +08:00 committed by GitHub
parent 955450f539
commit 67b6e0f894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -107,7 +107,7 @@ export type ComponentPublicInstanceConstructor<
__isFragment?: never
__isTeleport?: never
__isSuspense?: never
new (): T
new (...args: any[]): T
}
export type CreateComponentPublicInstance<

View File

@ -65,7 +65,7 @@ interface Constructor<P = any> {
__isFragment?: never
__isTeleport?: never
__isSuspense?: never
new (): { $props: P }
new (...args: any[]): { $props: P }
}
// The following is a series of overloads for providing props validation of

View File

@ -701,6 +701,16 @@ describe('defineComponent', () => {
components: { comp }
})
})
test('should accept class components with receiving constructor arguments', () => {
class Comp {
static __vccOpts = {}
constructor(_props: { foo: string }) {}
}
defineComponent({
components: { Comp }
})
})
})
describe('emits', () => {