Accept new baselines

This commit is contained in:
Anders Hejlsberg
2019-02-10 15:29:22 -08:00
parent 35cf397ae3
commit 1c9fe44726
3 changed files with 136 additions and 3 deletions

View File

@@ -71,6 +71,24 @@ declare var mbp: Man & Bear;
pigify(mbp).oinks; // OK, mbp is treated as Pig
pigify(mbp).walks; // Ok, mbp is treated as Man
// Repros from #29815
interface ITest {
name: 'test'
}
const createTestAsync = (): Promise<ITest> => Promise.resolve().then(() => ({ name: 'test' }))
const createTest = (): ITest => {
return { name: 'test' }
}
declare function f1<T, U>(x: T | U): T | U;
declare function f2<T, U>(x: T & U): T & U;
let x1: string = f1('a');
let x2: string = f2('a');
//// [unionAndIntersectionInference1.js]
@@ -80,7 +98,7 @@ function destructure(something, haveValue, haveY) {
return something === y ? haveY(y) : haveValue(something);
}
var value = Math.random() > 0.5 ? 'hey!' : undefined;
var result = destructure(value, function (text) { return 'string'; }, function (y) { return 'other one'; }); // text: string, y: Y
var result = destructure(value, text => 'string', y => 'other one'); // text: string, y: Y
// Repro from #4212
function isVoid(value) {
return undefined;
@@ -107,7 +125,13 @@ function baz1(value) {
function get(x) {
return null; // just an example
}
var foo;
let foo;
get(foo).toUpperCase(); // Ok
pigify(mbp).oinks; // OK, mbp is treated as Pig
pigify(mbp).walks; // Ok, mbp is treated as Man
const createTestAsync = () => Promise.resolve().then(() => ({ name: 'test' }));
const createTest = () => {
return { name: 'test' };
};
let x1 = f1('a');
let x2 = f2('a');

View File

@@ -50,7 +50,7 @@ function destructure<a, r>(
var value = Math.random() > 0.5 ? 'hey!' : <Y>undefined;
>value : Symbol(value, Decl(unionAndIntersectionInference1.ts, 12, 3))
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
>Y : Symbol(Y, Decl(unionAndIntersectionInference1.ts, 0, 0))
>undefined : Symbol(undefined)
@@ -201,3 +201,59 @@ pigify(mbp).walks; // Ok, mbp is treated as Man
>mbp : Symbol(mbp, Decl(unionAndIntersectionInference1.ts, 68, 11))
>walks : Symbol(Man.walks, Decl(unionAndIntersectionInference1.ts, 55, 15))
// Repros from #29815
interface ITest {
>ITest : Symbol(ITest, Decl(unionAndIntersectionInference1.ts, 71, 18))
name: 'test'
>name : Symbol(ITest.name, Decl(unionAndIntersectionInference1.ts, 75, 17))
}
const createTestAsync = (): Promise<ITest> => Promise.resolve().then(() => ({ name: 'test' }))
>createTestAsync : Symbol(createTestAsync, Decl(unionAndIntersectionInference1.ts, 79, 5))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>ITest : Symbol(ITest, Decl(unionAndIntersectionInference1.ts, 71, 18))
>Promise.resolve().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>name : Symbol(name, Decl(unionAndIntersectionInference1.ts, 79, 77))
const createTest = (): ITest => {
>createTest : Symbol(createTest, Decl(unionAndIntersectionInference1.ts, 81, 5))
>ITest : Symbol(ITest, Decl(unionAndIntersectionInference1.ts, 71, 18))
return { name: 'test' }
>name : Symbol(name, Decl(unionAndIntersectionInference1.ts, 82, 10))
}
declare function f1<T, U>(x: T | U): T | U;
>f1 : Symbol(f1, Decl(unionAndIntersectionInference1.ts, 83, 1))
>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 85, 20))
>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 85, 22))
>x : Symbol(x, Decl(unionAndIntersectionInference1.ts, 85, 26))
>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 85, 20))
>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 85, 22))
>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 85, 20))
>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 85, 22))
declare function f2<T, U>(x: T & U): T & U;
>f2 : Symbol(f2, Decl(unionAndIntersectionInference1.ts, 85, 43))
>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 86, 20))
>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 86, 22))
>x : Symbol(x, Decl(unionAndIntersectionInference1.ts, 86, 26))
>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 86, 20))
>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 86, 22))
>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 86, 20))
>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 86, 22))
let x1: string = f1('a');
>x1 : Symbol(x1, Decl(unionAndIntersectionInference1.ts, 88, 3))
>f1 : Symbol(f1, Decl(unionAndIntersectionInference1.ts, 83, 1))
let x2: string = f2('a');
>x2 : Symbol(x2, Decl(unionAndIntersectionInference1.ts, 89, 3))
>f2 : Symbol(f2, Decl(unionAndIntersectionInference1.ts, 85, 43))

View File

@@ -179,3 +179,56 @@ pigify(mbp).walks; // Ok, mbp is treated as Man
>mbp : Man & Bear
>walks : boolean
// Repros from #29815
interface ITest {
name: 'test'
>name : "test"
}
const createTestAsync = (): Promise<ITest> => Promise.resolve().then(() => ({ name: 'test' }))
>createTestAsync : () => Promise<ITest>
>(): Promise<ITest> => Promise.resolve().then(() => ({ name: 'test' })) : () => Promise<ITest>
>Promise.resolve().then(() => ({ name: 'test' })) : Promise<ITest | { name: "test"; }>
>Promise.resolve().then : <TResult1 = void, TResult2 = never>(onfulfilled?: (value: void) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>Promise.resolve() : Promise<void>
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>Promise : PromiseConstructor
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
>then : <TResult1 = void, TResult2 = never>(onfulfilled?: (value: void) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>() => ({ name: 'test' }) : () => { name: "test"; }
>({ name: 'test' }) : { name: "test"; }
>{ name: 'test' } : { name: "test"; }
>name : "test"
>'test' : "test"
const createTest = (): ITest => {
>createTest : () => ITest
>(): ITest => { return { name: 'test' }} : () => ITest
return { name: 'test' }
>{ name: 'test' } : { name: "test"; }
>name : "test"
>'test' : "test"
}
declare function f1<T, U>(x: T | U): T | U;
>f1 : <T, U>(x: T | U) => T | U
>x : T | U
declare function f2<T, U>(x: T & U): T & U;
>f2 : <T, U>(x: T & U) => T & U
>x : T & U
let x1: string = f1('a');
>x1 : string
>f1('a') : "a"
>f1 : <T, U>(x: T | U) => T | U
>'a' : "a"
let x2: string = f2('a');
>x2 : string
>f2('a') : "a"
>f2 : <T, U>(x: T & U) => T & U
>'a' : "a"