-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
ThisType doesn't enforce type-checking Object.prototype.call
#59341
Comments
const Foo: { foo(this: { x: number }): number } = {
foo() {
console.log(this.y); // <-- error
return this.x; // okay
}
}
Foo.foo.call({ y: 2 }); // <-- error |
Thanks for the quick reply @jcalz. I know about this parameters, but my point here is that these features may conflict. In addition, when I use |
It's not a bug that |
I understand. I'm not necessarily stating it's a bug. Maybe it's more like a new feature. By the way, I think it may benefit developers. Or maybe I'm wrong. |
This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
π Search Terms
ThisType
ThisType
andcall
π Version & Regression Information
ThisType
β― Playground Link
https://www.typescriptlang.org/play/?ssl=8&ssc=40&pln=1&pc=1#code/MYewdgzgLgBAYiEAuGAVAFgSwqgngBwFMAeAbxgA8UwBXAWwCNCAnGAXwD4YAyGcgM0QAKAJTV6TVmxgBePgCgYMQSFEKlSgPSaYoSCAA2hAHQGQAcyFQsEY7hEBuGNpjEAtG5gtmIZoo3MhFA0zGAw1tjGFA7+bPJx8gggxirGwACGBgZC5LgoAEzsjs467p5gIF7MPsxAA
π» Code
π Actual behavior
The last line doesn't give an error.
π Expected behavior
The last line should give an error.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: