Accept new baselines

This commit is contained in:
Anders Hejlsberg
2019-12-12 16:03:32 -08:00
parent 5524a61ce9
commit 6d67054339
3 changed files with 101 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
//// [unionReductionMutualSubtypes.ts]
// Repro from #35414
interface ReturnVal {
something(): void;
}
const k: ReturnVal = { something() { } }
declare const val: ReturnVal;
function run(options: { something?(b?: string): void }) {
const something = options.something ?? val.something;
something('');
}
//// [unionReductionMutualSubtypes.js]
"use strict";
// Repro from #35414
var k = { something: function () { } };
function run(options) {
var _a;
var something = (_a = options.something) !== null && _a !== void 0 ? _a : val.something;
something('');
}

View File

@@ -0,0 +1,38 @@
=== tests/cases/compiler/unionReductionMutualSubtypes.ts ===
// Repro from #35414
interface ReturnVal {
>ReturnVal : Symbol(ReturnVal, Decl(unionReductionMutualSubtypes.ts, 0, 0))
something(): void;
>something : Symbol(ReturnVal.something, Decl(unionReductionMutualSubtypes.ts, 2, 21))
}
const k: ReturnVal = { something() { } }
>k : Symbol(k, Decl(unionReductionMutualSubtypes.ts, 6, 5))
>ReturnVal : Symbol(ReturnVal, Decl(unionReductionMutualSubtypes.ts, 0, 0))
>something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 6, 22))
declare const val: ReturnVal;
>val : Symbol(val, Decl(unionReductionMutualSubtypes.ts, 8, 13))
>ReturnVal : Symbol(ReturnVal, Decl(unionReductionMutualSubtypes.ts, 0, 0))
function run(options: { something?(b?: string): void }) {
>run : Symbol(run, Decl(unionReductionMutualSubtypes.ts, 8, 29))
>options : Symbol(options, Decl(unionReductionMutualSubtypes.ts, 9, 13))
>something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 9, 23))
>b : Symbol(b, Decl(unionReductionMutualSubtypes.ts, 9, 35))
const something = options.something ?? val.something;
>something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 10, 9))
>options.something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 9, 23))
>options : Symbol(options, Decl(unionReductionMutualSubtypes.ts, 9, 13))
>something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 9, 23))
>val.something : Symbol(ReturnVal.something, Decl(unionReductionMutualSubtypes.ts, 2, 21))
>val : Symbol(val, Decl(unionReductionMutualSubtypes.ts, 8, 13))
>something : Symbol(ReturnVal.something, Decl(unionReductionMutualSubtypes.ts, 2, 21))
something('');
>something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 10, 9))
}

View File

@@ -0,0 +1,38 @@
=== tests/cases/compiler/unionReductionMutualSubtypes.ts ===
// Repro from #35414
interface ReturnVal {
something(): void;
>something : () => void
}
const k: ReturnVal = { something() { } }
>k : ReturnVal
>{ something() { } } : { something(): void; }
>something : () => void
declare const val: ReturnVal;
>val : ReturnVal
function run(options: { something?(b?: string): void }) {
>run : (options: { something?(b?: string | undefined): void; }) => void
>options : { something?(b?: string | undefined): void; }
>something : ((b?: string | undefined) => void) | undefined
>b : string | undefined
const something = options.something ?? val.something;
>something : (b?: string | undefined) => void
>options.something ?? val.something : (b?: string | undefined) => void
>options.something : ((b?: string | undefined) => void) | undefined
>options : { something?(b?: string | undefined): void; }
>something : ((b?: string | undefined) => void) | undefined
>val.something : () => void
>val : ReturnVal
>something : () => void
something('');
>something('') : void
>something : (b?: string | undefined) => void
>'' : ""
}