Skip to content

Commit

Permalink
fix(types): relax ComponentPublicInstanceConstructor type for class c…
Browse files Browse the repository at this point in the history
…omponents (#1943)
  • Loading branch information
ktsn authored Aug 25, 2020
1 parent 955450f commit 67b6e0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/runtime-core/src/componentPublicInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export type ComponentPublicInstanceConstructor<
__isFragment?: never
__isTeleport?: never
__isSuspense?: never
new (): T
new (...args: any[]): T
}

export type CreateComponentPublicInstance<
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/h.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test-dts/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 67b6e0f

Please sign in to comment.