Closed
Description
Bug Report
🔎 Search Terms
Type narrowing
🕗 Version & Regression Information
TS - 4.3.2
(Regression not aware)
💻 Code
private _enabled(): boolean {
return this.maxlength ? true : false;
}
private _createValidator(): void {
const maxlength = this.maxlength;
this._validator = (this._enabled()) ? validator(toInteger(maxlength)) : null;
}
🙁 Actual behavior
When using method getting error.
Argument of type 'string | number | null' is not assignable to parameter of type 'string | number'.
while same thing is working when using variable directly.
🙂 Expected behavior
Narrowing should work whether we use method or property.