Accept new baselines

This commit is contained in:
Anders Hejlsberg 2019-05-31 16:53:53 -07:00
parent d0795afb48
commit 0895fd6bdc
3 changed files with 104 additions and 0 deletions

View File

@ -2,6 +2,18 @@
const a: { x?: number } = { };
let x = 0;
({x = 1} = a);
// Repro from #26235
function f1(options?: { color?: string, width?: number }) {
let { color, width } = options || {};
({ color, width } = options || {});
}
function f2(options?: [string?, number?]) {
let [str, num] = options || [];
[str, num] = options || [];
}
//// [destructuringAssignmentWithDefault.js]
@ -9,3 +21,14 @@ var _a;
var a = {};
var x = 0;
(_a = a.x, x = _a === void 0 ? 1 : _a);
// Repro from #26235
function f1(options) {
var _a;
var _b = options || {}, color = _b.color, width = _b.width;
(_a = options || {}, color = _a.color, width = _a.width);
}
function f2(options) {
var _a;
var _b = options || [], str = _b[0], num = _b[1];
_a = options || [], str = _a[0], num = _a[1];
}

View File

@ -10,3 +10,37 @@ let x = 0;
>x : Symbol(x, Decl(destructuringAssignmentWithDefault.ts, 2, 2))
>a : Symbol(a, Decl(destructuringAssignmentWithDefault.ts, 0, 5))
// Repro from #26235
function f1(options?: { color?: string, width?: number }) {
>f1 : Symbol(f1, Decl(destructuringAssignmentWithDefault.ts, 2, 14))
>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 6, 12))
>color : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 6, 23))
>width : Symbol(width, Decl(destructuringAssignmentWithDefault.ts, 6, 39))
let { color, width } = options || {};
>color : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 7, 9))
>width : Symbol(width, Decl(destructuringAssignmentWithDefault.ts, 7, 16))
>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 6, 12))
({ color, width } = options || {});
>color : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 8, 6))
>width : Symbol(width, Decl(destructuringAssignmentWithDefault.ts, 8, 13))
>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 6, 12))
}
function f2(options?: [string?, number?]) {
>f2 : Symbol(f2, Decl(destructuringAssignmentWithDefault.ts, 9, 1))
>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 11, 12))
let [str, num] = options || [];
>str : Symbol(str, Decl(destructuringAssignmentWithDefault.ts, 12, 9))
>num : Symbol(num, Decl(destructuringAssignmentWithDefault.ts, 12, 13))
>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 11, 12))
[str, num] = options || [];
>str : Symbol(str, Decl(destructuringAssignmentWithDefault.ts, 12, 9))
>num : Symbol(num, Decl(destructuringAssignmentWithDefault.ts, 12, 13))
>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 11, 12))
}

View File

@ -16,3 +16,50 @@ let x = 0;
>1 : 1
>a : { x?: number | undefined; }
// Repro from #26235
function f1(options?: { color?: string, width?: number }) {
>f1 : (options?: { color?: string | undefined; width?: number | undefined; } | undefined) => void
>options : { color?: string | undefined; width?: number | undefined; } | undefined
>color : string | undefined
>width : number | undefined
let { color, width } = options || {};
>color : string | undefined
>width : number | undefined
>options || {} : { color?: string | undefined; width?: number | undefined; }
>options : { color?: string | undefined; width?: number | undefined; } | undefined
>{} : {}
({ color, width } = options || {});
>({ color, width } = options || {}) : { color?: string | undefined; width?: number | undefined; }
>{ color, width } = options || {} : { color?: string | undefined; width?: number | undefined; }
>{ color, width } : { color: string | undefined; width: number | undefined; }
>color : string | undefined
>width : number | undefined
>options || {} : { color?: string | undefined; width?: number | undefined; }
>options : { color?: string | undefined; width?: number | undefined; } | undefined
>{} : {}
}
function f2(options?: [string?, number?]) {
>f2 : (options?: [(string | undefined)?, (number | undefined)?] | undefined) => void
>options : [(string | undefined)?, (number | undefined)?] | undefined
let [str, num] = options || [];
>str : string | undefined
>num : number | undefined
>options || [] : [(string | undefined)?, (number | undefined)?]
>options : [(string | undefined)?, (number | undefined)?] | undefined
>[] : []
[str, num] = options || [];
>[str, num] = options || [] : [(string | undefined)?, (number | undefined)?]
>[str, num] : [string | undefined, number | undefined]
>str : string | undefined
>num : number | undefined
>options || [] : [(string | undefined)?, (number | undefined)?]
>options : [(string | undefined)?, (number | undefined)?] | undefined
>[] : []
}