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
Update: function(this) {} already be supported by TS from 2016, also supported by Closure compiler (search "function this type"), and also have PR in Flowtype.
Original comment:
This is the example of current proposal:
functionmethod(thiselem,e){console.log("Elem:",elem)// OKconsole.log("this:",this)// <-- Throws an error!}
I suggest allow this inside the body if no explicit name provided, so we can write:
As I understand, it won't break backwards compatibility. this in parameter position is syntax error now. For example new Function('this', '') throw SyntaxError.
Update:
function(this) {}
already be supported by TS from 2016, also supported by Closure compiler (search "function this type"), and also have PR in Flowtype.Original comment:
This is the example of current proposal:
I suggest allow
this
inside the body if no explicit name provided, so we can write:Though it looks redundant, it will be useful for type annotation (See microsoft/TypeScript#6739 and facebook/flow#452 (comment)), and linter (See http://eslint.org/docs/rules/no-invalid-this and http://eslint.org/docs/rules/prefer-arrow-callback#allowunboundthis).
Update: I changed my mind that this part should be leave to linters.
Original comments:
And current proposal allow
this
in inner functions:I suggest do not allow it, but require adding
this
in the arguments:The text was updated successfully, but these errors were encountered: