Skip to content

Commit 9190a2c

Browse files
committed
Add contextual types infer
1 parent f922427 commit 9190a2c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22365,6 +22365,8 @@ namespace ts {
2236522365
return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive;
2236622366
case SyntaxKind.BarBarToken:
2236722367
case SyntaxKind.QuestionQuestionToken:
22368+
case SyntaxKind.BarBarEqualsToken:
22369+
case SyntaxKind.QuestionQuestionEqualsToken:
2236822370
// When an || expression has a contextual type, the operands are contextually typed by that type, except
2236922371
// when that type originates in a binding pattern, the right operand is contextually typed by the type of
2237022372
// the left operand. When an || expression has no contextual type, the right operand is contextually typed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @strict: true
2+
// @target: esnext, es2020, es2015
3+
4+
function foo (f: (a: number) => void | undefined) {
5+
f ??= (a => a++)
6+
f ||= (a => a++)
7+
}

0 commit comments

Comments
 (0)