Change return type of Object
call signature to unknown
(currently any
)
#57379
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
π Search Terms
ObjectConstructor, Object, assignable, function
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEAzArgOzAFwJYHtVJxwAowAjALniIEp4BeAPngGcMYtUBzaygNxyzAA3ACgRiQjSEB6afECg5PACiADwAO4DCGDw4zZBAyUQMGDhjjJNekwBEt6jLmLVGzNt0h9hyqhzwTMwsJYmtGeFQDCEdZBWV1TQ89AyMA03NLYgBvAF9qWJcE9x1knzSgzKIAZTYObic410SSrxTff0CMkKIAOWQAW1ITGOd4ty0W71TOi0qAeVIAK00R+EAZcjHmzynjdIsgA
π» Code
π Actual behavior
Object
(ObjectContructor
) is assignable to any function, because it has a callable signature with return type of any.This lets the developers to use
Object
where only a properly typed function would be allowed, which can lead to unexpected runtime errors.I know this is a pretty edge case, but in my opinion it's worth looking into.
π Expected behavior
Object
is not assignable to functions with different return typeAdditional information about the issue
No response
The text was updated successfully, but these errors were encountered: