mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
49 lines
1.0 KiB
TypeScript
49 lines
1.0 KiB
TypeScript
//// [tests/cases/compiler/destructuringAssignmentWithDefault2.ts] ////
|
|
|
|
//// [destructuringAssignmentWithDefault2.ts]
|
|
const a: { x?: number; y?: number } = { };
|
|
|
|
let x: number;
|
|
|
|
// Should not error out
|
|
({ x = 0 } = a);
|
|
({ x: x = 0} = a);
|
|
({ y: x = 0} = a);
|
|
|
|
// Should be error
|
|
({ x = undefined } = a);
|
|
({ x: x = undefined } = a);
|
|
({ y: x = undefined } = a);
|
|
|
|
const { x: z1 } = a;
|
|
const { x: z2 = 0 } = a;
|
|
const { x: z3 = undefined } = a;
|
|
|
|
|
|
declare const r: Iterator<number>;
|
|
let done: boolean;
|
|
let value;
|
|
|
|
({ done = false, value } = r.next());
|
|
({ done: done = false, value } = r.next());
|
|
|
|
//// [destructuringAssignmentWithDefault2.js]
|
|
"use strict";
|
|
const a = {};
|
|
let x;
|
|
// Should not error out
|
|
({ x = 0 } = a);
|
|
({ x: x = 0 } = a);
|
|
({ y: x = 0 } = a);
|
|
// Should be error
|
|
({ x = undefined } = a);
|
|
({ x: x = undefined } = a);
|
|
({ y: x = undefined } = a);
|
|
const { x: z1 } = a;
|
|
const { x: z2 = 0 } = a;
|
|
const { x: z3 = undefined } = a;
|
|
let done;
|
|
let value;
|
|
({ done = false, value } = r.next());
|
|
({ done: done = false, value } = r.next());
|