From 48d343b9852acd673c38ad0c43a93aada3935e79 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 1 Jun 2019 10:37:02 -0700 Subject: [PATCH] Accept new baselines --- .../destructuringAssignmentWithDefault.js | 32 ++++++ ...destructuringAssignmentWithDefault.symbols | 80 +++++++++++++-- .../destructuringAssignmentWithDefault.types | 99 +++++++++++++++++++ 3 files changed, 203 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/destructuringAssignmentWithDefault.js b/tests/baselines/reference/destructuringAssignmentWithDefault.js index 4eedee050bd..b2b0c31654b 100644 --- a/tests/baselines/reference/destructuringAssignmentWithDefault.js +++ b/tests/baselines/reference/destructuringAssignmentWithDefault.js @@ -8,11 +8,27 @@ let x = 0; function f1(options?: { color?: string, width?: number }) { let { color, width } = options || {}; ({ color, width } = options || {}); + let x1 = (options || {}).color; + let x2 = (options || {})["color"]; } function f2(options?: [string?, number?]) { let [str, num] = options || []; [str, num] = options || []; + let x1 = (options || {})[0]; +} + +function f3(options?: { color: string, width: number }) { + let { color, width } = options || {}; + ({ color, width } = options || {}); + let x1 = (options || {}).color; + let x2 = (options || {})["color"]; +} + +function f4(options?: [string, number]) { + let [str, num] = options || []; + [str, num] = options || []; + let x1 = (options || {})[0]; } @@ -26,9 +42,25 @@ function f1(options) { var _a; var _b = options || {}, color = _b.color, width = _b.width; (_a = options || {}, color = _a.color, width = _a.width); + var x1 = (options || {}).color; + var x2 = (options || {})["color"]; } function f2(options) { var _a; var _b = options || [], str = _b[0], num = _b[1]; _a = options || [], str = _a[0], num = _a[1]; + var x1 = (options || {})[0]; +} +function f3(options) { + var _a; + var _b = options || {}, color = _b.color, width = _b.width; + (_a = options || {}, color = _a.color, width = _a.width); + var x1 = (options || {}).color; + var x2 = (options || {})["color"]; +} +function f4(options) { + var _a; + var _b = options || [], str = _b[0], num = _b[1]; + _a = options || [], str = _a[0], num = _a[1]; + var x1 = (options || {})[0]; } diff --git a/tests/baselines/reference/destructuringAssignmentWithDefault.symbols b/tests/baselines/reference/destructuringAssignmentWithDefault.symbols index 071740ebdde..eef4bdcd97a 100644 --- a/tests/baselines/reference/destructuringAssignmentWithDefault.symbols +++ b/tests/baselines/reference/destructuringAssignmentWithDefault.symbols @@ -27,20 +27,84 @@ function f1(options?: { color?: string, width?: number }) { >color : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 8, 6)) >width : Symbol(width, Decl(destructuringAssignmentWithDefault.ts, 8, 13)) >options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 6, 12)) + + let x1 = (options || {}).color; +>x1 : Symbol(x1, Decl(destructuringAssignmentWithDefault.ts, 9, 7)) +>(options || {}).color : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 6, 23)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 6, 12)) +>color : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 6, 23)) + + let x2 = (options || {})["color"]; +>x2 : Symbol(x2, Decl(destructuringAssignmentWithDefault.ts, 10, 7)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 6, 12)) +>"color" : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 6, 23)) } function f2(options?: [string?, number?]) { ->f2 : Symbol(f2, Decl(destructuringAssignmentWithDefault.ts, 9, 1)) ->options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 11, 12)) +>f2 : Symbol(f2, Decl(destructuringAssignmentWithDefault.ts, 11, 1)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 13, 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 : Symbol(str, Decl(destructuringAssignmentWithDefault.ts, 14, 9)) +>num : Symbol(num, Decl(destructuringAssignmentWithDefault.ts, 14, 13)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 13, 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)) +>str : Symbol(str, Decl(destructuringAssignmentWithDefault.ts, 14, 9)) +>num : Symbol(num, Decl(destructuringAssignmentWithDefault.ts, 14, 13)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 13, 12)) + + let x1 = (options || {})[0]; +>x1 : Symbol(x1, Decl(destructuringAssignmentWithDefault.ts, 16, 7)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 13, 12)) +>0 : Symbol(0) +} + +function f3(options?: { color: string, width: number }) { +>f3 : Symbol(f3, Decl(destructuringAssignmentWithDefault.ts, 17, 1)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 19, 12)) +>color : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 19, 23)) +>width : Symbol(width, Decl(destructuringAssignmentWithDefault.ts, 19, 38)) + + let { color, width } = options || {}; +>color : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 20, 9)) +>width : Symbol(width, Decl(destructuringAssignmentWithDefault.ts, 20, 16)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 19, 12)) + + ({ color, width } = options || {}); +>color : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 21, 6)) +>width : Symbol(width, Decl(destructuringAssignmentWithDefault.ts, 21, 13)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 19, 12)) + + let x1 = (options || {}).color; +>x1 : Symbol(x1, Decl(destructuringAssignmentWithDefault.ts, 22, 7)) +>(options || {}).color : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 19, 23)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 19, 12)) +>color : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 19, 23)) + + let x2 = (options || {})["color"]; +>x2 : Symbol(x2, Decl(destructuringAssignmentWithDefault.ts, 23, 7)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 19, 12)) +>"color" : Symbol(color, Decl(destructuringAssignmentWithDefault.ts, 19, 23)) +} + +function f4(options?: [string, number]) { +>f4 : Symbol(f4, Decl(destructuringAssignmentWithDefault.ts, 24, 1)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 26, 12)) + + let [str, num] = options || []; +>str : Symbol(str, Decl(destructuringAssignmentWithDefault.ts, 27, 9)) +>num : Symbol(num, Decl(destructuringAssignmentWithDefault.ts, 27, 13)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 26, 12)) + + [str, num] = options || []; +>str : Symbol(str, Decl(destructuringAssignmentWithDefault.ts, 27, 9)) +>num : Symbol(num, Decl(destructuringAssignmentWithDefault.ts, 27, 13)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 26, 12)) + + let x1 = (options || {})[0]; +>x1 : Symbol(x1, Decl(destructuringAssignmentWithDefault.ts, 29, 7)) +>options : Symbol(options, Decl(destructuringAssignmentWithDefault.ts, 26, 12)) +>0 : Symbol(0) } diff --git a/tests/baselines/reference/destructuringAssignmentWithDefault.types b/tests/baselines/reference/destructuringAssignmentWithDefault.types index 34f377774b5..379bfe8b3bd 100644 --- a/tests/baselines/reference/destructuringAssignmentWithDefault.types +++ b/tests/baselines/reference/destructuringAssignmentWithDefault.types @@ -40,6 +40,24 @@ function f1(options?: { color?: string, width?: number }) { >options || {} : { color?: string | undefined; width?: number | undefined; } >options : { color?: string | undefined; width?: number | undefined; } | undefined >{} : {} + + let x1 = (options || {}).color; +>x1 : string | undefined +>(options || {}).color : string | undefined +>(options || {}) : { color?: string | undefined; width?: number | undefined; } +>options || {} : { color?: string | undefined; width?: number | undefined; } +>options : { color?: string | undefined; width?: number | undefined; } | undefined +>{} : {} +>color : string | undefined + + let x2 = (options || {})["color"]; +>x2 : string | undefined +>(options || {})["color"] : string | undefined +>(options || {}) : { color?: string | undefined; width?: number | undefined; } +>options || {} : { color?: string | undefined; width?: number | undefined; } +>options : { color?: string | undefined; width?: number | undefined; } | undefined +>{} : {} +>"color" : "color" } function f2(options?: [string?, number?]) { @@ -61,5 +79,86 @@ function f2(options?: [string?, number?]) { >options || [] : [(string | undefined)?, (number | undefined)?] >options : [(string | undefined)?, (number | undefined)?] | undefined >[] : [] + + let x1 = (options || {})[0]; +>x1 : string | undefined +>(options || {})[0] : string | undefined +>(options || {}) : [(string | undefined)?, (number | undefined)?] | {} +>options || {} : [(string | undefined)?, (number | undefined)?] | {} +>options : [(string | undefined)?, (number | undefined)?] | undefined +>{} : {} +>0 : 0 +} + +function f3(options?: { color: string, width: number }) { +>f3 : (options?: { color: string; width: number; } | undefined) => void +>options : { color: string; width: number; } | undefined +>color : string +>width : number + + let { color, width } = options || {}; +>color : string | undefined +>width : number | undefined +>options || {} : { color: string; width: number; } | {} +>options : { color: string; width: number; } | undefined +>{} : {} + + ({ color, width } = options || {}); +>({ color, width } = options || {}) : { color: string; width: number; } | {} +>{ color, width } = options || {} : { color: string; width: number; } | {} +>{ color, width } : { color: string | undefined; width: number | undefined; } +>color : string | undefined +>width : number | undefined +>options || {} : { color: string; width: number; } | {} +>options : { color: string; width: number; } | undefined +>{} : {} + + let x1 = (options || {}).color; +>x1 : string | undefined +>(options || {}).color : string | undefined +>(options || {}) : { color: string; width: number; } | {} +>options || {} : { color: string; width: number; } | {} +>options : { color: string; width: number; } | undefined +>{} : {} +>color : string | undefined + + let x2 = (options || {})["color"]; +>x2 : string | undefined +>(options || {})["color"] : string | undefined +>(options || {}) : { color: string; width: number; } | {} +>options || {} : { color: string; width: number; } | {} +>options : { color: string; width: number; } | undefined +>{} : {} +>"color" : "color" +} + +function f4(options?: [string, number]) { +>f4 : (options?: [string, number] | undefined) => void +>options : [string, number] | undefined + + let [str, num] = options || []; +>str : string | undefined +>num : number | undefined +>options || [] : [] | [string, number] +>options : [string, number] | undefined +>[] : [] + + [str, num] = options || []; +>[str, num] = options || [] : [] | [string, number] +>[str, num] : [string | undefined, number | undefined] +>str : string | undefined +>num : number | undefined +>options || [] : [] | [string, number] +>options : [string, number] | undefined +>[] : [] + + let x1 = (options || {})[0]; +>x1 : string | undefined +>(options || {})[0] : string | undefined +>(options || {}) : [string, number] | {} +>options || {} : [string, number] | {} +>options : [string, number] | undefined +>{} : {} +>0 : 0 }