Skip to content

Type errors when using optional typed children #581

@tomdye

Description

@tomdye

bug

When typing optional children as follows:

type HelloChildRenderer = () => RenderResult;

const factory = create()
  .properties<HelloProperties>()
  .children<HelloChildRenderer | undefined>();

I am given a type error if I try to create the Hello widget using a self closing tag or without passing children. It appears that passing an empty {} child or {undefined} works but this is not ideal.

Please see linked codesandbox example:
https://codesandbox.io/s/dojo-codesandbox-template-eshg6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions