This commit is contained in:
kingwl
2020-04-01 23:39:38 +08:00
parent 9190a2c4e8
commit 82fe658a48
53 changed files with 2510 additions and 4 deletions

View File

@@ -1041,6 +1041,17 @@ namespace ts {
}
}
function isLogicalAssignmentExpressioin(node: Node) {
while (true) {
if (isParenthesizedExpression(node)) {
node = node.expression
}
else {
return isBinaryExpression(node) && isLogicalAssignmentOperator(node.operatorToken.kind);
}
}
}
function isTopLevelLogicalExpression(node: Node): boolean {
while (isParenthesizedExpression(node.parent) ||
isPrefixUnaryExpression(node.parent) && node.parent.operator === SyntaxKind.ExclamationToken) {
@@ -1063,7 +1074,7 @@ namespace ts {
function bindCondition(node: Expression | undefined, trueTarget: FlowLabel, falseTarget: FlowLabel) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!node || !isLogicalExpression(node) && !(isOptionalChain(node) && isOutermostOptionalChain(node))) {
if (!node || !isLogicalAssignmentExpressioin(node) && !isLogicalExpression(node) && !(isOptionalChain(node) && isOutermostOptionalChain(node))) {
addAntecedent(trueTarget, createFlowCondition(FlowFlags.TrueCondition, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(FlowFlags.FalseCondition, currentFlow, node));
}
@@ -1163,6 +1174,25 @@ namespace ts {
currentFlow = finishFlowLabel(postIfLabel);
}
function bindLogicalAssignmentExpression(node: BinaryExpression) {
const preRightLabel = createBranchLabel();
const postExpressionLabel = createBranchLabel();
if (node.operatorToken.kind === SyntaxKind.AmpersandAmpersandEqualsToken) {
bindCondition(node.left, preRightLabel, postExpressionLabel);
}
else {
bindCondition(node.left, postExpressionLabel, preRightLabel);
}
currentFlow = finishFlowLabel(preRightLabel);
bind(node.operatorToken);
bind(node.right);
bindAssignmentTargetFlow(node.left);
currentFlow = finishFlowLabel(postExpressionLabel);
}
function bindReturnOrThrow(node: ReturnStatement | ThrowStatement): void {
bind(node.expression);
if (node.kind === SyntaxKind.ReturnStatement) {
@@ -1450,6 +1480,10 @@ namespace ts {
}
function bindBinaryExpressionFlow(node: BinaryExpression) {
const flow = currentFlow
if (flow) {
}
const workStacks: {
expr: BinaryExpression[],
state: BindBinaryExpressionFlowState[],
@@ -1511,6 +1545,10 @@ namespace ts {
}
completeNode();
}
else if(isLogicalAssignmentOperator(operator)) {
bindLogicalAssignmentExpression(node);
completeNode();
}
else {
advanceState(BindBinaryExpressionFlowState.BindToken);
maybeBind(node.left);

View File

@@ -0,0 +1,33 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment4.ts(25,21): error TS2532: Object is possibly 'undefined'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment4.ts (1 errors) ====
function foo1(results: number[] | undefined) {
(results ||= []).push(100);
}
function foo2(results: number[] | undefined) {
(results ??= []).push(100);
}
function foo3(results: number[] | undefined) {
results ||= [];
results.push(100);
}
function foo4(results: number[] | undefined) {
results ||= [];
results.push(100);
}
interface ThingWithOriginal {
name: string;
original?: ThingWithOriginal
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
if (thing &&= thing.original) {
console.log(thing.name);
~~~~~
!!! error TS2532: Object is possibly 'undefined'.
}
}

View File

@@ -5,6 +5,26 @@ function foo1(results: number[] | undefined) {
function foo2(results: number[] | undefined) {
(results ??= []).push(100);
}
function foo3(results: number[] | undefined) {
results ||= [];
results.push(100);
}
function foo4(results: number[] | undefined) {
results ||= [];
results.push(100);
}
interface ThingWithOriginal {
name: string;
original?: ThingWithOriginal
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
if (thing &&= thing.original) {
console.log(thing.name);
}
}
//// [logicalAssignment4.js]
@@ -15,3 +35,16 @@ function foo1(results) {
function foo2(results) {
(results !== null && results !== void 0 ? results : (results = [])).push(100);
}
function foo3(results) {
results || (results = []);
results.push(100);
}
function foo4(results) {
results || (results = []);
results.push(100);
}
function doSomethingWithAlias(thing) {
if (thing && (thing = thing.original)) {
console.log(thing.name);
}
}

View File

@@ -18,3 +18,60 @@ function foo2(results: number[] | undefined) {
>results : Symbol(results, Decl(logicalAssignment4.ts, 4, 14))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo3(results: number[] | undefined) {
>foo3 : Symbol(foo3, Decl(logicalAssignment4.ts, 6, 1))
>results : Symbol(results, Decl(logicalAssignment4.ts, 8, 14))
results ||= [];
>results : Symbol(results, Decl(logicalAssignment4.ts, 8, 14))
results.push(100);
>results.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment4.ts, 8, 14))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo4(results: number[] | undefined) {
>foo4 : Symbol(foo4, Decl(logicalAssignment4.ts, 11, 1))
>results : Symbol(results, Decl(logicalAssignment4.ts, 13, 14))
results ||= [];
>results : Symbol(results, Decl(logicalAssignment4.ts, 13, 14))
results.push(100);
>results.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment4.ts, 13, 14))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
interface ThingWithOriginal {
>ThingWithOriginal : Symbol(ThingWithOriginal, Decl(logicalAssignment4.ts, 16, 1))
name: string;
>name : Symbol(ThingWithOriginal.name, Decl(logicalAssignment4.ts, 18, 29))
original?: ThingWithOriginal
>original : Symbol(ThingWithOriginal.original, Decl(logicalAssignment4.ts, 19, 17))
>ThingWithOriginal : Symbol(ThingWithOriginal, Decl(logicalAssignment4.ts, 16, 1))
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
>doSomethingWithAlias : Symbol(doSomethingWithAlias, Decl(logicalAssignment4.ts, 21, 1))
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>ThingWithOriginal : Symbol(ThingWithOriginal, Decl(logicalAssignment4.ts, 16, 1))
if (thing &&= thing.original) {
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>thing.original : Symbol(ThingWithOriginal.original, Decl(logicalAssignment4.ts, 19, 17))
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>original : Symbol(ThingWithOriginal.original, Decl(logicalAssignment4.ts, 19, 17))
console.log(thing.name);
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>thing.name : Symbol(ThingWithOriginal.name, Decl(logicalAssignment4.ts, 18, 29))
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>name : Symbol(ThingWithOriginal.name, Decl(logicalAssignment4.ts, 18, 29))
}
}

View File

@@ -28,3 +28,66 @@ function foo2(results: number[] | undefined) {
>push : (...items: number[]) => number
>100 : 100
}
function foo3(results: number[] | undefined) {
>foo3 : (results: number[] | undefined) => void
>results : number[] | undefined
results ||= [];
>results ||= [] : number[]
>results : number[] | undefined
>[] : never[]
results.push(100);
>results.push(100) : number
>results.push : (...items: number[]) => number
>results : number[]
>push : (...items: number[]) => number
>100 : 100
}
function foo4(results: number[] | undefined) {
>foo4 : (results: number[] | undefined) => void
>results : number[] | undefined
results ||= [];
>results ||= [] : number[]
>results : number[] | undefined
>[] : never[]
results.push(100);
>results.push(100) : number
>results.push : (...items: number[]) => number
>results : number[]
>push : (...items: number[]) => number
>100 : 100
}
interface ThingWithOriginal {
name: string;
>name : string
original?: ThingWithOriginal
>original : ThingWithOriginal | undefined
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
>doSomethingWithAlias : (thing?: ThingWithOriginal | undefined) => void
>thing : ThingWithOriginal | undefined
if (thing &&= thing.original) {
>thing &&= thing.original : ThingWithOriginal | undefined
>thing : ThingWithOriginal | undefined
>thing.original : ThingWithOriginal | undefined
>thing : ThingWithOriginal
>original : ThingWithOriginal | undefined
console.log(thing.name);
>console.log(thing.name) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>thing.name : string
>thing : ThingWithOriginal | undefined
>name : string
}
}

View File

@@ -0,0 +1,33 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment4.ts(25,21): error TS2532: Object is possibly 'undefined'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment4.ts (1 errors) ====
function foo1(results: number[] | undefined) {
(results ||= []).push(100);
}
function foo2(results: number[] | undefined) {
(results ??= []).push(100);
}
function foo3(results: number[] | undefined) {
results ||= [];
results.push(100);
}
function foo4(results: number[] | undefined) {
results ||= [];
results.push(100);
}
interface ThingWithOriginal {
name: string;
original?: ThingWithOriginal
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
if (thing &&= thing.original) {
console.log(thing.name);
~~~~~
!!! error TS2532: Object is possibly 'undefined'.
}
}

View File

@@ -5,6 +5,26 @@ function foo1(results: number[] | undefined) {
function foo2(results: number[] | undefined) {
(results ??= []).push(100);
}
function foo3(results: number[] | undefined) {
results ||= [];
results.push(100);
}
function foo4(results: number[] | undefined) {
results ||= [];
results.push(100);
}
interface ThingWithOriginal {
name: string;
original?: ThingWithOriginal
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
if (thing &&= thing.original) {
console.log(thing.name);
}
}
//// [logicalAssignment4.js]
@@ -15,3 +35,16 @@ function foo1(results) {
function foo2(results) {
(results ?? (results = [])).push(100);
}
function foo3(results) {
results || (results = []);
results.push(100);
}
function foo4(results) {
results || (results = []);
results.push(100);
}
function doSomethingWithAlias(thing) {
if (thing && (thing = thing.original)) {
console.log(thing.name);
}
}

View File

@@ -18,3 +18,60 @@ function foo2(results: number[] | undefined) {
>results : Symbol(results, Decl(logicalAssignment4.ts, 4, 14))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo3(results: number[] | undefined) {
>foo3 : Symbol(foo3, Decl(logicalAssignment4.ts, 6, 1))
>results : Symbol(results, Decl(logicalAssignment4.ts, 8, 14))
results ||= [];
>results : Symbol(results, Decl(logicalAssignment4.ts, 8, 14))
results.push(100);
>results.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment4.ts, 8, 14))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo4(results: number[] | undefined) {
>foo4 : Symbol(foo4, Decl(logicalAssignment4.ts, 11, 1))
>results : Symbol(results, Decl(logicalAssignment4.ts, 13, 14))
results ||= [];
>results : Symbol(results, Decl(logicalAssignment4.ts, 13, 14))
results.push(100);
>results.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment4.ts, 13, 14))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
interface ThingWithOriginal {
>ThingWithOriginal : Symbol(ThingWithOriginal, Decl(logicalAssignment4.ts, 16, 1))
name: string;
>name : Symbol(ThingWithOriginal.name, Decl(logicalAssignment4.ts, 18, 29))
original?: ThingWithOriginal
>original : Symbol(ThingWithOriginal.original, Decl(logicalAssignment4.ts, 19, 17))
>ThingWithOriginal : Symbol(ThingWithOriginal, Decl(logicalAssignment4.ts, 16, 1))
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
>doSomethingWithAlias : Symbol(doSomethingWithAlias, Decl(logicalAssignment4.ts, 21, 1))
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>ThingWithOriginal : Symbol(ThingWithOriginal, Decl(logicalAssignment4.ts, 16, 1))
if (thing &&= thing.original) {
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>thing.original : Symbol(ThingWithOriginal.original, Decl(logicalAssignment4.ts, 19, 17))
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>original : Symbol(ThingWithOriginal.original, Decl(logicalAssignment4.ts, 19, 17))
console.log(thing.name);
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>thing.name : Symbol(ThingWithOriginal.name, Decl(logicalAssignment4.ts, 18, 29))
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>name : Symbol(ThingWithOriginal.name, Decl(logicalAssignment4.ts, 18, 29))
}
}

View File

@@ -28,3 +28,66 @@ function foo2(results: number[] | undefined) {
>push : (...items: number[]) => number
>100 : 100
}
function foo3(results: number[] | undefined) {
>foo3 : (results: number[] | undefined) => void
>results : number[] | undefined
results ||= [];
>results ||= [] : number[]
>results : number[] | undefined
>[] : never[]
results.push(100);
>results.push(100) : number
>results.push : (...items: number[]) => number
>results : number[]
>push : (...items: number[]) => number
>100 : 100
}
function foo4(results: number[] | undefined) {
>foo4 : (results: number[] | undefined) => void
>results : number[] | undefined
results ||= [];
>results ||= [] : number[]
>results : number[] | undefined
>[] : never[]
results.push(100);
>results.push(100) : number
>results.push : (...items: number[]) => number
>results : number[]
>push : (...items: number[]) => number
>100 : 100
}
interface ThingWithOriginal {
name: string;
>name : string
original?: ThingWithOriginal
>original : ThingWithOriginal | undefined
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
>doSomethingWithAlias : (thing?: ThingWithOriginal | undefined) => void
>thing : ThingWithOriginal | undefined
if (thing &&= thing.original) {
>thing &&= thing.original : ThingWithOriginal | undefined
>thing : ThingWithOriginal | undefined
>thing.original : ThingWithOriginal | undefined
>thing : ThingWithOriginal
>original : ThingWithOriginal | undefined
console.log(thing.name);
>console.log(thing.name) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>thing.name : string
>thing : ThingWithOriginal | undefined
>name : string
}
}

View File

@@ -0,0 +1,33 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment4.ts(25,21): error TS2532: Object is possibly 'undefined'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment4.ts (1 errors) ====
function foo1(results: number[] | undefined) {
(results ||= []).push(100);
}
function foo2(results: number[] | undefined) {
(results ??= []).push(100);
}
function foo3(results: number[] | undefined) {
results ||= [];
results.push(100);
}
function foo4(results: number[] | undefined) {
results ||= [];
results.push(100);
}
interface ThingWithOriginal {
name: string;
original?: ThingWithOriginal
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
if (thing &&= thing.original) {
console.log(thing.name);
~~~~~
!!! error TS2532: Object is possibly 'undefined'.
}
}

View File

@@ -5,6 +5,26 @@ function foo1(results: number[] | undefined) {
function foo2(results: number[] | undefined) {
(results ??= []).push(100);
}
function foo3(results: number[] | undefined) {
results ||= [];
results.push(100);
}
function foo4(results: number[] | undefined) {
results ||= [];
results.push(100);
}
interface ThingWithOriginal {
name: string;
original?: ThingWithOriginal
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
if (thing &&= thing.original) {
console.log(thing.name);
}
}
//// [logicalAssignment4.js]
@@ -15,3 +35,16 @@ function foo1(results) {
function foo2(results) {
(results ??= []).push(100);
}
function foo3(results) {
results ||= [];
results.push(100);
}
function foo4(results) {
results ||= [];
results.push(100);
}
function doSomethingWithAlias(thing) {
if (thing &&= thing.original) {
console.log(thing.name);
}
}

View File

@@ -18,3 +18,60 @@ function foo2(results: number[] | undefined) {
>results : Symbol(results, Decl(logicalAssignment4.ts, 4, 14))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo3(results: number[] | undefined) {
>foo3 : Symbol(foo3, Decl(logicalAssignment4.ts, 6, 1))
>results : Symbol(results, Decl(logicalAssignment4.ts, 8, 14))
results ||= [];
>results : Symbol(results, Decl(logicalAssignment4.ts, 8, 14))
results.push(100);
>results.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment4.ts, 8, 14))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo4(results: number[] | undefined) {
>foo4 : Symbol(foo4, Decl(logicalAssignment4.ts, 11, 1))
>results : Symbol(results, Decl(logicalAssignment4.ts, 13, 14))
results ||= [];
>results : Symbol(results, Decl(logicalAssignment4.ts, 13, 14))
results.push(100);
>results.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment4.ts, 13, 14))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
interface ThingWithOriginal {
>ThingWithOriginal : Symbol(ThingWithOriginal, Decl(logicalAssignment4.ts, 16, 1))
name: string;
>name : Symbol(ThingWithOriginal.name, Decl(logicalAssignment4.ts, 18, 29))
original?: ThingWithOriginal
>original : Symbol(ThingWithOriginal.original, Decl(logicalAssignment4.ts, 19, 17))
>ThingWithOriginal : Symbol(ThingWithOriginal, Decl(logicalAssignment4.ts, 16, 1))
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
>doSomethingWithAlias : Symbol(doSomethingWithAlias, Decl(logicalAssignment4.ts, 21, 1))
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>ThingWithOriginal : Symbol(ThingWithOriginal, Decl(logicalAssignment4.ts, 16, 1))
if (thing &&= thing.original) {
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>thing.original : Symbol(ThingWithOriginal.original, Decl(logicalAssignment4.ts, 19, 17))
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>original : Symbol(ThingWithOriginal.original, Decl(logicalAssignment4.ts, 19, 17))
console.log(thing.name);
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>thing.name : Symbol(ThingWithOriginal.name, Decl(logicalAssignment4.ts, 18, 29))
>thing : Symbol(thing, Decl(logicalAssignment4.ts, 22, 30))
>name : Symbol(ThingWithOriginal.name, Decl(logicalAssignment4.ts, 18, 29))
}
}

View File

@@ -28,3 +28,66 @@ function foo2(results: number[] | undefined) {
>push : (...items: number[]) => number
>100 : 100
}
function foo3(results: number[] | undefined) {
>foo3 : (results: number[] | undefined) => void
>results : number[] | undefined
results ||= [];
>results ||= [] : number[]
>results : number[] | undefined
>[] : never[]
results.push(100);
>results.push(100) : number
>results.push : (...items: number[]) => number
>results : number[]
>push : (...items: number[]) => number
>100 : 100
}
function foo4(results: number[] | undefined) {
>foo4 : (results: number[] | undefined) => void
>results : number[] | undefined
results ||= [];
>results ||= [] : number[]
>results : number[] | undefined
>[] : never[]
results.push(100);
>results.push(100) : number
>results.push : (...items: number[]) => number
>results : number[]
>push : (...items: number[]) => number
>100 : 100
}
interface ThingWithOriginal {
name: string;
>name : string
original?: ThingWithOriginal
>original : ThingWithOriginal | undefined
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
>doSomethingWithAlias : (thing?: ThingWithOriginal | undefined) => void
>thing : ThingWithOriginal | undefined
if (thing &&= thing.original) {
>thing &&= thing.original : ThingWithOriginal | undefined
>thing : ThingWithOriginal | undefined
>thing.original : ThingWithOriginal | undefined
>thing : ThingWithOriginal
>original : ThingWithOriginal | undefined
console.log(thing.name);
>console.log(thing.name) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>thing.name : string
>thing : ThingWithOriginal | undefined
>name : string
}
}

View File

@@ -0,0 +1,51 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(12,12): error TS7006: Parameter 'a' implicitly has an 'any' type.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(13,5): error TS2722: Cannot invoke an object which is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(17,12): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(22,12): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(27,27): error TS7006: Parameter 'a' implicitly has an 'any' type.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(28,5): error TS2722: Cannot invoke an object which is possibly 'undefined'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts (6 errors) ====
function foo1 (f?: (a: number) => void) {
f ??= (a => a)
f(42)
}
function foo2 (f?: (a: number) => void) {
f ||= (a => a)
f(42)
}
function foo3 (f?: (a: number) => void) {
f &&= (a => a)
~
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.
f(42)
~
!!! error TS2722: Cannot invoke an object which is possibly 'undefined'.
}
function bar1 (f?: (a: number) => void) {
f ??= (f.toString(), (a => a))
~
!!! error TS2532: Object is possibly 'undefined'.
f(42)
}
function bar2 (f?: (a: number) => void) {
f ||= (f.toString(), (a => a))
~
!!! error TS2532: Object is possibly 'undefined'.
f(42)
}
function bar3 (f?: (a: number) => void) {
f &&= (f.toString(), (a => a))
~
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.
f(42)
~
!!! error TS2722: Cannot invoke an object which is possibly 'undefined'.
}

View File

@@ -0,0 +1,58 @@
//// [logicalAssignment5.ts]
function foo1 (f?: (a: number) => void) {
f ??= (a => a)
f(42)
}
function foo2 (f?: (a: number) => void) {
f ||= (a => a)
f(42)
}
function foo3 (f?: (a: number) => void) {
f &&= (a => a)
f(42)
}
function bar1 (f?: (a: number) => void) {
f ??= (f.toString(), (a => a))
f(42)
}
function bar2 (f?: (a: number) => void) {
f ||= (f.toString(), (a => a))
f(42)
}
function bar3 (f?: (a: number) => void) {
f &&= (f.toString(), (a => a))
f(42)
}
//// [logicalAssignment5.js]
"use strict";
function foo1(f) {
f !== null && f !== void 0 ? f : (f = (a => a));
f(42);
}
function foo2(f) {
f || (f = (a => a));
f(42);
}
function foo3(f) {
f && (f = (a => a));
f(42);
}
function bar1(f) {
f !== null && f !== void 0 ? f : (f = (f.toString(), (a => a)));
f(42);
}
function bar2(f) {
f || (f = (f.toString(), (a => a)));
f(42);
}
function bar3(f) {
f && (f = (f.toString(), (a => a)));
f(42);
}

View File

@@ -0,0 +1,90 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts ===
function foo1 (f?: (a: number) => void) {
>foo1 : Symbol(foo1, Decl(logicalAssignment5.ts, 0, 0))
>f : Symbol(f, Decl(logicalAssignment5.ts, 0, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 0, 20))
f ??= (a => a)
>f : Symbol(f, Decl(logicalAssignment5.ts, 0, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 1, 11))
>a : Symbol(a, Decl(logicalAssignment5.ts, 1, 11))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 0, 15))
}
function foo2 (f?: (a: number) => void) {
>foo2 : Symbol(foo2, Decl(logicalAssignment5.ts, 3, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 5, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 5, 20))
f ||= (a => a)
>f : Symbol(f, Decl(logicalAssignment5.ts, 5, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 6, 11))
>a : Symbol(a, Decl(logicalAssignment5.ts, 6, 11))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 5, 15))
}
function foo3 (f?: (a: number) => void) {
>foo3 : Symbol(foo3, Decl(logicalAssignment5.ts, 8, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 10, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 10, 20))
f &&= (a => a)
>f : Symbol(f, Decl(logicalAssignment5.ts, 10, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 11, 11))
>a : Symbol(a, Decl(logicalAssignment5.ts, 11, 11))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 10, 15))
}
function bar1 (f?: (a: number) => void) {
>bar1 : Symbol(bar1, Decl(logicalAssignment5.ts, 13, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 15, 20))
f ??= (f.toString(), (a => a))
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 16, 26))
>a : Symbol(a, Decl(logicalAssignment5.ts, 16, 26))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
}
function bar2 (f?: (a: number) => void) {
>bar2 : Symbol(bar2, Decl(logicalAssignment5.ts, 18, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 20, 20))
f ||= (f.toString(), (a => a))
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 21, 26))
>a : Symbol(a, Decl(logicalAssignment5.ts, 21, 26))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
}
function bar3 (f?: (a: number) => void) {
>bar3 : Symbol(bar3, Decl(logicalAssignment5.ts, 23, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 25, 20))
f &&= (f.toString(), (a => a))
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
>f.toString : Symbol(Function.toString, Decl(lib.es5.d.ts, --, --))
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
>toString : Symbol(Function.toString, Decl(lib.es5.d.ts, --, --))
>a : Symbol(a, Decl(logicalAssignment5.ts, 26, 26))
>a : Symbol(a, Decl(logicalAssignment5.ts, 26, 26))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
}

View File

@@ -0,0 +1,133 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts ===
function foo1 (f?: (a: number) => void) {
>foo1 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ??= (a => a)
>f ??= (a => a) : (a: number) => void
>f : ((a: number) => void) | undefined
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function foo2 (f?: (a: number) => void) {
>foo2 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ||= (a => a)
>f ||= (a => a) : (a: number) => void
>f : ((a: number) => void) | undefined
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function foo3 (f?: (a: number) => void) {
>foo3 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f &&= (a => a)
>f &&= (a => a) : ((a: any) => any) | undefined
>f : ((a: number) => void) | undefined
>(a => a) : (a: any) => any
>a => a : (a: any) => any
>a : any
>a : any
f(42)
>f(42) : any
>f : undefined
>42 : 42
}
function bar1 (f?: (a: number) => void) {
>bar1 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ??= (f.toString(), (a => a))
>f ??= (f.toString(), (a => a)) : (a: number) => void
>f : ((a: number) => void) | undefined
>(f.toString(), (a => a)) : (a: number) => number
>f.toString(), (a => a) : (a: number) => number
>f.toString() : any
>f.toString : any
>f : undefined
>toString : any
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function bar2 (f?: (a: number) => void) {
>bar2 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ||= (f.toString(), (a => a))
>f ||= (f.toString(), (a => a)) : (a: number) => void
>f : ((a: number) => void) | undefined
>(f.toString(), (a => a)) : (a: number) => number
>f.toString(), (a => a) : (a: number) => number
>f.toString() : any
>f.toString : any
>f : undefined
>toString : any
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function bar3 (f?: (a: number) => void) {
>bar3 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f &&= (f.toString(), (a => a))
>f &&= (f.toString(), (a => a)) : ((a: any) => any) | undefined
>f : ((a: number) => void) | undefined
>(f.toString(), (a => a)) : (a: any) => any
>f.toString(), (a => a) : (a: any) => any
>f.toString() : string
>f.toString : () => string
>f : (a: number) => void
>toString : () => string
>(a => a) : (a: any) => any
>a => a : (a: any) => any
>a : any
>a : any
f(42)
>f(42) : any
>f : undefined
>42 : 42
}

View File

@@ -0,0 +1,51 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(12,12): error TS7006: Parameter 'a' implicitly has an 'any' type.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(13,5): error TS2722: Cannot invoke an object which is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(17,12): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(22,12): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(27,27): error TS7006: Parameter 'a' implicitly has an 'any' type.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(28,5): error TS2722: Cannot invoke an object which is possibly 'undefined'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts (6 errors) ====
function foo1 (f?: (a: number) => void) {
f ??= (a => a)
f(42)
}
function foo2 (f?: (a: number) => void) {
f ||= (a => a)
f(42)
}
function foo3 (f?: (a: number) => void) {
f &&= (a => a)
~
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.
f(42)
~
!!! error TS2722: Cannot invoke an object which is possibly 'undefined'.
}
function bar1 (f?: (a: number) => void) {
f ??= (f.toString(), (a => a))
~
!!! error TS2532: Object is possibly 'undefined'.
f(42)
}
function bar2 (f?: (a: number) => void) {
f ||= (f.toString(), (a => a))
~
!!! error TS2532: Object is possibly 'undefined'.
f(42)
}
function bar3 (f?: (a: number) => void) {
f &&= (f.toString(), (a => a))
~
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.
f(42)
~
!!! error TS2722: Cannot invoke an object which is possibly 'undefined'.
}

View File

@@ -0,0 +1,58 @@
//// [logicalAssignment5.ts]
function foo1 (f?: (a: number) => void) {
f ??= (a => a)
f(42)
}
function foo2 (f?: (a: number) => void) {
f ||= (a => a)
f(42)
}
function foo3 (f?: (a: number) => void) {
f &&= (a => a)
f(42)
}
function bar1 (f?: (a: number) => void) {
f ??= (f.toString(), (a => a))
f(42)
}
function bar2 (f?: (a: number) => void) {
f ||= (f.toString(), (a => a))
f(42)
}
function bar3 (f?: (a: number) => void) {
f &&= (f.toString(), (a => a))
f(42)
}
//// [logicalAssignment5.js]
"use strict";
function foo1(f) {
f ?? (f = (a => a));
f(42);
}
function foo2(f) {
f || (f = (a => a));
f(42);
}
function foo3(f) {
f && (f = (a => a));
f(42);
}
function bar1(f) {
f ?? (f = (f.toString(), (a => a)));
f(42);
}
function bar2(f) {
f || (f = (f.toString(), (a => a)));
f(42);
}
function bar3(f) {
f && (f = (f.toString(), (a => a)));
f(42);
}

View File

@@ -0,0 +1,90 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts ===
function foo1 (f?: (a: number) => void) {
>foo1 : Symbol(foo1, Decl(logicalAssignment5.ts, 0, 0))
>f : Symbol(f, Decl(logicalAssignment5.ts, 0, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 0, 20))
f ??= (a => a)
>f : Symbol(f, Decl(logicalAssignment5.ts, 0, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 1, 11))
>a : Symbol(a, Decl(logicalAssignment5.ts, 1, 11))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 0, 15))
}
function foo2 (f?: (a: number) => void) {
>foo2 : Symbol(foo2, Decl(logicalAssignment5.ts, 3, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 5, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 5, 20))
f ||= (a => a)
>f : Symbol(f, Decl(logicalAssignment5.ts, 5, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 6, 11))
>a : Symbol(a, Decl(logicalAssignment5.ts, 6, 11))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 5, 15))
}
function foo3 (f?: (a: number) => void) {
>foo3 : Symbol(foo3, Decl(logicalAssignment5.ts, 8, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 10, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 10, 20))
f &&= (a => a)
>f : Symbol(f, Decl(logicalAssignment5.ts, 10, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 11, 11))
>a : Symbol(a, Decl(logicalAssignment5.ts, 11, 11))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 10, 15))
}
function bar1 (f?: (a: number) => void) {
>bar1 : Symbol(bar1, Decl(logicalAssignment5.ts, 13, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 15, 20))
f ??= (f.toString(), (a => a))
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 16, 26))
>a : Symbol(a, Decl(logicalAssignment5.ts, 16, 26))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
}
function bar2 (f?: (a: number) => void) {
>bar2 : Symbol(bar2, Decl(logicalAssignment5.ts, 18, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 20, 20))
f ||= (f.toString(), (a => a))
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 21, 26))
>a : Symbol(a, Decl(logicalAssignment5.ts, 21, 26))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
}
function bar3 (f?: (a: number) => void) {
>bar3 : Symbol(bar3, Decl(logicalAssignment5.ts, 23, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 25, 20))
f &&= (f.toString(), (a => a))
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
>f.toString : Symbol(Function.toString, Decl(lib.es5.d.ts, --, --))
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
>toString : Symbol(Function.toString, Decl(lib.es5.d.ts, --, --))
>a : Symbol(a, Decl(logicalAssignment5.ts, 26, 26))
>a : Symbol(a, Decl(logicalAssignment5.ts, 26, 26))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
}

