Closed
Description
class Foo {
bar?: Foo
public setBar(): asserts this is Foo & {bar: Foo} {
this.bar = this;
}
public sayHi(): string {
return 'Hi!';
}
}
function test() {
let foo = new Foo();
foo.bar = undefined;
foo.setBar();
if (foo.bar) {
console.log('This should be OK: ' + foo.bar.sayHi());
}
}
Current error
Assertions require every name in the call target to be declared with an explicit type annotation.
'foo' is declared here.
foo
is declared here but... but okay so what am I supposed to do now??