Closed
Description
TypeScript Version: 3.4.5
Search Terms:
instanceof
Code
// this works
if (target instanceof DatasourceCommandWidgetElement) {
this._commandBased = true;
this._commandElement = target.commandElement;
} else {
this._commandBased = false;
}
// this fails
if (this._commandBased = (target instanceof DatasourceCommandWidgetElement)) {
this._commandElement = target.commandElement;
}
Expected behavior:
Type inference respected.
Actual behavior:
Type inference missed.
Related Issues:
Might be related to 31291 but, in this case, the if statement directly wraps the type-inferenced instruction. Could be that the assigned variable (kind-of-)takes control and the cast gets lost...