View File

@@ -0,0 +1,133 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts ===
function foo1 (f?: (a: number) => void) {
>foo1 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ??= (a => a)
>f ??= (a => a) : (a: number) => void
>f : ((a: number) => void) | undefined
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function foo2 (f?: (a: number) => void) {
>foo2 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ||= (a => a)
>f ||= (a => a) : (a: number) => void
>f : ((a: number) => void) | undefined
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function foo3 (f?: (a: number) => void) {
>foo3 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f &&= (a => a)
>f &&= (a => a) : ((a: any) => any) | undefined
>f : ((a: number) => void) | undefined
>(a => a) : (a: any) => any
>a => a : (a: any) => any
>a : any
>a : any
f(42)
>f(42) : any
>f : undefined
>42 : 42
}
function bar1 (f?: (a: number) => void) {
>bar1 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ??= (f.toString(), (a => a))
>f ??= (f.toString(), (a => a)) : (a: number) => void
>f : ((a: number) => void) | undefined
>(f.toString(), (a => a)) : (a: number) => number
>f.toString(), (a => a) : (a: number) => number
>f.toString() : any
>f.toString : any
>f : undefined
>toString : any
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function bar2 (f?: (a: number) => void) {
>bar2 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ||= (f.toString(), (a => a))
>f ||= (f.toString(), (a => a)) : (a: number) => void
>f : ((a: number) => void) | undefined
>(f.toString(), (a => a)) : (a: number) => number
>f.toString(), (a => a) : (a: number) => number
>f.toString() : any
>f.toString : any
>f : undefined
>toString : any
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function bar3 (f?: (a: number) => void) {
>bar3 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f &&= (f.toString(), (a => a))
>f &&= (f.toString(), (a => a)) : ((a: any) => any) | undefined
>f : ((a: number) => void) | undefined
>(f.toString(), (a => a)) : (a: any) => any
>f.toString(), (a => a) : (a: any) => any
>f.toString() : string
>f.toString : () => string
>f : (a: number) => void
>toString : () => string
>(a => a) : (a: any) => any
>a => a : (a: any) => any
>a : any
>a : any
f(42)
>f(42) : any
>f : undefined
>42 : 42
}

View File

@@ -0,0 +1,51 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(12,12): error TS7006: Parameter 'a' implicitly has an 'any' type.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(13,5): error TS2722: Cannot invoke an object which is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(17,12): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(22,12): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(27,27): error TS7006: Parameter 'a' implicitly has an 'any' type.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts(28,5): error TS2722: Cannot invoke an object which is possibly 'undefined'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts (6 errors) ====
function foo1 (f?: (a: number) => void) {
f ??= (a => a)
f(42)
}
function foo2 (f?: (a: number) => void) {
f ||= (a => a)
f(42)
}
function foo3 (f?: (a: number) => void) {
f &&= (a => a)
~
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.
f(42)
~
!!! error TS2722: Cannot invoke an object which is possibly 'undefined'.
}
function bar1 (f?: (a: number) => void) {
f ??= (f.toString(), (a => a))
~
!!! error TS2532: Object is possibly 'undefined'.
f(42)
}
function bar2 (f?: (a: number) => void) {
f ||= (f.toString(), (a => a))
~
!!! error TS2532: Object is possibly 'undefined'.
f(42)
}
function bar3 (f?: (a: number) => void) {
f &&= (f.toString(), (a => a))
~
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.
f(42)
~
!!! error TS2722: Cannot invoke an object which is possibly 'undefined'.
}

View File

@@ -0,0 +1,58 @@
//// [logicalAssignment5.ts]
function foo1 (f?: (a: number) => void) {
f ??= (a => a)
f(42)
}
function foo2 (f?: (a: number) => void) {
f ||= (a => a)
f(42)
}
function foo3 (f?: (a: number) => void) {
f &&= (a => a)
f(42)
}
function bar1 (f?: (a: number) => void) {
f ??= (f.toString(), (a => a))
f(42)
}
function bar2 (f?: (a: number) => void) {
f ||= (f.toString(), (a => a))
f(42)
}
function bar3 (f?: (a: number) => void) {
f &&= (f.toString(), (a => a))
f(42)
}
//// [logicalAssignment5.js]
"use strict";
function foo1(f) {
f ??= (a => a);
f(42);
}
function foo2(f) {
f ||= (a => a);
f(42);
}
function foo3(f) {
f &&= (a => a);
f(42);
}
function bar1(f) {
f ??= (f.toString(), (a => a));
f(42);
}
function bar2(f) {
f ||= (f.toString(), (a => a));
f(42);
}
function bar3(f) {
f &&= (f.toString(), (a => a));
f(42);
}

View File

@@ -0,0 +1,90 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts ===
function foo1 (f?: (a: number) => void) {
>foo1 : Symbol(foo1, Decl(logicalAssignment5.ts, 0, 0))
>f : Symbol(f, Decl(logicalAssignment5.ts, 0, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 0, 20))
f ??= (a => a)
>f : Symbol(f, Decl(logicalAssignment5.ts, 0, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 1, 11))
>a : Symbol(a, Decl(logicalAssignment5.ts, 1, 11))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 0, 15))
}
function foo2 (f?: (a: number) => void) {
>foo2 : Symbol(foo2, Decl(logicalAssignment5.ts, 3, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 5, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 5, 20))
f ||= (a => a)
>f : Symbol(f, Decl(logicalAssignment5.ts, 5, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 6, 11))
>a : Symbol(a, Decl(logicalAssignment5.ts, 6, 11))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 5, 15))
}
function foo3 (f?: (a: number) => void) {
>foo3 : Symbol(foo3, Decl(logicalAssignment5.ts, 8, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 10, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 10, 20))
f &&= (a => a)
>f : Symbol(f, Decl(logicalAssignment5.ts, 10, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 11, 11))
>a : Symbol(a, Decl(logicalAssignment5.ts, 11, 11))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 10, 15))
}
function bar1 (f?: (a: number) => void) {
>bar1 : Symbol(bar1, Decl(logicalAssignment5.ts, 13, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 15, 20))
f ??= (f.toString(), (a => a))
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 16, 26))
>a : Symbol(a, Decl(logicalAssignment5.ts, 16, 26))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 15, 15))
}
function bar2 (f?: (a: number) => void) {
>bar2 : Symbol(bar2, Decl(logicalAssignment5.ts, 18, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 20, 20))
f ||= (f.toString(), (a => a))
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 21, 26))
>a : Symbol(a, Decl(logicalAssignment5.ts, 21, 26))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 20, 15))
}
function bar3 (f?: (a: number) => void) {
>bar3 : Symbol(bar3, Decl(logicalAssignment5.ts, 23, 1))
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
>a : Symbol(a, Decl(logicalAssignment5.ts, 25, 20))
f &&= (f.toString(), (a => a))
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
>f.toString : Symbol(Function.toString, Decl(lib.es5.d.ts, --, --))
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
>toString : Symbol(Function.toString, Decl(lib.es5.d.ts, --, --))
>a : Symbol(a, Decl(logicalAssignment5.ts, 26, 26))
>a : Symbol(a, Decl(logicalAssignment5.ts, 26, 26))
f(42)
>f : Symbol(f, Decl(logicalAssignment5.ts, 25, 15))
}

