Allow type system to represent this
in function inputs/outputs · Issue #285 · microsoft/TypeScript (original) (raw)
The early discussions about generics had this feature outlined, but it never made it into the final version for some reason. Meanwhile, it would be extremely helpful in some cases. The use case that it most dear to my heart is Knockout:
interface Observable<T> {
<U>( this: U, value: T ): U;
}
var viewModel = {
Str: ko.observable( "abc" ),
Num: ko.observable( 5 )
};
viewModel.Str( "xyz" ).Num( 10 );