mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 20:25:23 -06:00
Add contextual types infer
This commit is contained in:
parent
f922427196
commit
9190a2c4e8
@ -22365,6 +22365,8 @@ namespace ts {
|
||||
return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive;
|
||||
case SyntaxKind.BarBarToken:
|
||||
case SyntaxKind.QuestionQuestionToken:
|
||||
case SyntaxKind.BarBarEqualsToken:
|
||||
case SyntaxKind.QuestionQuestionEqualsToken:
|
||||
// When an || expression has a contextual type, the operands are contextually typed by that type, except
|
||||
// when that type originates in a binding pattern, the right operand is contextually typed by the type of
|
||||
// the left operand. When an || expression has no contextual type, the right operand is contextually typed
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
// @strict: true
|
||||
// @target: esnext, es2020, es2015
|
||||
|
||||
function foo (f: (a: number) => void | undefined) {
|
||||
f ??= (a => a++)
|
||||
f ||= (a => a++)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user