You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function getSyntacticNullishnessSemantics(node: Node): PredicateSemantics {
39606
+
node = skipOuterExpressions(node);
39607
+
switch (node.kind) {
39608
+
case SyntaxKind.AwaitExpression:
39609
+
case SyntaxKind.CallExpression:
39610
+
case SyntaxKind.ElementAccessExpression:
39611
+
case SyntaxKind.NewExpression:
39612
+
case SyntaxKind.PropertyAccessExpression:
39613
+
case SyntaxKind.YieldExpression:
39614
+
return PredicateSemantics.Sometimes;
39615
+
case SyntaxKind.BinaryExpression:
39616
+
// List of operators that can produce null/undefined:
39617
+
// = ??= ?? || ||= && &&=
39618
+
switch ((node as BinaryExpression).operatorToken.kind) {
39619
+
case SyntaxKind.EqualsToken:
39620
+
case SyntaxKind.QuestionQuestionToken:
39621
+
case SyntaxKind.QuestionQuestionEqualsToken:
39622
+
case SyntaxKind.BarBarToken:
39623
+
case SyntaxKind.BarBarEqualsToken:
39624
+
case SyntaxKind.AmpersandAmpersandToken:
39625
+
case SyntaxKind.AmpersandAmpersandEqualsToken:
39626
+
return PredicateSemantics.Sometimes;
39627
+
}
39628
+
return PredicateSemantics.Never;
39629
+
case SyntaxKind.ConditionalExpression:
39630
+
return getSyntacticNullishnessSemantics((node as ConditionalExpression).whenTrue) | getSyntacticNullishnessSemantics((node as ConditionalExpression).whenFalse);
39631
+
case SyntaxKind.NullKeyword:
39632
+
return PredicateSemantics.Always;
39633
+
case SyntaxKind.Identifier:
39634
+
if (getResolvedSymbol(node as Identifier) === undefinedSymbol) {
39635
+
return PredicateSemantics.Always;
39636
+
}
39637
+
return PredicateSemantics.Sometimes;
39581
39638
}
39639
+
return PredicateSemantics.Never;
39582
39640
}
39583
39641
39584
39642
// Note that this and `checkBinaryExpression` above should behave mostly the same, except this elides some
@@ -39589,7 +39647,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
0 commit comments