Accept new baselines

This commit is contained in:
Anders Hejlsberg 2019-07-20 10:02:46 -07:00
parent d96d16e10b
commit 623a1725c8
4 changed files with 118 additions and 17 deletions

View file

@ -39,6 +39,17 @@ tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference
~~
!!! error TS2345: Argument of type '42' is not assignable to parameter of type 'never'.
export interface Foo<T> {
then<U>(f: (x: T) => U | Foo<U>, g: U): Foo<U>;
}
export interface Bar<T> {
then<S>(f: (x: T) => S | Bar<S>, g: S): Bar<S>;
}
function qux(p1: Foo<void>, p2: Bar<void>) {
p1 = p2;
}
// Repros from #32434
declare function foo<T>(x: T | Promise<T>): void;

View file

@ -31,6 +31,17 @@ const d1 = f4("abc");
const d2 = f4(s);
const d3 = f4(42); // Error
export interface Foo<T> {
then<U>(f: (x: T) => U | Foo<U>, g: U): Foo<U>;
}
export interface Bar<T> {
then<S>(f: (x: T) => S | Bar<S>, g: S): Bar<S>;
}
function qux(p1: Foo<void>, p2: Bar<void>) {
p1 = p2;
}
// Repros from #32434
declare function foo<T>(x: T | Promise<T>): void;
@ -43,6 +54,7 @@ const y = bar(1, 2);
//// [unionTypeInference.js]
"use strict";
exports.__esModule = true;
var a1 = f1(1, 2); // 1 | 2
var a2 = f1(1, "hello"); // 1
var a3 = f1(1, sn); // number
@ -59,5 +71,8 @@ var c5 = f3("abc"); // never
var d1 = f4("abc");
var d2 = f4(s);
var d3 = f4(42); // Error
function qux(p1, p2) {
p1 = p2;
}
foo(x);
var y = bar(1, 2);

View file

