Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Jakhongiirr opened this issue Apr 6, 2023 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@Jakhongiirr
Copy link

###

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

@fatcerberus
Copy link

fatcerberus commented Apr 6, 2023

This already is an error:

Playground

Parameter 'param' implicitly has an 'any' type.

Make sure you have noImplicitAny (or preferably, strict) enabled.

@MartinJohns
Copy link
Contributor

Duplicate of #32082.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Apr 6, 2023
@Jakhongiirr
Copy link
Author

even after strict and noImplicitAny enabled, this is still an issue, sorry if it is duplicate, it is hard to analyze 5k+ issues

@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants