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
Personally I don't think this is a bug but rather an improvement.
A method signature will contextually type the object literal itself because this in method is the containing object literal. But an arrow function does not have this.
A user-side fix would be annotate this explicitly:
TypeScript Version: 4.0.0-dev.20200516
Search Terms: object literal inference arrow function method
Expected behavior:
M
in inferred as{ foo: () => void; }
Actual behavior:: When using
function
or method syntaxM
is inferred asunknown
. Using arrow functions works fine.Related Issues: #32230 But that specific case seems fixed
Code
Output
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: