Skip to content

method parameter types defined in an interface doesn't apply to an actual class method parameters #53688

Closed
@Jakhongiirr

Description

@Jakhongiirr

###

We don't want to define a type for both in interface and in class as we work with complex nested generic types

we want to see the error during coding, not at compile time

🙁
Current behavior:

interface A {
  method(param: string): void;
}

class B implements A {
  method(param): void {
    // the type of param is any
    console.log(param);
  }
}

const b = new B();
b.method(1); // -> no error

```

🙂
Expected behavior:

interface A {
  method(param: string): void;
}

class B implements A {
  method(param): void {
    // should be type error for param
    console.log(param);
  }
}

const b = new B();
b.method(1); // -> should be type error

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