1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
tests/cases/compiler/destructuringAssignmentWithDefault2.ts(11,4): error TS2322: Type 'undefined' is not assignable to type 'number'.
tests/cases/compiler/destructuringAssignmentWithDefault2.ts(11,4): error TS2322: Type 'number | undefined' is not assignable to type 'number'.
Type 'undefined' is not assignable to type 'number'.
tests/cases/compiler/destructuringAssignmentWithDefault2.ts(12,7): error TS2322: Type 'undefined' is not assignable to type 'number'.
tests/cases/compiler/destructuringAssignmentWithDefault2.ts(13,7): error TS2322: Type 'undefined' is not assignable to type 'number'.
==== tests/cases/compiler/destructuringAssignmentWithDefault2.ts (4 errors) ====
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);
~
!!! error TS2322: Type 'undefined' is not assignable to type 'number'.
~
!!! error TS2322: Type 'number | undefined' is not assignable to type 'number'.
!!! error TS2322: Type 'undefined' is not assignable to type 'number'.
({ x: x = undefined } = a);
~
!!! error TS2322: Type 'undefined' is not assignable to type 'number'.
({ y: x = undefined } = a);
~
!!! error TS2322: Type 'undefined' is not assignable to type 'number'.
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());
|