View File

@@ -0,0 +1,133 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment5.ts ===
function foo1 (f?: (a: number) => void) {
>foo1 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ??= (a => a)
>f ??= (a => a) : (a: number) => void
>f : ((a: number) => void) | undefined
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function foo2 (f?: (a: number) => void) {
>foo2 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ||= (a => a)
>f ||= (a => a) : (a: number) => void
>f : ((a: number) => void) | undefined
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function foo3 (f?: (a: number) => void) {
>foo3 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f &&= (a => a)
>f &&= (a => a) : ((a: any) => any) | undefined
>f : ((a: number) => void) | undefined
>(a => a) : (a: any) => any
>a => a : (a: any) => any
>a : any
>a : any
f(42)
>f(42) : any
>f : undefined
>42 : 42
}
function bar1 (f?: (a: number) => void) {
>bar1 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ??= (f.toString(), (a => a))
>f ??= (f.toString(), (a => a)) : (a: number) => void
>f : ((a: number) => void) | undefined
>(f.toString(), (a => a)) : (a: number) => number
>f.toString(), (a => a) : (a: number) => number
>f.toString() : any
>f.toString : any
>f : undefined
>toString : any
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function bar2 (f?: (a: number) => void) {
>bar2 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f ||= (f.toString(), (a => a))
>f ||= (f.toString(), (a => a)) : (a: number) => void
>f : ((a: number) => void) | undefined
>(f.toString(), (a => a)) : (a: number) => number
>f.toString(), (a => a) : (a: number) => number
>f.toString() : any
>f.toString : any
>f : undefined
>toString : any
>(a => a) : (a: number) => number
>a => a : (a: number) => number
>a : number
>a : number
f(42)
>f(42) : void
>f : (a: number) => void
>42 : 42
}
function bar3 (f?: (a: number) => void) {
>bar3 : (f?: ((a: number) => void) | undefined) => void
>f : ((a: number) => void) | undefined
>a : number
f &&= (f.toString(), (a => a))
>f &&= (f.toString(), (a => a)) : ((a: any) => any) | undefined
>f : ((a: number) => void) | undefined
>(f.toString(), (a => a)) : (a: any) => any
>f.toString(), (a => a) : (a: any) => any
>f.toString() : string
>f.toString : () => string
>f : (a: number) => void
>toString : () => string
>(a => a) : (a: any) => any
>a => a : (a: any) => any
>a : any
>a : any
f(42)
>f(42) : any
>f : undefined
>42 : 42
}

View File

@@ -0,0 +1,20 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts(10,5): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts(10,42): error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts (2 errors) ====
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= (results1 ||= [])).push(100);
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= (results1 ??= [])).push(100);
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= (results1 &&= [])).push(100);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~
!!! error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
}

View File

@@ -0,0 +1,24 @@
//// [logicalAssignment6.ts]
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= (results1 ||= [])).push(100);
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= (results1 ??= [])).push(100);
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= (results1 &&= [])).push(100);
}
//// [logicalAssignment6.js]
"use strict";
function foo1(results, results1) {
(results || (results = (results1 || (results1 = [])))).push(100);
}
function foo2(results, results1) {
(results !== null && results !== void 0 ? results : (results = (results1 !== null && results1 !== void 0 ? results1 : (results1 = [])))).push(100);
}
function foo3(results, results1) {
(results && (results = (results1 && (results1 = [])))).push(100);
}

View File

@@ -0,0 +1,36 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : Symbol(foo1, Decl(logicalAssignment6.ts, 0, 0))
>results : Symbol(results, Decl(logicalAssignment6.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 0, 44))
(results ||= (results1 ||= [])).push(100);
>(results ||= (results1 ||= [])).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment6.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 0, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : Symbol(foo2, Decl(logicalAssignment6.ts, 2, 1))
>results : Symbol(results, Decl(logicalAssignment6.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 4, 44))
(results ??= (results1 ??= [])).push(100);
>(results ??= (results1 ??= [])).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment6.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 4, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : Symbol(foo3, Decl(logicalAssignment6.ts, 6, 1))
>results : Symbol(results, Decl(logicalAssignment6.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 8, 44))
(results &&= (results1 &&= [])).push(100);
>(results &&= (results1 &&= [])).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment6.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 8, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}

