This code causes an error:
type X<A> = {x: A} interface Foo { // works a(): X<this> // does not work b(): {x: this} }
Output:
foo.ts(7,11): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
It errors if the object type is defined inline, but works for a typedef.
This is by design. See discussion here.
Activity
ahejlsberg commentedon Jan 2, 2016
This is by design. See discussion here.