Skip to content

Infer arguments types from interface #16944

Closed
@patrick91

Description

@patrick91

I've tried to look for this issues, but I didn't find any.
Here's an example of the problem:

interface IComponentLifecycle<P> {
  componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
}

interface IProps {
  hello: string;
}

class X implements IComponentLifecycle<IProps> {
  componentWillReceiveProps(nextProps) { // <-- nextProps is any
    // TODO: logic
  }
}

This is based on react's typings (that's how I found the issue).

Is this an expected behaviour or not?

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