fix: type signature of Component too narrow
This commit is contained in:
parent
8dd0fb94e9
commit
cbd80f381c
4 changed files with 23 additions and 7 deletions
|
|
@ -37,9 +37,7 @@ export type Element =
|
|||
/**
|
||||
* Custom HTMLElement factory that can be parameterized by props.
|
||||
*/
|
||||
export interface Component<
|
||||
P extends Record<string, unknown> = Record<string, never>
|
||||
> {
|
||||
export interface Component<P extends object = {}> {
|
||||
(
|
||||
props: P & {
|
||||
children?: Element[];
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import { flatDeep } from "./utils";
|
|||
*
|
||||
* @return Fully-realized HTMLElement, ready for rendering.
|
||||
*/
|
||||
export function createElement<P extends Record<string, unknown>>(
|
||||
export function createElement<P extends object>(
|
||||
comp: Component<P>,
|
||||
props: P,
|
||||
...children: Element[]
|
||||
|
|
@ -38,8 +38,8 @@ export function createElement(
|
|||
...children: Element[]
|
||||
): HTMLElement;
|
||||
export function createElement(
|
||||
type: string | Component<Record<string, unknown>>,
|
||||
props: HTMLAttributes | Record<string, unknown> | null,
|
||||
type: string | Component<any>,
|
||||
props: object | null,
|
||||
...children: Element[]
|
||||
): HTMLElement {
|
||||
// Flatten the children array so we can accept arrays as children.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue