Skip to content

typeof React.Component stopped working #18946

@mikew

Description

@mikew

TypeScript Version: 2.5.3

Code

class MyComponent extends React.Component<{}, {}> { render () { return null } } function thisTakesAComponent (component: typeof React.Component) { } thisTakesAComponent(MyComponent)

Expected behavior:
Should compile fine.

Actual behavior:

Argument of type 'typeof MyComponent' is not assignable to parameter of type 'typeof Component'. Type 'MyComponent' is not assignable to type 'Component<P, S>'. Types of property 'setState' are incompatible. Type '{ <K extends never>(f: (prevState: {}, props: {}) => Pick<{}, K>, callback?: (() => any) | undefi...' is not assignable to type '{ <K extends keyof S>(f: (prevState: S, props: P) => Pick<S, K>, callback?: (() => any) | undefin...'. Types of parameters 'f' and 'f' are incompatible. Types of parameters 'prevState' and 'prevState' are incompatible. Type '{}' is not assignable to type 'S'. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions