Skip to content

Commit

Permalink
Baseline updates
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Jun 25, 2020
1 parent e81d845 commit ed01085
Show file tree
Hide file tree
Showing 20 changed files with 655 additions and 71 deletions.
100 changes: 100 additions & 0 deletions tests/baselines/reference/consistentUnionSubtypeReduction.js
@@ -0,0 +1,100 @@
//// [consistentUnionSubtypeReduction.ts]
// https://github.com/microsoft/TypeScript/issues/31155

declare const MyArray: {
isArray<T>(arg: T | {}): arg is T extends readonly any[] ? readonly any[] : any[];
};

declare const a: readonly string[] | string;
declare const b: string[] | string;
declare const c: unknown;

if (MyArray.isArray(a)) {
a; // readonly string[]
}
else {
a; // string
}
a; // readonly string[] | string;

if (MyArray.isArray(b)) {
b; // string[] | string;
}
else {
b; // string
}
b; // string[] | string;

if (MyArray.isArray(c)) {
c; // any[]
}


function f<T>(x: T) {
const a: readonly T[] | string = null!;
const b: T[] | string = null!;
const c: T = null!;

if (MyArray.isArray(a)) {
a; // readonly T[]
}
else {
a; // string
}
a; // readonly T[] | string;

if (MyArray.isArray(b)) {
b; // T[]
}
else {
b; // string
}
b;

if (MyArray.isArray(c)) {
c; // T & (T extends readonly any[] ? readonly any[] : any[])
}
}


//// [consistentUnionSubtypeReduction.js]
// https://github.com/microsoft/TypeScript/issues/31155
if (MyArray.isArray(a)) {
a; // readonly string[]
}
else {
a; // string
}
a; // readonly string[] | string;
if (MyArray.isArray(b)) {
b; // string[] | string;
}
else {
b; // string
}
b; // string[] | string;
if (MyArray.isArray(c)) {
c; // any[]
}
function f(x) {
var a = null;
var b = null;
var c = null;
if (MyArray.isArray(a)) {
a; // readonly T[]
}
else {
a; // string
}
a; // readonly T[] | string;
if (MyArray.isArray(b)) {
b; // T[]
}
else {
b; // string
}
b;
if (MyArray.isArray(c)) {
c; // T & (T extends readonly any[] ? readonly any[] : any[])
}
}
129 changes: 129 additions & 0 deletions tests/baselines/reference/consistentUnionSubtypeReduction.symbols
@@ -0,0 +1,129 @@
=== tests/cases/compiler/consistentUnionSubtypeReduction.ts ===
// https://github.com/microsoft/TypeScript/issues/31155

declare const MyArray: {
>MyArray : Symbol(MyArray, Decl(consistentUnionSubtypeReduction.ts, 2, 13))

isArray<T>(arg: T | {}): arg is T extends readonly any[] ? readonly any[] : any[];
>isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>T : Symbol(T, Decl(consistentUnionSubtypeReduction.ts, 3, 12))
>arg : Symbol(arg, Decl(consistentUnionSubtypeReduction.ts, 3, 15))
>T : Symbol(T, Decl(consistentUnionSubtypeReduction.ts, 3, 12))
>arg : Symbol(arg, Decl(consistentUnionSubtypeReduction.ts, 3, 15))
>T : Symbol(T, Decl(consistentUnionSubtypeReduction.ts, 3, 12))

};

declare const a: readonly string[] | string;
>a : Symbol(a, Decl(consistentUnionSubtypeReduction.ts, 6, 13))

declare const b: string[] | string;
>b : Symbol(b, Decl(consistentUnionSubtypeReduction.ts, 7, 13))

declare const c: unknown;
>c : Symbol(c, Decl(consistentUnionSubtypeReduction.ts, 8, 13))

if (MyArray.isArray(a)) {
>MyArray.isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>MyArray : Symbol(MyArray, Decl(consistentUnionSubtypeReduction.ts, 2, 13))
>isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>a : Symbol(a, Decl(consistentUnionSubtypeReduction.ts, 6, 13))

a; // readonly string[]
>a : Symbol(a, Decl(consistentUnionSubtypeReduction.ts, 6, 13))
}
else {
a; // string
>a : Symbol(a, Decl(consistentUnionSubtypeReduction.ts, 6, 13))
}
a; // readonly string[] | string;
>a : Symbol(a, Decl(consistentUnionSubtypeReduction.ts, 6, 13))

if (MyArray.isArray(b)) {
>MyArray.isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>MyArray : Symbol(MyArray, Decl(consistentUnionSubtypeReduction.ts, 2, 13))
>isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>b : Symbol(b, Decl(consistentUnionSubtypeReduction.ts, 7, 13))

b; // string[] | string;
>b : Symbol(b, Decl(consistentUnionSubtypeReduction.ts, 7, 13))
}
else {
b; // string
>b : Symbol(b, Decl(consistentUnionSubtypeReduction.ts, 7, 13))
}
b; // string[] | string;
>b : Symbol(b, Decl(consistentUnionSubtypeReduction.ts, 7, 13))

if (MyArray.isArray(c)) {
>MyArray.isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>MyArray : Symbol(MyArray, Decl(consistentUnionSubtypeReduction.ts, 2, 13))
>isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>c : Symbol(c, Decl(consistentUnionSubtypeReduction.ts, 8, 13))

c; // any[]
>c : Symbol(c, Decl(consistentUnionSubtypeReduction.ts, 8, 13))
}


function f<T>(x: T) {
>f : Symbol(f, Decl(consistentUnionSubtypeReduction.ts, 28, 1))
>T : Symbol(T, Decl(consistentUnionSubtypeReduction.ts, 31, 11))
>x : Symbol(x, Decl(consistentUnionSubtypeReduction.ts, 31, 14))
>T : Symbol(T, Decl(consistentUnionSubtypeReduction.ts, 31, 11))

const a: readonly T[] | string = null!;
>a : Symbol(a, Decl(consistentUnionSubtypeReduction.ts, 32, 9))
>T : Symbol(T, Decl(consistentUnionSubtypeReduction.ts, 31, 11))

const b: T[] | string = null!;
>b : Symbol(b, Decl(consistentUnionSubtypeReduction.ts, 33, 9))
>T : Symbol(T, Decl(consistentUnionSubtypeReduction.ts, 31, 11))

const c: T = null!;
>c : Symbol(c, Decl(consistentUnionSubtypeReduction.ts, 34, 9))
>T : Symbol(T, Decl(consistentUnionSubtypeReduction.ts, 31, 11))

if (MyArray.isArray(a)) {
>MyArray.isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>MyArray : Symbol(MyArray, Decl(consistentUnionSubtypeReduction.ts, 2, 13))
>isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>a : Symbol(a, Decl(consistentUnionSubtypeReduction.ts, 32, 9))

a; // readonly T[]
>a : Symbol(a, Decl(consistentUnionSubtypeReduction.ts, 32, 9))
}
else {
a; // string
>a : Symbol(a, Decl(consistentUnionSubtypeReduction.ts, 32, 9))
}
a; // readonly T[] | string;
>a : Symbol(a, Decl(consistentUnionSubtypeReduction.ts, 32, 9))

if (MyArray.isArray(b)) {
>MyArray.isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>MyArray : Symbol(MyArray, Decl(consistentUnionSubtypeReduction.ts, 2, 13))
>isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>b : Symbol(b, Decl(consistentUnionSubtypeReduction.ts, 33, 9))

b; // T[]
>b : Symbol(b, Decl(consistentUnionSubtypeReduction.ts, 33, 9))
}
else {
b; // string
>b : Symbol(b, Decl(consistentUnionSubtypeReduction.ts, 33, 9))
}
b;
>b : Symbol(b, Decl(consistentUnionSubtypeReduction.ts, 33, 9))

if (MyArray.isArray(c)) {
>MyArray.isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>MyArray : Symbol(MyArray, Decl(consistentUnionSubtypeReduction.ts, 2, 13))
>isArray : Symbol(isArray, Decl(consistentUnionSubtypeReduction.ts, 2, 24))
>c : Symbol(c, Decl(consistentUnionSubtypeReduction.ts, 34, 9))

c; // T & (T extends readonly any[] ? readonly any[] : any[])
>c : Symbol(c, Decl(consistentUnionSubtypeReduction.ts, 34, 9))
}
}

132 changes: 132 additions & 0 deletions tests/baselines/reference/consistentUnionSubtypeReduction.types
@@ -0,0 +1,132 @@
=== tests/cases/compiler/consistentUnionSubtypeReduction.ts ===
// https://github.com/microsoft/TypeScript/issues/31155

declare const MyArray: {
>MyArray : { isArray<T>(arg: {} | T): arg is T extends readonly any[] ? readonly any[] : any[]; }

isArray<T>(arg: T | {}): arg is T extends readonly any[] ? readonly any[] : any[];
>isArray : <T>(arg: T | {}) => arg is T extends readonly any[] ? readonly any[] : any[]
>arg : {} | T

};

declare const a: readonly string[] | string;
>a : string | readonly string[]

declare const b: string[] | string;
>b : string | string[]

declare const c: unknown;
>c : unknown

if (MyArray.isArray(a)) {
>MyArray.isArray(a) : boolean
>MyArray.isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>MyArray : { isArray<T>(arg: {} | T): arg is T extends readonly any[] ? readonly any[] : any[]; }
>isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>a : string | readonly string[]

a; // readonly string[]
>a : readonly string[]
}
else {
a; // string
>a : string
}
a; // readonly string[] | string;
>a : string | readonly string[]

if (MyArray.isArray(b)) {
>MyArray.isArray(b) : boolean
>MyArray.isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>MyArray : { isArray<T>(arg: {} | T): arg is T extends readonly any[] ? readonly any[] : any[]; }
>isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>b : string | string[]

b; // string[] | string;
>b : string[]
}
else {
b; // string
>b : string
}
b; // string[] | string;
>b : string | string[]

if (MyArray.isArray(c)) {
>MyArray.isArray(c) : boolean
>MyArray.isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>MyArray : { isArray<T>(arg: {} | T): arg is T extends readonly any[] ? readonly any[] : any[]; }
>isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>c : unknown

c; // any[]
>c : any[]
}


function f<T>(x: T) {
>f : <T>(x: T) => void
>x : T

const a: readonly T[] | string = null!;
>a : string | readonly T[]
>null! : null
>null : null

const b: T[] | string = null!;
>b : string | T[]
>null! : null
>null : null

const c: T = null!;
>c : T
>null! : null
>null : null

if (MyArray.isArray(a)) {
>MyArray.isArray(a) : boolean
>MyArray.isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>MyArray : { isArray<T>(arg: {} | T): arg is T extends readonly any[] ? readonly any[] : any[]; }
>isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>a : string | readonly T[]

a; // readonly T[]
>a : readonly T[]
}
else {
a; // string
>a : string
}
a; // readonly T[] | string;
>a : string | readonly T[]

if (MyArray.isArray(b)) {
>MyArray.isArray(b) : boolean
>MyArray.isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>MyArray : { isArray<T>(arg: {} | T): arg is T extends readonly any[] ? readonly any[] : any[]; }
>isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>b : string | T[]

b; // T[]
>b : T[]
}
else {
b; // string
>b : string
}
b;
>b : string | T[]

if (MyArray.isArray(c)) {
>MyArray.isArray(c) : boolean
>MyArray.isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>MyArray : { isArray<T>(arg: {} | T): arg is T extends readonly any[] ? readonly any[] : any[]; }
>isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>c : T

c; // T & (T extends readonly any[] ? readonly any[] : any[])
>c : T & (T extends readonly any[] ? readonly any[] : any[])
}
}

Expand Up @@ -67,9 +67,9 @@ export const updateIfChanged = <T>(t: T) => {
>assign : { <T, U>(target: T, source: U): T & U; <T, U, V>(target: T, source1: U, source2: V): T & U & V; <T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; }
>Array.isArray(u) ? [] : {} : undefined[] | {}
>Array.isArray(u) : boolean
>Array.isArray : (arg: any) => arg is any[]
>Array.isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>Array : ArrayConstructor
>isArray : (arg: any) => arg is any[]
>isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>u : U
>[] : undefined[]
>{} : {}
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/fixSignatureCaching.types
Expand Up @@ -1109,9 +1109,9 @@ define(function () {
>Array : ArrayConstructor

Array.isArray : function (value) { return Object.prototype.toString.call(value) === '[object Array]'; };
>Array.isArray : (arg: any) => arg is any[]
>Array.isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>Array : ArrayConstructor
>isArray : (arg: any) => arg is any[]
>isArray : <T>(arg: {} | T) => arg is T extends readonly any[] ? readonly any[] : any[]
>function (value) { return Object.prototype.toString.call(value) === '[object Array]'; } : (value: any) => boolean
>value : any
>Object.prototype.toString.call(value) === '[object Array]' : boolean
Expand Down

0 comments on commit ed01085

Please sign in to comment.