Skip to content

Type error with React.Component<void, void> #15419

@DanHarman

Description

@DanHarman

TypeScript Version: 2.3.1

Code

export class NavMenu extends React.Component<void, void> {...}

<NavMenu />

Expected behavior:

It doesn't give a type error.

Actual behavior:

At the location the component is instantiated:

      TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<NavMenu> & { children?: ReactNode; } & void'.
    Type '{}' is not assignable to type 'void'.

This could be a typings error perhaps, but it seems wrong to have to create a functional component to not have any props, or have to make the props type undefined?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions