Skip to content

The returned types of a component should be re-thinked. #3

Description

@thejimmylin

For now the component and JSX related type aliases are like:

/**
 * Component type aliases.
 */
type Component = (props: JsxProps) => Renderable;
type Renderable = JsxNode | NestedArray<JsxNode>;

/**
 * JSX type aliases.
 */
type JsxNode = JsxElement | string;
type JsxElement = { tag: string | Component; props: JsxProps };
type JsxAttrs = { [key: string | symbol]: any };
type JsxProps = JsxAttrs & { children: Array<JsxNode> };

The problem is that the returned type of a component is complicated, which makes the later process of JSX/Fiber/DOM elements complicated, too. If the types of a component could be simpler, it may help a lot.

Also, the fragment should be considered, too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions