mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Component commits:7be925173cExclude ?? operator from true/false literal check in createFlowConditionb9802166aeAccept new API baselines3d4c14c5f8Add tests7362545e8cAccept new baselines2d1af77839Address CR feedback8f0de27784Accept new API baselines
This commit is contained in:
committed by
Daniel Rosenwasser
parent
db419ff5ab
commit
330c8acda2
@@ -1,3 +1,4 @@
|
||||
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
export const enum ModuleInstanceState {
|
||||
@@ -951,11 +952,10 @@ namespace ts {
|
||||
if (!expression) {
|
||||
return flags & FlowFlags.TrueCondition ? antecedent : unreachableFlow;
|
||||
}
|
||||
if (expression.kind === SyntaxKind.TrueKeyword && flags & FlowFlags.FalseCondition ||
|
||||
expression.kind === SyntaxKind.FalseKeyword && flags & FlowFlags.TrueCondition) {
|
||||
if (!isExpressionOfOptionalChainRoot(expression)) {
|
||||
return unreachableFlow;
|
||||
}
|
||||
if ((expression.kind === SyntaxKind.TrueKeyword && flags & FlowFlags.FalseCondition ||
|
||||
expression.kind === SyntaxKind.FalseKeyword && flags & FlowFlags.TrueCondition) &&
|
||||
!isExpressionOfOptionalChainRoot(expression) && !isNullishCoalesce(expression.parent)) {
|
||||
return unreachableFlow;
|
||||
}
|
||||
if (!isNarrowingExpression(expression)) {
|
||||
return antecedent;
|
||||
|
||||
@@ -5925,6 +5925,10 @@ namespace ts {
|
||||
return isOptionalChainRoot(node.parent) && node.parent.expression === node;
|
||||
}
|
||||
|
||||
export function isNullishCoalesce(node: Node) {
|
||||
return node.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>node).operatorToken.kind === SyntaxKind.QuestionQuestionToken;
|
||||
}
|
||||
|
||||
export function isNewExpression(node: Node): node is NewExpression {
|
||||
return node.kind === SyntaxKind.NewExpression;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user