View File

@@ -0,0 +1,57 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ||= (results1 ||= [])).push(100);
>(results ||= (results1 ||= [])).push(100) : number
>(results ||= (results1 ||= [])).push : (...items: number[]) => number
>(results ||= (results1 ||= [])) : number[]
>results ||= (results1 ||= []) : number[]
>results : number[] | undefined
>(results1 ||= []) : number[]
>results1 ||= [] : number[]
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ??= (results1 ??= [])).push(100);
>(results ??= (results1 ??= [])).push(100) : number
>(results ??= (results1 ??= [])).push : (...items: number[]) => number
>(results ??= (results1 ??= [])) : number[]
>results ??= (results1 ??= []) : number[]
>results : number[] | undefined
>(results1 ??= []) : number[]
>results1 ??= [] : number[]
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results &&= (results1 &&= [])).push(100);
>(results &&= (results1 &&= [])).push(100) : number
>(results &&= (results1 &&= [])).push : (...items: never[]) => number
>(results &&= (results1 &&= [])) : never[] | undefined
>results &&= (results1 &&= []) : never[] | undefined
>results : number[] | undefined
>(results1 &&= []) : never[] | undefined
>results1 &&= [] : never[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: never[]) => number
>100 : 100
}

View File

@@ -0,0 +1,20 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts(10,5): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts(10,42): error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts (2 errors) ====
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= (results1 ||= [])).push(100);
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= (results1 ??= [])).push(100);
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= (results1 &&= [])).push(100);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~
!!! error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
}

View File

@@ -0,0 +1,24 @@
//// [logicalAssignment6.ts]
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= (results1 ||= [])).push(100);
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= (results1 ??= [])).push(100);
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= (results1 &&= [])).push(100);
}
//// [logicalAssignment6.js]
"use strict";
function foo1(results, results1) {
(results || (results = (results1 || (results1 = [])))).push(100);
}
function foo2(results, results1) {
(results ?? (results = (results1 ?? (results1 = [])))).push(100);
}
function foo3(results, results1) {
(results && (results = (results1 && (results1 = [])))).push(100);
}

View File

@@ -0,0 +1,36 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : Symbol(foo1, Decl(logicalAssignment6.ts, 0, 0))
>results : Symbol(results, Decl(logicalAssignment6.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 0, 44))
(results ||= (results1 ||= [])).push(100);
>(results ||= (results1 ||= [])).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment6.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 0, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : Symbol(foo2, Decl(logicalAssignment6.ts, 2, 1))
>results : Symbol(results, Decl(logicalAssignment6.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 4, 44))
(results ??= (results1 ??= [])).push(100);
>(results ??= (results1 ??= [])).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment6.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 4, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : Symbol(foo3, Decl(logicalAssignment6.ts, 6, 1))
>results : Symbol(results, Decl(logicalAssignment6.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 8, 44))
(results &&= (results1 &&= [])).push(100);
>(results &&= (results1 &&= [])).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment6.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 8, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}

View File

@@ -0,0 +1,57 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ||= (results1 ||= [])).push(100);
>(results ||= (results1 ||= [])).push(100) : number
>(results ||= (results1 ||= [])).push : (...items: number[]) => number
>(results ||= (results1 ||= [])) : number[]
>results ||= (results1 ||= []) : number[]
>results : number[] | undefined
>(results1 ||= []) : number[]
>results1 ||= [] : number[]
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ??= (results1 ??= [])).push(100);
>(results ??= (results1 ??= [])).push(100) : number
>(results ??= (results1 ??= [])).push : (...items: number[]) => number
>(results ??= (results1 ??= [])) : number[]
>results ??= (results1 ??= []) : number[]
>results : number[] | undefined
>(results1 ??= []) : number[]
>results1 ??= [] : number[]
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results &&= (results1 &&= [])).push(100);
>(results &&= (results1 &&= [])).push(100) : number
>(results &&= (results1 &&= [])).push : (...items: never[]) => number
>(results &&= (results1 &&= [])) : never[] | undefined
>results &&= (results1 &&= []) : never[] | undefined
>results : number[] | undefined
>(results1 &&= []) : never[] | undefined
>results1 &&= [] : never[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: never[]) => number
>100 : 100
}

View File

@@ -0,0 +1,20 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts(10,5): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts(10,42): error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts (2 errors) ====
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= (results1 ||= [])).push(100);
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= (results1 ??= [])).push(100);
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= (results1 &&= [])).push(100);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~
!!! error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
}

View File

@@ -0,0 +1,24 @@
//// [logicalAssignment6.ts]
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= (results1 ||= [])).push(100);
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= (results1 ??= [])).push(100);
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= (results1 &&= [])).push(100);
}
//// [logicalAssignment6.js]
"use strict";
function foo1(results, results1) {
(results ||= (results1 ||= [])).push(100);
}
function foo2(results, results1) {
(results ??= (results1 ??= [])).push(100);
}
function foo3(results, results1) {
(results &&= (results1 &&= [])).push(100);
}

View File

@@ -0,0 +1,36 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : Symbol(foo1, Decl(logicalAssignment6.ts, 0, 0))
>results : Symbol(results, Decl(logicalAssignment6.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 0, 44))
(results ||= (results1 ||= [])).push(100);
>(results ||= (results1 ||= [])).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment6.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 0, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : Symbol(foo2, Decl(logicalAssignment6.ts, 2, 1))
>results : Symbol(results, Decl(logicalAssignment6.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 4, 44))
(results ??= (results1 ??= [])).push(100);
>(results ??= (results1 ??= [])).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment6.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 4, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : Symbol(foo3, Decl(logicalAssignment6.ts, 6, 1))
>results : Symbol(results, Decl(logicalAssignment6.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 8, 44))
(results &&= (results1 &&= [])).push(100);
>(results &&= (results1 &&= [])).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment6.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment6.ts, 8, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}

View File

@@ -0,0 +1,57 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment6.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ||= (results1 ||= [])).push(100);
>(results ||= (results1 ||= [])).push(100) : number
>(results ||= (results1 ||= [])).push : (...items: number[]) => number
>(results ||= (results1 ||= [])) : number[]
>results ||= (results1 ||= []) : number[]
>results : number[] | undefined
>(results1 ||= []) : number[]
>results1 ||= [] : number[]
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ??= (results1 ??= [])).push(100);
>(results ??= (results1 ??= [])).push(100) : number
>(results ??= (results1 ??= [])).push : (...items: number[]) => number
>(results ??= (results1 ??= [])) : number[]
>results ??= (results1 ??= []) : number[]
>results : number[] | undefined
>(results1 ??= []) : number[]
>results1 ??= [] : number[]
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results &&= (results1 &&= [])).push(100);
>(results &&= (results1 &&= [])).push(100) : number
>(results &&= (results1 &&= [])).push : (...items: never[]) => number
>(results &&= (results1 &&= [])) : never[] | undefined
>results &&= (results1 &&= []) : never[] | undefined
>results : number[] | undefined
>(results1 &&= []) : never[] | undefined
>results1 &&= [] : never[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: never[]) => number
>100 : 100
}

View File

@@ -0,0 +1,29 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(2,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(6,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(10,5): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(10,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(10,40): error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts (5 errors) ====
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= results1 ||= []).push(100);
~~~~~~~~~~~~~~~~~~~~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= results1 ??= []).push(100);
~~~~~~~~~~~~~~~~~~~~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= results1 &&= []).push(100);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
~~~
!!! error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
}

View File

@@ -0,0 +1,25 @@
//// [logicalAssignment7.ts]
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= results1 ||= []).push(100);
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= results1 ??= []).push(100);
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= results1 &&= []).push(100);
}
//// [logicalAssignment7.js]
"use strict";
function foo1(results, results1) {
(results || (results = results1) || (results || (results = results1) = [])).push(100);
}
function foo2(results, results1) {
var _a;
((_a = results !== null && results !== void 0 ? results : (results = results1)) !== null && _a !== void 0 ? _a : (results !== null && results !== void 0 ? results : (results = results1) = [])).push(100);
}
function foo3(results, results1) {
(results && (results = results1) && (results && (results = results1) = [])).push(100);
}

View File

@@ -0,0 +1,36 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : Symbol(foo1, Decl(logicalAssignment7.ts, 0, 0))
>results : Symbol(results, Decl(logicalAssignment7.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 0, 44))
(results ||= results1 ||= []).push(100);
>(results ||= results1 ||= []).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment7.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 0, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : Symbol(foo2, Decl(logicalAssignment7.ts, 2, 1))
>results : Symbol(results, Decl(logicalAssignment7.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 4, 44))
(results ??= results1 ??= []).push(100);
>(results ??= results1 ??= []).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment7.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 4, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : Symbol(foo3, Decl(logicalAssignment7.ts, 6, 1))
>results : Symbol(results, Decl(logicalAssignment7.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 8, 44))
(results &&= results1 &&= []).push(100);
>(results &&= results1 &&= []).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment7.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 8, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}

View File

@@ -0,0 +1,54 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ||= results1 ||= []).push(100);
>(results ||= results1 ||= []).push(100) : number
>(results ||= results1 ||= []).push : (...items: number[]) => number
>(results ||= results1 ||= []) : number[]
>results ||= results1 ||= [] : number[]
>results ||= results1 : number[] | undefined
>results : number[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ??= results1 ??= []).push(100);
>(results ??= results1 ??= []).push(100) : number
>(results ??= results1 ??= []).push : (...items: number[]) => number
>(results ??= results1 ??= []) : number[]
>results ??= results1 ??= [] : number[]
>results ??= results1 : number[] | undefined
>results : number[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results &&= results1 &&= []).push(100);
>(results &&= results1 &&= []).push(100) : number
>(results &&= results1 &&= []).push : (...items: never[]) => number
>(results &&= results1 &&= []) : never[] | undefined
>results &&= results1 &&= [] : never[] | undefined
>results &&= results1 : number[] | undefined
>results : number[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: never[]) => number
>100 : 100
}

View File

@@ -0,0 +1,29 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(2,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(6,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(10,5): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(10,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(10,40): error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts (5 errors) ====
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= results1 ||= []).push(100);
~~~~~~~~~~~~~~~~~~~~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= results1 ??= []).push(100);
~~~~~~~~~~~~~~~~~~~~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= results1 &&= []).push(100);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
~~~
!!! error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
}

View File

@@ -0,0 +1,24 @@
//// [logicalAssignment7.ts]
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= results1 ||= []).push(100);
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= results1 ??= []).push(100);
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= results1 &&= []).push(100);
}
//// [logicalAssignment7.js]
"use strict";
function foo1(results, results1) {
(results || (results = results1) || (results || (results = results1) = [])).push(100);
}
function foo2(results, results1) {
(results ?? (results = results1) ?? (results ?? (results = results1) = [])).push(100);
}
function foo3(results, results1) {
(results && (results = results1) && (results && (results = results1) = [])).push(100);
}

View File

@@ -0,0 +1,36 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : Symbol(foo1, Decl(logicalAssignment7.ts, 0, 0))
>results : Symbol(results, Decl(logicalAssignment7.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 0, 44))
(results ||= results1 ||= []).push(100);
>(results ||= results1 ||= []).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment7.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 0, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : Symbol(foo2, Decl(logicalAssignment7.ts, 2, 1))
>results : Symbol(results, Decl(logicalAssignment7.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 4, 44))
(results ??= results1 ??= []).push(100);
>(results ??= results1 ??= []).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment7.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 4, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : Symbol(foo3, Decl(logicalAssignment7.ts, 6, 1))
>results : Symbol(results, Decl(logicalAssignment7.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 8, 44))
(results &&= results1 &&= []).push(100);
>(results &&= results1 &&= []).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment7.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 8, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}

View File

@@ -0,0 +1,54 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ||= results1 ||= []).push(100);
>(results ||= results1 ||= []).push(100) : number
>(results ||= results1 ||= []).push : (...items: number[]) => number
>(results ||= results1 ||= []) : number[]
>results ||= results1 ||= [] : number[]
>results ||= results1 : number[] | undefined
>results : number[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ??= results1 ??= []).push(100);
>(results ??= results1 ??= []).push(100) : number
>(results ??= results1 ??= []).push : (...items: number[]) => number
>(results ??= results1 ??= []) : number[]
>results ??= results1 ??= [] : number[]
>results ??= results1 : number[] | undefined
>results : number[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results &&= results1 &&= []).push(100);
>(results &&= results1 &&= []).push(100) : number
>(results &&= results1 &&= []).push : (...items: never[]) => number
>(results &&= results1 &&= []) : never[] | undefined
>results &&= results1 &&= [] : never[] | undefined
>results &&= results1 : number[] | undefined
>results : number[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: never[]) => number
>100 : 100
}

View File

@@ -0,0 +1,29 @@
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(2,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(6,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(10,5): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(10,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts(10,40): error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
==== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts (5 errors) ====
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= results1 ||= []).push(100);
~~~~~~~~~~~~~~~~~~~~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= results1 ??= []).push(100);
~~~~~~~~~~~~~~~~~~~~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= results1 &&= []).push(100);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
~~~
!!! error TS2345: Argument of type '100' is not assignable to parameter of type 'never'.
}

View File

@@ -0,0 +1,24 @@
//// [logicalAssignment7.ts]
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= results1 ||= []).push(100);
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= results1 ??= []).push(100);
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= results1 &&= []).push(100);
}
//// [logicalAssignment7.js]
"use strict";
function foo1(results, results1) {
(results ||= results1 ||= []).push(100);
}
function foo2(results, results1) {
(results ??= results1 ??= []).push(100);
}
function foo3(results, results1) {
(results &&= results1 &&= []).push(100);
}

View File

@@ -0,0 +1,36 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : Symbol(foo1, Decl(logicalAssignment7.ts, 0, 0))
>results : Symbol(results, Decl(logicalAssignment7.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 0, 44))
(results ||= results1 ||= []).push(100);
>(results ||= results1 ||= []).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment7.ts, 0, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 0, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : Symbol(foo2, Decl(logicalAssignment7.ts, 2, 1))
>results : Symbol(results, Decl(logicalAssignment7.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 4, 44))
(results ??= results1 ??= []).push(100);
>(results ??= results1 ??= []).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment7.ts, 4, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 4, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : Symbol(foo3, Decl(logicalAssignment7.ts, 6, 1))
>results : Symbol(results, Decl(logicalAssignment7.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 8, 44))
(results &&= results1 &&= []).push(100);
>(results &&= results1 &&= []).push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>results : Symbol(results, Decl(logicalAssignment7.ts, 8, 14))
>results1 : Symbol(results1, Decl(logicalAssignment7.ts, 8, 44))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
}

View File

@@ -0,0 +1,54 @@
=== tests/cases/conformance/esnext/logicalAssignment/logicalAssignment7.ts ===
function foo1(results: number[] | undefined, results1: number[] | undefined) {
>foo1 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ||= results1 ||= []).push(100);
>(results ||= results1 ||= []).push(100) : number
>(results ||= results1 ||= []).push : (...items: number[]) => number
>(results ||= results1 ||= []) : number[]
>results ||= results1 ||= [] : number[]
>results ||= results1 : number[] | undefined
>results : number[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
>foo2 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results ??= results1 ??= []).push(100);
>(results ??= results1 ??= []).push(100) : number
>(results ??= results1 ??= []).push : (...items: number[]) => number
>(results ??= results1 ??= []) : number[]
>results ??= results1 ??= [] : number[]
>results ??= results1 : number[] | undefined
>results : number[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: number[]) => number
>100 : 100
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
>foo3 : (results: number[] | undefined, results1: number[] | undefined) => void
>results : number[] | undefined
>results1 : number[] | undefined
(results &&= results1 &&= []).push(100);
>(results &&= results1 &&= []).push(100) : number
>(results &&= results1 &&= []).push : (...items: never[]) => number
>(results &&= results1 &&= []) : never[] | undefined
>results &&= results1 &&= [] : never[] | undefined
>results &&= results1 : number[] | undefined
>results : number[] | undefined
>results1 : number[] | undefined
>[] : never[]
>push : (...items: never[]) => number
>100 : 100
}

View File

@@ -7,4 +7,24 @@ function foo1(results: number[] | undefined) {
function foo2(results: number[] | undefined) {
(results ??= []).push(100);
}
function foo3(results: number[] | undefined) {
results ||= [];
results.push(100);
}
function foo4(results: number[] | undefined) {
results ||= [];
results.push(100);
}
interface ThingWithOriginal {
name: string;
original?: ThingWithOriginal
}
function doSomethingWithAlias(thing?: ThingWithOriginal | undefined) {
if (thing &&= thing.original) {
console.log(thing.name);
}
}

View File

@@ -1,7 +1,32 @@
// @strict: true
// @target: esnext, es2020, es2015
function foo (f: (a: number) => void | undefined) {
f ??= (a => a++)
f ||= (a => a++)
function foo1 (f?: (a: number) => void) {
f ??= (a => a)
f(42)
}
function foo2 (f?: (a: number) => void) {
f ||= (a => a)
f(42)
}
function foo3 (f?: (a: number) => void) {
f &&= (a => a)
f(42)
}
function bar1 (f?: (a: number) => void) {
f ??= (f.toString(), (a => a))
f(42)
}
function bar2 (f?: (a: number) => void) {
f ||= (f.toString(), (a => a))
f(42)
}
function bar3 (f?: (a: number) => void) {
f &&= (f.toString(), (a => a))
f(42)
}

View File

@@ -0,0 +1,14 @@
// @strict: true
// @target: esnext, es2020, es2015
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= (results1 ||= [])).push(100);
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= (results1 ??= [])).push(100);
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= (results1 &&= [])).push(100);
}

View File

@@ -0,0 +1,14 @@
// @strict: true
// @target: esnext, es2020, es2015
function foo1(results: number[] | undefined, results1: number[] | undefined) {
(results ||= results1 ||= []).push(100);
}
function foo2(results: number[] | undefined, results1: number[] | undefined) {
(results ??= results1 ??= []).push(100);
}
function foo3(results: number[] | undefined, results1: number[] | undefined) {
(results &&= results1 &&= []).push(100);
}