@ -107,34 +107,83 @@ const d3 = f4(42); // Error
>d3 : Symbol(d3, Decl(unionTypeInference.ts, 30, 5))
>f4 : Symbol(f4, Decl(unionTypeInference.ts, 24, 21))
export interface Foo<T> {
>Foo : Symbol(Foo, Decl(unionTypeInference.ts, 30, 18))
>T : Symbol(T, Decl(unionTypeInference.ts, 32, 21))
then<U>(f: (x: T) => U | Foo<U>, g: U): Foo<U>;
>then : Symbol(Foo.then, Decl(unionTypeInference.ts, 32, 25))
>U : Symbol(U, Decl(unionTypeInference.ts, 33, 9))
>f : Symbol(f, Decl(unionTypeInference.ts, 33, 12))
>x : Symbol(x, Decl(unionTypeInference.ts, 33, 16))
>T : Symbol(T, Decl(unionTypeInference.ts, 32, 21))
>U : Symbol(U, Decl(unionTypeInference.ts, 33, 9))
>Foo : Symbol(Foo, Decl(unionTypeInference.ts, 30, 18))
>U : Symbol(U, Decl(unionTypeInference.ts, 33, 9))
>g : Symbol(g, Decl(unionTypeInference.ts, 33, 36))
>U : Symbol(U, Decl(unionTypeInference.ts, 33, 9))
>Foo : Symbol(Foo, Decl(unionTypeInference.ts, 30, 18))
>U : Symbol(U, Decl(unionTypeInference.ts, 33, 9))
}
export interface Bar<T> {
>Bar : Symbol(Bar, Decl(unionTypeInference.ts, 34, 1))
>T : Symbol(T, Decl(unionTypeInference.ts, 35, 21))
then<S>(f: (x: T) => S | Bar<S>, g: S): Bar<S>;
>then : Symbol(Bar.then, Decl(unionTypeInference.ts, 35, 25))
>S : Symbol(S, Decl(unionTypeInference.ts, 36, 9))
>f : Symbol(f, Decl(unionTypeInference.ts, 36, 12))
>x : Symbol(x, Decl(unionTypeInference.ts, 36, 16))
>T : Symbol(T, Decl(unionTypeInference.ts, 35, 21))
>S : Symbol(S, Decl(unionTypeInference.ts, 36, 9))
>Bar : Symbol(Bar, Decl(unionTypeInference.ts, 34, 1))
>S : Symbol(S, Decl(unionTypeInference.ts, 36, 9))
>g : Symbol(g, Decl(unionTypeInference.ts, 36, 36))
>S : Symbol(S, Decl(unionTypeInference.ts, 36, 9))
>Bar : Symbol(Bar, Decl(unionTypeInference.ts, 34, 1))
>S : Symbol(S, Decl(unionTypeInference.ts, 36, 9))
}
function qux(p1: Foo<void>, p2: Bar<void>) {
>qux : Symbol(qux, Decl(unionTypeInference.ts, 37, 1))
>p1 : Symbol(p1, Decl(unionTypeInference.ts, 39, 13))
>Foo : Symbol(Foo, Decl(unionTypeInference.ts, 30, 18))
>p2 : Symbol(p2, Decl(unionTypeInference.ts, 39, 27))
>Bar : Symbol(Bar, Decl(unionTypeInference.ts, 34, 1))
p1 = p2;
>p1 : Symbol(p1, Decl(unionTypeInference.ts, 39, 13))
>p2 : Symbol(p2, Decl(unionTypeInference.ts, 39, 27))
}
// Repros from #32434
declare function foo<T>(x: T | Promise<T>): void;
>foo : Symbol(foo, Decl(unionTypeInference.ts, 30, 18))
>T : Symbol(T, Decl(unionTypeInference.ts, 34, 21))
>x : Symbol(x, Decl(unionTypeInference.ts, 34, 24))
>T : Symbol(T, Decl(unionTypeInference.ts, 34, 21))
>foo : Symbol(foo, Decl(unionTypeInference.ts, 41, 1))
>T : Symbol(T, Decl(unionTypeInference.ts, 45, 21))
>x : Symbol(x, Decl(unionTypeInference.ts, 45, 24))
>T : Symbol(T, Decl(unionTypeInference.ts, 45, 21))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(unionTypeInference.ts, 34, 21))
>T : Symbol(T, Decl(unionTypeInference.ts, 45, 21))
declare let x: false | Promise<true>;
>x : Symbol(x, Decl(unionTypeInference.ts, 35, 11))
>x : Symbol(x, Decl(unionTypeInference.ts, 46, 11))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --))
foo(x);
>foo : Symbol(foo, Decl(unionTypeInference.ts, 30, 18))
>x : Symbol(x, Decl(unionTypeInference.ts, 35, 11))
>foo : Symbol(foo, Decl(unionTypeInference.ts, 41, 1))
>x : Symbol(x, Decl(unionTypeInference.ts, 46, 11))
declare function bar<T>(x: T, y: string | T): T;
>bar : Symbol(bar, Decl(unionTypeInference.ts, 36, 7))
>T : Symbol(T, Decl(unionTypeInference.ts, 38, 21))
>x : Symbol(x, Decl(unionTypeInference.ts, 38, 24))
>T : Symbol(T, Decl(unionTypeInference.ts, 38, 21))
>y : Symbol(y, Decl(unionTypeInference.ts, 38, 29))
>T : Symbol(T, Decl(unionTypeInference.ts, 38, 21))
>T : Symbol(T, Decl(unionTypeInference.ts, 38, 21))
>bar : Symbol(bar, Decl(unionTypeInference.ts, 47, 7))
>T : Symbol(T, Decl(unionTypeInference.ts, 49, 21))
>x : Symbol(x, Decl(unionTypeInference.ts, 49, 24))
>T : Symbol(T, Decl(unionTypeInference.ts, 49, 21))
>y : Symbol(y, Decl(unionTypeInference.ts, 49, 29))
>T : Symbol(T, Decl(unionTypeInference.ts, 49, 21))
>T : Symbol(T, Decl(unionTypeInference.ts, 49, 21))
const y = bar(1, 2);
>y : Symbol(y, Decl(unionTypeInference.ts, 39, 5))
>bar : Symbol(bar, Decl(unionTypeInference.ts, 36, 7))
>y : Symbol(y, Decl(unionTypeInference.ts, 50, 5))
>bar : Symbol(bar, Decl(unionTypeInference.ts, 47, 7))

View file

@ -131,6 +131,32 @@ const d3 = f4(42); // Error
>f4 : <T>(x: string & T) => T
>42 : 42
export interface Foo<T> {
then<U>(f: (x: T) => U | Foo<U>, g: U): Foo<U>;
>then : <U>(f: (x: T) => U | Foo<U>, g: U) => Foo<U>
>f : (x: T) => U | Foo<U>
>x : T
>g : U
}
export interface Bar<T> {
then<S>(f: (x: T) => S | Bar<S>, g: S): Bar<S>;
>then : <S>(f: (x: T) => S | Bar<S>, g: S) => Bar<S>
>f : (x: T) => S | Bar<S>
>x : T
>g : S
}
function qux(p1: Foo<void>, p2: Bar<void>) {
>qux : (p1: Foo<void>, p2: Bar<void>) => void
>p1 : Foo<void>
>p2 : Bar<void>
p1 = p2;
>p1 = p2 : Bar<void>
>p1 : Foo<void>
>p2 : Bar<void>
}
// Repros from #32434
declare function foo<T>(x: T | Promise<T>): void;