Currently it seems that you can only annotate the this magic reference by putting the function as a method in a class declaration.
However, in the light of the new bind syntax proposal, it would make sense to be able to annotate functions that take in this as data, e.g.
function head (count) {
return this.slice(0, count);
}
[1,2,3]::head(2) // [1,2]
could be annotated something like:
function head <T> Array<T> -> (count : number) : Array<T> {
...
}
Currently it seems that you can only annotate the
thismagic reference by putting the function as a method in a class declaration.However, in the light of the new bind syntax proposal, it would make sense to be able to annotate functions that take in
thisas data, e.g.could be annotated something like: