TypeScript/tests/cases/compiler/typePredicateWithThisParameter.ts
2017-04-22 17:09:20 -07:00

27 lines
400 B
TypeScript

// Repro from #15310
interface Foo {
foo: string;
}
interface Bar {
bar: string;
}
function isFoo1(object: {}): object is Foo {
return 'foo' in object;
}
function isFoo2(this: void, object: {}): object is Foo {
return 'foo' in object;
}
declare let test: Foo | Bar;
if (isFoo1(test)) {
test.foo = 'hi';
}
if (isFoo2(test)) {
test.foo = 'hi';
}