Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chain RHS narrowing and truthiness narrowing in assignment expression…
… narrowing (#31348)
- Loading branch information
Showing
9 changed files
with
194 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/controlFlowForCompoundAssignmentToThisMember.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//// [controlFlowForCompoundAssignmentToThisMember.ts] | ||
class DatasourceCommandWidgetElement { | ||
_commandBased: boolean; | ||
_commandElement: unknown; | ||
commandElement: unknown; | ||
|
||
constructor(target: unknown) { | ||
if (target instanceof DatasourceCommandWidgetElement) { | ||
this._commandBased = true; | ||
this._commandElement = target.commandElement; | ||
} else { | ||
this._commandBased = false; | ||
} | ||
|
||
if (this._commandBased = (target instanceof DatasourceCommandWidgetElement)) { | ||
this._commandElement = target.commandElement; | ||
} | ||
} | ||
} | ||
|
||
//// [controlFlowForCompoundAssignmentToThisMember.js] | ||
var DatasourceCommandWidgetElement = /** @class */ (function () { | ||
function DatasourceCommandWidgetElement(target) { | ||
if (target instanceof DatasourceCommandWidgetElement) { | ||
this._commandBased = true; | ||
this._commandElement = target.commandElement; | ||
} | ||
else { | ||
this._commandBased = false; | ||
} | ||
if (this._commandBased = (target instanceof DatasourceCommandWidgetElement)) { | ||
this._commandElement = target.commandElement; | ||
} | ||
} | ||
return DatasourceCommandWidgetElement; | ||
}()); |
57 changes: 57 additions & 0 deletions
57
tests/baselines/reference/controlFlowForCompoundAssignmentToThisMember.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
=== tests/cases/compiler/controlFlowForCompoundAssignmentToThisMember.ts === | ||
class DatasourceCommandWidgetElement { | ||
>DatasourceCommandWidgetElement : Symbol(DatasourceCommandWidgetElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 0)) | ||
|
||
_commandBased: boolean; | ||
>_commandBased : Symbol(DatasourceCommandWidgetElement._commandBased, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 38)) | ||
|
||
_commandElement: unknown; | ||
>_commandElement : Symbol(DatasourceCommandWidgetElement._commandElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 1, 27)) | ||
|
||
commandElement: unknown; | ||
>commandElement : Symbol(DatasourceCommandWidgetElement.commandElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 2, 29)) | ||
|
||
constructor(target: unknown) { | ||
>target : Symbol(target, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 5, 16)) | ||
|
||
if (target instanceof DatasourceCommandWidgetElement) { | ||
>target : Symbol(target, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 5, 16)) | ||
>DatasourceCommandWidgetElement : Symbol(DatasourceCommandWidgetElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 0)) | ||
|
||
this._commandBased = true; | ||
>this._commandBased : Symbol(DatasourceCommandWidgetElement._commandBased, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 38)) | ||
>this : Symbol(DatasourceCommandWidgetElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 0)) | ||
>_commandBased : Symbol(DatasourceCommandWidgetElement._commandBased, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 38)) | ||
|
||
this._commandElement = target.commandElement; | ||
>this._commandElement : Symbol(DatasourceCommandWidgetElement._commandElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 1, 27)) | ||
>this : Symbol(DatasourceCommandWidgetElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 0)) | ||
>_commandElement : Symbol(DatasourceCommandWidgetElement._commandElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 1, 27)) | ||
>target.commandElement : Symbol(DatasourceCommandWidgetElement.commandElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 2, 29)) | ||
>target : Symbol(target, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 5, 16)) | ||
>commandElement : Symbol(DatasourceCommandWidgetElement.commandElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 2, 29)) | ||
|
||
} else { | ||
this._commandBased = false; | ||
>this._commandBased : Symbol(DatasourceCommandWidgetElement._commandBased, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 38)) | ||
>this : Symbol(DatasourceCommandWidgetElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 0)) | ||
>_commandBased : Symbol(DatasourceCommandWidgetElement._commandBased, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 38)) | ||
} | ||
|
||
if (this._commandBased = (target instanceof DatasourceCommandWidgetElement)) { | ||
>this._commandBased : Symbol(DatasourceCommandWidgetElement._commandBased, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 38)) | ||
>this : Symbol(DatasourceCommandWidgetElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 0)) | ||
>_commandBased : Symbol(DatasourceCommandWidgetElement._commandBased, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 38)) | ||
>target : Symbol(target, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 5, 16)) | ||
>DatasourceCommandWidgetElement : Symbol(DatasourceCommandWidgetElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 0)) | ||
|
||
this._commandElement = target.commandElement; | ||
>this._commandElement : Symbol(DatasourceCommandWidgetElement._commandElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 1, 27)) | ||
>this : Symbol(DatasourceCommandWidgetElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 0, 0)) | ||
>_commandElement : Symbol(DatasourceCommandWidgetElement._commandElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 1, 27)) | ||
>target.commandElement : Symbol(DatasourceCommandWidgetElement.commandElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 2, 29)) | ||
>target : Symbol(target, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 5, 16)) | ||
>commandElement : Symbol(DatasourceCommandWidgetElement.commandElement, Decl(controlFlowForCompoundAssignmentToThisMember.ts, 2, 29)) | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
tests/baselines/reference/controlFlowForCompoundAssignmentToThisMember.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
=== tests/cases/compiler/controlFlowForCompoundAssignmentToThisMember.ts === | ||
class DatasourceCommandWidgetElement { | ||
>DatasourceCommandWidgetElement : DatasourceCommandWidgetElement | ||
|
||
_commandBased: boolean; | ||
>_commandBased : boolean | ||
|
||
_commandElement: unknown; | ||
>_commandElement : unknown | ||
|
||
commandElement: unknown; | ||
>commandElement : unknown | ||
|
||
constructor(target: unknown) { | ||
>target : unknown | ||
|
||
if (target instanceof DatasourceCommandWidgetElement) { | ||
>target instanceof DatasourceCommandWidgetElement : boolean | ||
>target : unknown | ||
>DatasourceCommandWidgetElement : typeof DatasourceCommandWidgetElement | ||
|
||
this._commandBased = true; | ||
>this._commandBased = true : true | ||
>this._commandBased : boolean | ||
>this : this | ||
>_commandBased : boolean | ||
>true : true | ||
|
||
this._commandElement = target.commandElement; | ||
>this._commandElement = target.commandElement : unknown | ||
>this._commandElement : unknown | ||
>this : this | ||
>_commandElement : unknown | ||
>target.commandElement : unknown | ||
>target : DatasourceCommandWidgetElement | ||
>commandElement : unknown | ||
|
||
} else { | ||
this._commandBased = false; | ||
>this._commandBased = false : false | ||
>this._commandBased : boolean | ||
>this : this | ||
>_commandBased : boolean | ||
>false : false | ||
} | ||
|
||
if (this._commandBased = (target instanceof DatasourceCommandWidgetElement)) { | ||
>this._commandBased = (target instanceof DatasourceCommandWidgetElement) : boolean | ||
>this._commandBased : boolean | ||
>this : this | ||
>_commandBased : boolean | ||
>(target instanceof DatasourceCommandWidgetElement) : boolean | ||
>target instanceof DatasourceCommandWidgetElement : boolean | ||
>target : unknown | ||
>DatasourceCommandWidgetElement : typeof DatasourceCommandWidgetElement | ||
|
||
this._commandElement = target.commandElement; | ||
>this._commandElement = target.commandElement : unknown | ||
>this._commandElement : unknown | ||
>this : this | ||
>_commandElement : unknown | ||
>target.commandElement : unknown | ||
>target : DatasourceCommandWidgetElement | ||
>commandElement : unknown | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/cases/compiler/controlFlowForCompoundAssignmentToThisMember.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
class DatasourceCommandWidgetElement { | ||
_commandBased: boolean; | ||
_commandElement: unknown; | ||
commandElement: unknown; | ||
|
||
constructor(target: unknown) { | ||
if (target instanceof DatasourceCommandWidgetElement) { | ||
this._commandBased = true; | ||
this._commandElement = target.commandElement; | ||
} else { | ||
this._commandBased = false; | ||
} | ||
|
||
if (this._commandBased = (target instanceof DatasourceCommandWidgetElement)) { | ||
this._commandElement = target.commandElement; | ||
} | ||
} | ||
} |