mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
42 lines
1.6 KiB
Plaintext
42 lines
1.6 KiB
Plaintext
destructuringAssignmentWithDefault2.ts(11,4): error TS2322: Type 'number | undefined' is not assignable to type 'number'.
|
|
Type 'undefined' is not assignable to type 'number'.
|
|
destructuringAssignmentWithDefault2.ts(11,4): error TS2322: Type 'undefined' is not assignable to type 'number'.
|
|
destructuringAssignmentWithDefault2.ts(12,7): error TS2322: Type 'undefined' is not assignable to type 'number'.
|
|
destructuringAssignmentWithDefault2.ts(13,7): error TS2322: Type 'undefined' is not assignable to type 'number'.
|
|
|
|
|
|
==== 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 'number | undefined' is not assignable to type 'number'.
|
|
!!! error TS2322: Type '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()); |