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
{{ message }}
Repository navigation
Function types are not as strict as types of functions #20859
This compiles fine, although the function shouldn't be assignable to getX2 IMO. Can this perhaps be more strict? Currently, one has to manually add the return type to the r-value:
constgetX2: XGetter=(): X=>// Added ": X"{return{x: 1,y: 2};// Will now fail here}
While this certainly works, it makes it hard to write libraries (or simple wrappers) that enforce expected behavior, where the users shouldn't have to know to be strict about their callbacks, but rather this be enforced by the library:
// This is in a libraryfunctiongetXFromFun(fn: XGetter){returnfn();}// This is a user using the librarygetXFromFun(()=>({x: 1,y: 2}));// This should fail
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Activity
DanielRosenwasser commentedon Dec 23, 2017
I think this is #241?
grantila commentedon Dec 23, 2017
Yeah more or less, I didn't see that.
typescript-bot commentedon Jan 7, 2018
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.