-
Notifications
You must be signed in to change notification settings - Fork 12.4k
-
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
Interface implementation may have more-specific argument types than interface #46999
Comments
Thanks! I suspected it was probably something like that, just didn't quite know how to search for it. Hopefully this will help other people find the issue. At the very least I wish this behavior would be revisited for "simple" types (i.e., scalars) since it effectively disables strict null checking when implementing a function. I discovered the issue when I did something like this: Sentry.init({
beforeSend(event: Sentry.Event, hint: Sentry.Hint) { ... }
}) since TS didn't warn me that the hint param can be undefined. But feel free to close if that discussion is already been had or out of scope. |
This is a very commonly encountered issue, for what it's worth. If you're able to use |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
🔎 Search Terms
interface, variance (covariance, contravariance), interface methods, implementation, soundness, unsoundness, narrowing, interface assignability
🕗 Version & Regression Information
Seems to effect every version of TypeScript I tried on the Playground (3.X and 4.X).
⏯ Playground Link
https://www.typescriptlang.org/play?ts=4.5.2#code/PTAEFkE9QYwewCYFNQHM5IM6gBZIE5IBQRAlgHYAuBAZgIYwoCqmBoA3kaN6OXQLZIAXKEyV8FVAG4iAXxIVq+eo1ABxQkiUcuaTZQAUmOgBsArpTqVScciLETyqADSgzrfAH4RLNgB9eM34AIwIASntxSRl5InhyMVAaOHx+Uw0kLQIRDKz8UABeHW5UfSNXd2zQX3ww4p4QHiamgD02lt1uRoBlHDgzEwReOEpQUNBTEzgAdyQEEQADGtAA8iDQ-ICzcmQaCjmF0AMafDh+dX1wztBGzD6BofIRsZQ6TExSVD5gkxRKOFASw8hzwhAAdNdCJQzPhyICACTsTCyUD8aDIOiERKIyr4MF8QSyBYyJqNZrkinNdrUtrXRoAdVIJhMoEoOFO0wmoHw22sglABFO+VCMDolTcHlRdGgDGhk2g422u32CDpYBSXLWIQIEO4smcchkcVsmDgvzBU1QxxSaRMuSUYNKmUMACI8My4C7XOxeAJhKAXQAVfB0ABupEwLtAsjCYRk8VN5st1tS6UueKdWgMbqQHpdsZkQA
💻 Code
🙁 Actual behavior
Should not typecheck (see comments above). The implementation given should not be assignable to
Greeter
.🙂 Expected behavior
Typechecks successfully.
The text was updated successfully, but these errors were encountered: