Code QuizIntermediate Losing this-Type in a Chain
Finding why a fluent method breaks chaining when it hardcodes the return type.
Codetypescript
class QueryBuilder {
private parts: string[] = [];
where(cond: string): QueryBuilder {
this.parts.push(cond);
return this;
}
}
class AdminQuery extends QueryBuilder {
onlyAdmins(): this {
return this;
}
}
new AdminQuery().where("active").onlyAdmins();What is the bug in this code?