Here’s a minimal snippet to reproduce this
class Stuff<InGuild extends boolean = boolean> {
public inGuild(): this is Stuff<true> {
return true;
}
}
const x = new Stuff();
if (x.inGuild()) {
x
}
Hover over x
on VSCode and I see this:
x
is still a Stuff<boolean>
and not a Stuff<true>
, why is that?
I got this idea from discord.js here and I wonder why they can do that and I’m not able to reproduce this here.