In TypeScript 2.0, why can I have a function type guard:
function hasValue<T>(value: T | undefined): value is T { return value !== undefined; }
But not a method type guard?:
export class Maybe<T> {
constructor(public value: T | undefined) {}
hasValue(): this.value is T { return this.value !== undefined; }
}
error on hasValue()
:
'{' or ';' expected.