You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionbar<Textends{[key: string]: any}>(value: T){value.hasOwnProperty('foo')}functionfoo<T>(value: T){bar<T>(value)//no error, even though T doesn't match the constraint}bar(undefined)//correctly errors: undefined is not assignable to Tfoo(undefined)//no error, fails at runtime
π Actual behavior
No compile error when calling bar with a type that doesn't match the bounds of T
π Expected behavior
Compile error
The text was updated successfully, but these errors were encountered:
Bug Report
π Search Terms
Generic no constraint call function with no constraint
π Version & Regression Information
4.3.0-dev-20210504
β― Playground Link
https://www.typescriptlang.org/play?ts=4.3.0-dev.20210506#code/GYVwdgxgLglg9mABAIwIYCcA8AVRBTADyjzABMBnRAbwG0BrPATwC5Fyp0YwBzAXVdRhGAXwB8ACgBuqADYg8rbAEpqAKEQbE0uXgB0AC1TkA8gHcwABXRwADnnRRG4gOTA4cZ0tXDVq0JFgERDc4HAlteUUlKnVNNCxscNl5FQB6VLA4fHRrdAAafEkSRCh9OBBufURcUjg8cjBnKEQAW1QoCCrSvEQIBHZ0VC4ob1948XBSPGAuPFI01L6cvGgZRmzc8lZJ6dnSRBhKTOajchhuMFRkGR6oLOw-dwmyXbA5hcyNuHzgoZlKdqIdDgWAtPBAA
π» Code
π Actual behavior
No compile error when calling
bar
with a type that doesn't match the bounds ofT
π Expected behavior
Compile error
The text was updated successfully, but these errors were encountered: