-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Domain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancements
Milestone
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??
Metadata
Metadata
Assignees
Labels
Domain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancements