Test updates from union changes

This commit is contained in:
Dan Quirk
2014-10-10 14:41:14 -07:00
parent 95584e9104
commit bacb9d0b22
139 changed files with 2558 additions and 3336 deletions
+214 -98
View File
@@ -1,55 +1,109 @@
//// [arrayBestCommonTypes.ts]
interface iface { }
class base implements iface { }
class base2 implements iface { }
class derived extends base { }
module EmptyTypes {
interface iface { }
class base implements iface { }
class base2 implements iface { }
class derived extends base { }
class f {
public voidIfAny(x: boolean, y?: boolean): number;
public voidIfAny(x: string, y?: boolean): number;
public voidIfAny(x: number, y?: boolean): number;
public voidIfAny(x: any, y =false): any { return null; }
public x() {
<number>(this.voidIfAny([4, 2][0]));
<number>(this.voidIfAny([4, 2, undefined][0]));
<number>(this.voidIfAny([undefined, 2, 4][0]));
<number>(this.voidIfAny([null, 2, 4][0]));
<number>(this.voidIfAny([2, 4, null][0]));
<number>(this.voidIfAny([undefined, 4, null][0]));
class f {
public voidIfAny(x: boolean, y?: boolean): number;
public voidIfAny(x: string, y?: boolean): number;
public voidIfAny(x: number, y?: boolean): number;
public voidIfAny(x: any, y = false): any { return null; }
<number>(this.voidIfAny(['', "q"][0]));
<number>(this.voidIfAny(['', "q", undefined][0]));
<number>(this.voidIfAny([undefined, "q", ''][0]));
<number>(this.voidIfAny([null, "q", ''][0]));
<number>(this.voidIfAny(["q", '', null][0]));
<number>(this.voidIfAny([undefined, '', null][0]));
public x() {
<number>(this.voidIfAny([4, 2][0]));
<number>(this.voidIfAny([4, 2, undefined][0]));
<number>(this.voidIfAny([undefined, 2, 4][0]));
<number>(this.voidIfAny([null, 2, 4][0]));
<number>(this.voidIfAny([2, 4, null][0]));
<number>(this.voidIfAny([undefined, 4, null][0]));
<number>(this.voidIfAny([[3,4],[null]][0][0]));
var t1: { x: number; y: base; }[] = [ { x: 7, y: new derived() }, { x: 5, y: new base() } ];
var t2: { x: boolean; y: base; }[] = [ { x: true, y: new derived() }, { x: false, y: new base() } ];
var t3: { x: string; y: base; }[] = [ { x: undefined, y: new base() }, { x: '', y: new derived() } ];
<number>(this.voidIfAny(['', "q"][0]));
<number>(this.voidIfAny(['', "q", undefined][0]));
<number>(this.voidIfAny([undefined, "q", ''][0]));
<number>(this.voidIfAny([null, "q", ''][0]));
<number>(this.voidIfAny(["q", '', null][0]));
<number>(this.voidIfAny([undefined, '', null][0]));
var anyObj: any = null;
// Order matters here so test all the variants
var a1 = [ {x: 0, y: 'a'}, {x: 'a', y: 'a'}, {x: anyObj, y: 'a'} ];
var a2 = [ {x: anyObj, y: 'a'}, {x: 0, y: 'a'}, {x: 'a', y: 'a'} ];
var a3 = [ {x: 0, y: 'a'}, {x: anyObj, y: 'a'}, {x: 'a', y: 'a'} ];
var ifaceObj: iface = null;
var baseObj = new base();
var base2Obj = new base2();
<number>(this.voidIfAny([[3, 4], [null]][0][0]));
var b1 = [ baseObj, base2Obj, ifaceObj ];
var b2 = [ base2Obj, baseObj, ifaceObj ];
var b3 = [ baseObj, ifaceObj, base2Obj ];
var b4 = [ ifaceObj, baseObj, base2Obj ];
var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }];
var t2: { x: boolean; y: base; }[] = [{ x: true, y: new derived() }, { x: false, y: new base() }];
var t3: { x: string; y: base; }[] = [{ x: undefined, y: new base() }, { x: '', y: new derived() }];
var anyObj: any = null;
// Order matters here so test all the variants
var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }];
var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }];
var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }];
var ifaceObj: iface = null;
var baseObj = new base();
var base2Obj = new base2();
var b1 = [baseObj, base2Obj, ifaceObj];
var b2 = [base2Obj, baseObj, ifaceObj];
var b3 = [baseObj, ifaceObj, base2Obj];
var b4 = [ifaceObj, baseObj, base2Obj];
}
}
}
module NonEmptyTypes {
interface iface { x: string; }
class base implements iface { x: string; y: string; }
class base2 implements iface { x: string; z: string; }
class derived extends base { a: string; }
class f {
public voidIfAny(x: boolean, y?: boolean): number;
public voidIfAny(x: string, y?: boolean): number;
public voidIfAny(x: number, y?: boolean): number;
public voidIfAny(x: any, y = false): any { return null; }
public x() {
<number>(this.voidIfAny([4, 2][0]));
<number>(this.voidIfAny([4, 2, undefined][0]));
<number>(this.voidIfAny([undefined, 2, 4][0]));
<number>(this.voidIfAny([null, 2, 4][0]));
<number>(this.voidIfAny([2, 4, null][0]));
<number>(this.voidIfAny([undefined, 4, null][0]));
<number>(this.voidIfAny(['', "q"][0]));
<number>(this.voidIfAny(['', "q", undefined][0]));
<number>(this.voidIfAny([undefined, "q", ''][0]));
<number>(this.voidIfAny([null, "q", ''][0]));
<number>(this.voidIfAny(["q", '', null][0]));
<number>(this.voidIfAny([undefined, '', null][0]));
<number>(this.voidIfAny([[3, 4], [null]][0][0]));
var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }];
var t2: { x: boolean; y: base; }[] = [{ x: true, y: new derived() }, { x: false, y: new base() }];
var t3: { x: string; y: base; }[] = [{ x: undefined, y: new base() }, { x: '', y: new derived() }];
var anyObj: any = null;
// Order matters here so test all the variants
var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }];
var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }];
var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }];
var ifaceObj: iface = null;
var baseObj = new base();
var base2Obj = new base2();
var b1 = [baseObj, base2Obj, ifaceObj];
var b2 = [base2Obj, baseObj, ifaceObj];
var b3 = [baseObj, ifaceObj, base2Obj];
var b4 = [ifaceObj, baseObj, base2Obj];
}
}
}
@@ -60,59 +114,121 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
var base = (function () {
function base() {
}
return base;
})();
var base2 = (function () {
function base2() {
}
return base2;
})();
var derived = (function (_super) {
__extends(derived, _super);
function derived() {
_super.apply(this, arguments);
}
return derived;
})(base);
var f = (function () {
function f() {
}
f.prototype.voidIfAny = function (x, y) {
if (y === void 0) { y = false; }
return null;
};
f.prototype.x = function () {
(this.voidIfAny([4, 2][0]));
(this.voidIfAny([4, 2, undefined][0]));
(this.voidIfAny([undefined, 2, 4][0]));
(this.voidIfAny([null, 2, 4][0]));
(this.voidIfAny([2, 4, null][0]));
(this.voidIfAny([undefined, 4, null][0]));
(this.voidIfAny(['', "q"][0]));
(this.voidIfAny(['', "q", undefined][0]));
(this.voidIfAny([undefined, "q", ''][0]));
(this.voidIfAny([null, "q", ''][0]));
(this.voidIfAny(["q", '', null][0]));
(this.voidIfAny([undefined, '', null][0]));
(this.voidIfAny([[3, 4], [null]][0][0]));
var t1 = [{ x: 7, y: new derived() }, { x: 5, y: new base() }];
var t2 = [{ x: true, y: new derived() }, { x: false, y: new base() }];
var t3 = [{ x: undefined, y: new base() }, { x: '', y: new derived() }];
var anyObj = null;
// Order matters here so test all the variants
var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }];
var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }];
var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }];
var ifaceObj = null;
var baseObj = new base();
var base2Obj = new base2();
var b1 = [baseObj, base2Obj, ifaceObj];
var b2 = [base2Obj, baseObj, ifaceObj];
var b3 = [baseObj, ifaceObj, base2Obj];
var b4 = [ifaceObj, baseObj, base2Obj];
};
return f;
})();
var EmptyTypes;
(function (EmptyTypes) {
var base = (function () {
function base() {
}
return base;
})();
var base2 = (function () {
function base2() {
}
return base2;
})();
var derived = (function (_super) {
__extends(derived, _super);
function derived() {
_super.apply(this, arguments);
}
return derived;
})(base);
var f = (function () {
function f() {
}
f.prototype.voidIfAny = function (x, y) {
if (y === void 0) { y = false; }
return null;
};
f.prototype.x = function () {
(this.voidIfAny([4, 2][0]));
(this.voidIfAny([4, 2, undefined][0]));
(this.voidIfAny([undefined, 2, 4][0]));
(this.voidIfAny([null, 2, 4][0]));
(this.voidIfAny([2, 4, null][0]));
(this.voidIfAny([undefined, 4, null][0]));
(this.voidIfAny(['', "q"][0]));
(this.voidIfAny(['', "q", undefined][0]));
(this.voidIfAny([undefined, "q", ''][0]));
(this.voidIfAny([null, "q", ''][0]));
(this.voidIfAny(["q", '', null][0]));
(this.voidIfAny([undefined, '', null][0]));
(this.voidIfAny([[3, 4], [null]][0][0]));
var t1 = [{ x: 7, y: new derived() }, { x: 5, y: new base() }];
var t2 = [{ x: true, y: new derived() }, { x: false, y: new base() }];
var t3 = [{ x: undefined, y: new base() }, { x: '', y: new derived() }];
var anyObj = null;
// Order matters here so test all the variants
var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }];
var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }];
var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }];
var ifaceObj = null;
var baseObj = new base();
var base2Obj = new base2();
var b1 = [baseObj, base2Obj, ifaceObj];
var b2 = [base2Obj, baseObj, ifaceObj];
var b3 = [baseObj, ifaceObj, base2Obj];
var b4 = [ifaceObj, baseObj, base2Obj];
};
return f;
})();
})(EmptyTypes || (EmptyTypes = {}));
var NonEmptyTypes;
(function (NonEmptyTypes) {
var base = (function () {
function base() {
}
return base;
})();
var base2 = (function () {
function base2() {
}
return base2;
})();
var derived = (function (_super) {
__extends(derived, _super);
function derived() {
_super.apply(this, arguments);
}
return derived;
})(base);
var f = (function () {
function f() {
}
f.prototype.voidIfAny = function (x, y) {
if (y === void 0) { y = false; }
return null;
};
f.prototype.x = function () {
(this.voidIfAny([4, 2][0]));
(this.voidIfAny([4, 2, undefined][0]));
(this.voidIfAny([undefined, 2, 4][0]));
(this.voidIfAny([null, 2, 4][0]));
(this.voidIfAny([2, 4, null][0]));
(this.voidIfAny([undefined, 4, null][0]));
(this.voidIfAny(['', "q"][0]));
(this.voidIfAny(['', "q", undefined][0]));
(this.voidIfAny([undefined, "q", ''][0]));
(this.voidIfAny([null, "q", ''][0]));
(this.voidIfAny(["q", '', null][0]));
(this.voidIfAny([undefined, '', null][0]));
(this.voidIfAny([[3, 4], [null]][0][0]));
var t1 = [{ x: 7, y: new derived() }, { x: 5, y: new base() }];
var t2 = [{ x: true, y: new derived() }, { x: false, y: new base() }];
var t3 = [{ x: undefined, y: new base() }, { x: '', y: new derived() }];
var anyObj = null;
// Order matters here so test all the variants
var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }];
var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }];
var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }];
var ifaceObj = null;
var baseObj = new base();
var base2Obj = new base2();
var b1 = [baseObj, base2Obj, ifaceObj];
var b2 = [base2Obj, baseObj, ifaceObj];
var b3 = [baseObj, ifaceObj, base2Obj];
var b4 = [ifaceObj, baseObj, base2Obj];
};
return f;
})();
})(NonEmptyTypes || (NonEmptyTypes = {}));
@@ -1,47 +1,50 @@
=== tests/cases/compiler/arrayBestCommonTypes.ts ===
interface iface { }
module EmptyTypes {
>EmptyTypes : typeof EmptyTypes
interface iface { }
>iface : iface
class base implements iface { }
class base implements iface { }
>base : base
>iface : iface
class base2 implements iface { }
class base2 implements iface { }
>base2 : base2
>iface : iface
class derived extends base { }
class derived extends base { }
>derived : derived
>base : base
class f {
class f {
>f : f
public voidIfAny(x: boolean, y?: boolean): number;
public voidIfAny(x: boolean, y?: boolean): number;
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>x : boolean
>y : boolean
public voidIfAny(x: string, y?: boolean): number;
public voidIfAny(x: string, y?: boolean): number;
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>x : string
>y : boolean
public voidIfAny(x: number, y?: boolean): number;
public voidIfAny(x: number, y?: boolean): number;
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>x : number
>y : boolean
public voidIfAny(x: any, y =false): any { return null; }
public voidIfAny(x: any, y = false): any { return null; }
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>x : any
>y : boolean
public x() {
public x() {
>x : () => void
<number>(this.voidIfAny([4, 2][0]));
<number>(this.voidIfAny([4, 2][0]));
><number>(this.voidIfAny([4, 2][0])) : number
>(this.voidIfAny([4, 2][0])) : number
>this.voidIfAny([4, 2][0]) : number
@@ -51,7 +54,7 @@ class f {
>[4, 2][0] : number
>[4, 2] : number[]
<number>(this.voidIfAny([4, 2, undefined][0]));
<number>(this.voidIfAny([4, 2, undefined][0]));
><number>(this.voidIfAny([4, 2, undefined][0])) : number
>(this.voidIfAny([4, 2, undefined][0])) : number
>this.voidIfAny([4, 2, undefined][0]) : number
@@ -62,7 +65,7 @@ class f {
>[4, 2, undefined] : number[]
>undefined : undefined
<number>(this.voidIfAny([undefined, 2, 4][0]));
<number>(this.voidIfAny([undefined, 2, 4][0]));
><number>(this.voidIfAny([undefined, 2, 4][0])) : number
>(this.voidIfAny([undefined, 2, 4][0])) : number
>this.voidIfAny([undefined, 2, 4][0]) : number
@@ -73,7 +76,7 @@ class f {
>[undefined, 2, 4] : number[]
>undefined : undefined
<number>(this.voidIfAny([null, 2, 4][0]));
<number>(this.voidIfAny([null, 2, 4][0]));
><number>(this.voidIfAny([null, 2, 4][0])) : number
>(this.voidIfAny([null, 2, 4][0])) : number
>this.voidIfAny([null, 2, 4][0]) : number
@@ -83,7 +86,7 @@ class f {
>[null, 2, 4][0] : number
>[null, 2, 4] : number[]
<number>(this.voidIfAny([2, 4, null][0]));
<number>(this.voidIfAny([2, 4, null][0]));
><number>(this.voidIfAny([2, 4, null][0])) : number
>(this.voidIfAny([2, 4, null][0])) : number
>this.voidIfAny([2, 4, null][0]) : number
@@ -93,7 +96,7 @@ class f {
>[2, 4, null][0] : number
>[2, 4, null] : number[]
<number>(this.voidIfAny([undefined, 4, null][0]));
<number>(this.voidIfAny([undefined, 4, null][0]));
><number>(this.voidIfAny([undefined, 4, null][0])) : number
>(this.voidIfAny([undefined, 4, null][0])) : number
>this.voidIfAny([undefined, 4, null][0]) : number
@@ -104,7 +107,7 @@ class f {
>[undefined, 4, null] : number[]
>undefined : undefined
<number>(this.voidIfAny(['', "q"][0]));
<number>(this.voidIfAny(['', "q"][0]));
><number>(this.voidIfAny(['', "q"][0])) : number
>(this.voidIfAny(['', "q"][0])) : number
>this.voidIfAny(['', "q"][0]) : number
@@ -114,7 +117,7 @@ class f {
>['', "q"][0] : string
>['', "q"] : string[]
<number>(this.voidIfAny(['', "q", undefined][0]));
<number>(this.voidIfAny(['', "q", undefined][0]));
><number>(this.voidIfAny(['', "q", undefined][0])) : number
>(this.voidIfAny(['', "q", undefined][0])) : number
>this.voidIfAny(['', "q", undefined][0]) : number
@@ -125,7 +128,7 @@ class f {
>['', "q", undefined] : string[]
>undefined : undefined
<number>(this.voidIfAny([undefined, "q", ''][0]));
<number>(this.voidIfAny([undefined, "q", ''][0]));
><number>(this.voidIfAny([undefined, "q", ''][0])) : number
>(this.voidIfAny([undefined, "q", ''][0])) : number
>this.voidIfAny([undefined, "q", ''][0]) : number
@@ -136,7 +139,7 @@ class f {
>[undefined, "q", ''] : string[]
>undefined : undefined
<number>(this.voidIfAny([null, "q", ''][0]));
<number>(this.voidIfAny([null, "q", ''][0]));
><number>(this.voidIfAny([null, "q", ''][0])) : number
>(this.voidIfAny([null, "q", ''][0])) : number
>this.voidIfAny([null, "q", ''][0]) : number
@@ -146,7 +149,7 @@ class f {
>[null, "q", ''][0] : string
>[null, "q", ''] : string[]
<number>(this.voidIfAny(["q", '', null][0]));
<number>(this.voidIfAny(["q", '', null][0]));
><number>(this.voidIfAny(["q", '', null][0])) : number
>(this.voidIfAny(["q", '', null][0])) : number
>this.voidIfAny(["q", '', null][0]) : number
@@ -156,7 +159,7 @@ class f {
>["q", '', null][0] : string
>["q", '', null] : string[]
<number>(this.voidIfAny([undefined, '', null][0]));
<number>(this.voidIfAny([undefined, '', null][0]));
><number>(this.voidIfAny([undefined, '', null][0])) : number
>(this.voidIfAny([undefined, '', null][0])) : number
>this.voidIfAny([undefined, '', null][0]) : number
@@ -167,26 +170,26 @@ class f {
>[undefined, '', null] : string[]
>undefined : undefined
<number>(this.voidIfAny([[3,4],[null]][0][0]));
><number>(this.voidIfAny([[3,4],[null]][0][0])) : number
>(this.voidIfAny([[3,4],[null]][0][0])) : number
>this.voidIfAny([[3,4],[null]][0][0]) : number
<number>(this.voidIfAny([[3, 4], [null]][0][0]));
><number>(this.voidIfAny([[3, 4], [null]][0][0])) : number
>(this.voidIfAny([[3, 4], [null]][0][0])) : number
>this.voidIfAny([[3, 4], [null]][0][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[[3,4],[null]][0][0] : number
>[[3,4],[null]][0] : number[]
>[[3,4],[null]] : number[][]
>[3,4] : number[]
>[[3, 4], [null]][0][0] : number
>[[3, 4], [null]][0] : number[]
>[[3, 4], [null]] : number[][]
>[3, 4] : number[]
>[null] : null[]
var t1: { x: number; y: base; }[] = [ { x: 7, y: new derived() }, { x: 5, y: new base() } ];
var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }];
>t1 : { x: number; y: base; }[]
>x : number
>y : base
>base : base
>[ { x: 7, y: new derived() }, { x: 5, y: new base() } ] : { x: number; y: base; }[]
>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: base; }[]
>{ x: 7, y: new derived() } : { x: number; y: derived; }
>x : number
>y : derived
@@ -198,12 +201,12 @@ class f {
>new base() : base
>base : typeof base
var t2: { x: boolean; y: base; }[] = [ { x: true, y: new derived() }, { x: false, y: new base() } ];
var t2: { x: boolean; y: base; }[] = [{ x: true, y: new derived() }, { x: false, y: new base() }];
>t2 : { x: boolean; y: base; }[]
>x : boolean
>y : base
>base : base
>[ { x: true, y: new derived() }, { x: false, y: new base() } ] : { x: boolean; y: base; }[]
>[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: base; }[]
>{ x: true, y: new derived() } : { x: boolean; y: derived; }
>x : boolean
>y : derived
@@ -215,12 +218,12 @@ class f {
>new base() : base
>base : typeof base
var t3: { x: string; y: base; }[] = [ { x: undefined, y: new base() }, { x: '', y: new derived() } ];
var t3: { x: string; y: base; }[] = [{ x: undefined, y: new base() }, { x: '', y: new derived() }];
>t3 : { x: string; y: base; }[]
>x : string
>y : base
>base : base
>[ { x: undefined, y: new base() }, { x: '', y: new derived() } ] : { x: string; y: base; }[]
>[{ x: undefined, y: new base() }, { x: '', y: new derived() }] : { x: string; y: base; }[]
>{ x: undefined, y: new base() } : { x: undefined; y: base; }
>x : undefined
>undefined : undefined
@@ -233,95 +236,429 @@ class f {
>new derived() : derived
>derived : typeof derived
var anyObj: any = null;
var anyObj: any = null;
>anyObj : any
// Order matters here so test all the variants
var a1 = [ {x: 0, y: 'a'}, {x: 'a', y: 'a'}, {x: anyObj, y: 'a'} ];
// Order matters here so test all the variants
var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }];
>a1 : { x: any; y: string; }[]
>[ {x: 0, y: 'a'}, {x: 'a', y: 'a'}, {x: anyObj, y: 'a'} ] : { x: any; y: string; }[]
>{x: 0, y: 'a'} : { x: number; y: string; }
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[]
>{ x: 0, y: 'a' } : { x: number; y: string; }
>x : number
>y : string
>{x: 'a', y: 'a'} : { x: string; y: string; }
>{ x: 'a', y: 'a' } : { x: string; y: string; }
>x : string
>y : string
>{x: anyObj, y: 'a'} : { x: any; y: string; }
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
>x : any
>anyObj : any
>y : string
var a2 = [ {x: anyObj, y: 'a'}, {x: 0, y: 'a'}, {x: 'a', y: 'a'} ];
var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }];
>a2 : { x: any; y: string; }[]
>[ {x: anyObj, y: 'a'}, {x: 0, y: 'a'}, {x: 'a', y: 'a'} ] : { x: any; y: string; }[]
>{x: anyObj, y: 'a'} : { x: any; y: string; }
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
>x : any
>anyObj : any
>y : string
>{x: 0, y: 'a'} : { x: number; y: string; }
>{ x: 0, y: 'a' } : { x: number; y: string; }
>x : number
>y : string
>{x: 'a', y: 'a'} : { x: string; y: string; }
>{ x: 'a', y: 'a' } : { x: string; y: string; }
>x : string
>y : string
var a3 = [ {x: 0, y: 'a'}, {x: anyObj, y: 'a'}, {x: 'a', y: 'a'} ];
var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }];
>a3 : { x: any; y: string; }[]
>[ {x: 0, y: 'a'}, {x: anyObj, y: 'a'}, {x: 'a', y: 'a'} ] : { x: any; y: string; }[]
>{x: 0, y: 'a'} : { x: number; y: string; }
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
>{ x: 0, y: 'a' } : { x: number; y: string; }
>x : number
>y : string
>{x: anyObj, y: 'a'} : { x: any; y: string; }
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
>x : any
>anyObj : any
>y : string
>{x: 'a', y: 'a'} : { x: string; y: string; }
>{ x: 'a', y: 'a' } : { x: string; y: string; }
>x : string
>y : string
var ifaceObj: iface = null;
var ifaceObj: iface = null;
>ifaceObj : iface
>iface : iface
var baseObj = new base();
var baseObj = new base();
>baseObj : base
>new base() : base
>base : typeof base
var base2Obj = new base2();
var base2Obj = new base2();
>base2Obj : base2
>new base2() : base2
>base2 : typeof base2
var b1 = [ baseObj, base2Obj, ifaceObj ];
>b1 : base[]
>[ baseObj, base2Obj, ifaceObj ] : base[]
var b1 = [baseObj, base2Obj, ifaceObj];
>b1 : iface[]
>[baseObj, base2Obj, ifaceObj] : iface[]
>baseObj : base
>base2Obj : base2
>ifaceObj : iface
var b2 = [ base2Obj, baseObj, ifaceObj ];
>b2 : base2[]
>[ base2Obj, baseObj, ifaceObj ] : base2[]
var b2 = [base2Obj, baseObj, ifaceObj];
>b2 : iface[]
>[base2Obj, baseObj, ifaceObj] : iface[]
>base2Obj : base2
>baseObj : base
>ifaceObj : iface
var b3 = [ baseObj, ifaceObj, base2Obj ];
>b3 : base[]
>[ baseObj, ifaceObj, base2Obj ] : base[]
var b3 = [baseObj, ifaceObj, base2Obj];
>b3 : iface[]
>[baseObj, ifaceObj, base2Obj] : iface[]
>baseObj : base
>ifaceObj : iface
>base2Obj : base2
var b4 = [ ifaceObj, baseObj, base2Obj ];
var b4 = [ifaceObj, baseObj, base2Obj];
>b4 : iface[]
>[ ifaceObj, baseObj, base2Obj ] : iface[]
>[ifaceObj, baseObj, base2Obj] : iface[]
>ifaceObj : iface
>baseObj : base
>base2Obj : base2
}
}
}
module NonEmptyTypes {
>NonEmptyTypes : typeof NonEmptyTypes
interface iface { x: string; }
>iface : iface
>x : string
class base implements iface { x: string; y: string; }
>base : base
>iface : iface
>x : string
>y : string
class base2 implements iface { x: string; z: string; }
>base2 : base2
>iface : iface
>x : string
>z : string
class derived extends base { a: string; }
>derived : derived
>base : base
>a : string
class f {
>f : f
public voidIfAny(x: boolean, y?: boolean): number;
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>x : boolean
>y : boolean
public voidIfAny(x: string, y?: boolean): number;
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>x : string
>y : boolean
public voidIfAny(x: number, y?: boolean): number;
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>x : number
>y : boolean
public voidIfAny(x: any, y = false): any { return null; }
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>x : any
>y : boolean
public x() {
>x : () => void
<number>(this.voidIfAny([4, 2][0]));
><number>(this.voidIfAny([4, 2][0])) : number
>(this.voidIfAny([4, 2][0])) : number
>this.voidIfAny([4, 2][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[4, 2][0] : number
>[4, 2] : number[]
<number>(this.voidIfAny([4, 2, undefined][0]));
><number>(this.voidIfAny([4, 2, undefined][0])) : number
>(this.voidIfAny([4, 2, undefined][0])) : number
>this.voidIfAny([4, 2, undefined][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[4, 2, undefined][0] : number
>[4, 2, undefined] : number[]
>undefined : undefined
<number>(this.voidIfAny([undefined, 2, 4][0]));
><number>(this.voidIfAny([undefined, 2, 4][0])) : number
>(this.voidIfAny([undefined, 2, 4][0])) : number
>this.voidIfAny([undefined, 2, 4][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, 2, 4][0] : number
>[undefined, 2, 4] : number[]
>undefined : undefined
<number>(this.voidIfAny([null, 2, 4][0]));
><number>(this.voidIfAny([null, 2, 4][0])) : number
>(this.voidIfAny([null, 2, 4][0])) : number
>this.voidIfAny([null, 2, 4][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[null, 2, 4][0] : number
>[null, 2, 4] : number[]
<number>(this.voidIfAny([2, 4, null][0]));
><number>(this.voidIfAny([2, 4, null][0])) : number
>(this.voidIfAny([2, 4, null][0])) : number
>this.voidIfAny([2, 4, null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[2, 4, null][0] : number
>[2, 4, null] : number[]
<number>(this.voidIfAny([undefined, 4, null][0]));
><number>(this.voidIfAny([undefined, 4, null][0])) : number
>(this.voidIfAny([undefined, 4, null][0])) : number
>this.voidIfAny([undefined, 4, null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, 4, null][0] : number
>[undefined, 4, null] : number[]
>undefined : undefined
<number>(this.voidIfAny(['', "q"][0]));
><number>(this.voidIfAny(['', "q"][0])) : number
>(this.voidIfAny(['', "q"][0])) : number
>this.voidIfAny(['', "q"][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>['', "q"][0] : string
>['', "q"] : string[]
<number>(this.voidIfAny(['', "q", undefined][0]));
><number>(this.voidIfAny(['', "q", undefined][0])) : number
>(this.voidIfAny(['', "q", undefined][0])) : number
>this.voidIfAny(['', "q", undefined][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>['', "q", undefined][0] : string
>['', "q", undefined] : string[]
>undefined : undefined
<number>(this.voidIfAny([undefined, "q", ''][0]));
><number>(this.voidIfAny([undefined, "q", ''][0])) : number
>(this.voidIfAny([undefined, "q", ''][0])) : number
>this.voidIfAny([undefined, "q", ''][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, "q", ''][0] : string
>[undefined, "q", ''] : string[]
>undefined : undefined
<number>(this.voidIfAny([null, "q", ''][0]));
><number>(this.voidIfAny([null, "q", ''][0])) : number
>(this.voidIfAny([null, "q", ''][0])) : number
>this.voidIfAny([null, "q", ''][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[null, "q", ''][0] : string
>[null, "q", ''] : string[]
<number>(this.voidIfAny(["q", '', null][0]));
><number>(this.voidIfAny(["q", '', null][0])) : number
>(this.voidIfAny(["q", '', null][0])) : number
>this.voidIfAny(["q", '', null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>["q", '', null][0] : string
>["q", '', null] : string[]
<number>(this.voidIfAny([undefined, '', null][0]));
><number>(this.voidIfAny([undefined, '', null][0])) : number
>(this.voidIfAny([undefined, '', null][0])) : number
>this.voidIfAny([undefined, '', null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, '', null][0] : string
>[undefined, '', null] : string[]
>undefined : undefined
<number>(this.voidIfAny([[3, 4], [null]][0][0]));
><number>(this.voidIfAny([[3, 4], [null]][0][0])) : number
>(this.voidIfAny([[3, 4], [null]][0][0])) : number
>this.voidIfAny([[3, 4], [null]][0][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[[3, 4], [null]][0][0] : number
>[[3, 4], [null]][0] : number[]
>[[3, 4], [null]] : number[][]
>[3, 4] : number[]
>[null] : null[]
var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }];
>t1 : { x: number; y: base; }[]
>x : number
>y : base
>base : base
>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: base; }[]
>{ x: 7, y: new derived() } : { x: number; y: derived; }
>x : number
>y : derived
>new derived() : derived
>derived : typeof derived
>{ x: 5, y: new base() } : { x: number; y: base; }
>x : number
>y : base
>new base() : base
>base : typeof base
var t2: { x: boolean; y: base; }[] = [{ x: true, y: new derived() }, { x: false, y: new base() }];
>t2 : { x: boolean; y: base; }[]
>x : boolean
>y : base
>base : base
>[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: base; }[]
>{ x: true, y: new derived() } : { x: boolean; y: derived; }
>x : boolean
>y : derived
>new derived() : derived
>derived : typeof derived
>{ x: false, y: new base() } : { x: boolean; y: base; }
>x : boolean
>y : base
>new base() : base
>base : typeof base
var t3: { x: string; y: base; }[] = [{ x: undefined, y: new base() }, { x: '', y: new derived() }];
>t3 : { x: string; y: base; }[]
>x : string
>y : base
>base : base
>[{ x: undefined, y: new base() }, { x: '', y: new derived() }] : { x: string; y: base; }[]
>{ x: undefined, y: new base() } : { x: undefined; y: base; }
>x : undefined
>undefined : undefined
>y : base
>new base() : base
>base : typeof base
>{ x: '', y: new derived() } : { x: string; y: derived; }
>x : string
>y : derived
>new derived() : derived
>derived : typeof derived
var anyObj: any = null;
>anyObj : any
// Order matters here so test all the variants
var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }];
>a1 : { x: any; y: string; }[]
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[]
>{ x: 0, y: 'a' } : { x: number; y: string; }
>x : number
>y : string
>{ x: 'a', y: 'a' } : { x: string; y: string; }
>x : string
>y : string
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
>x : any
>anyObj : any
>y : string
var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }];
>a2 : { x: any; y: string; }[]
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
>x : any
>anyObj : any
>y : string
>{ x: 0, y: 'a' } : { x: number; y: string; }
>x : number
>y : string
>{ x: 'a', y: 'a' } : { x: string; y: string; }
>x : string
>y : string
var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }];
>a3 : { x: any; y: string; }[]
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
>{ x: 0, y: 'a' } : { x: number; y: string; }
>x : number
>y : string
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
>x : any
>anyObj : any
>y : string
>{ x: 'a', y: 'a' } : { x: string; y: string; }
>x : string
>y : string
var ifaceObj: iface = null;
>ifaceObj : iface
>iface : iface
var baseObj = new base();
>baseObj : base
>new base() : base
>base : typeof base
var base2Obj = new base2();
>base2Obj : base2
>new base2() : base2
>base2 : typeof base2
var b1 = [baseObj, base2Obj, ifaceObj];
>b1 : iface[]
>[baseObj, base2Obj, ifaceObj] : iface[]
>baseObj : base
>base2Obj : base2
>ifaceObj : iface
var b2 = [base2Obj, baseObj, ifaceObj];
>b2 : iface[]
>[base2Obj, baseObj, ifaceObj] : iface[]
>base2Obj : base2
>baseObj : base
>ifaceObj : iface
var b3 = [baseObj, ifaceObj, base2Obj];
>b3 : iface[]
>[baseObj, ifaceObj, base2Obj] : iface[]
>baseObj : base
>ifaceObj : iface
>base2Obj : base2
var b4 = [ifaceObj, baseObj, base2Obj];
>b4 : iface[]
>[ifaceObj, baseObj, base2Obj] : iface[]
>ifaceObj : iface
>baseObj : base
>base2Obj : base2
}
}
}
@@ -1,40 +0,0 @@
tests/cases/compiler/arrayLiteralContextualType.ts(28,5): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'IAnimal[]'.
Type '{}' is not assignable to type 'IAnimal'.
tests/cases/compiler/arrayLiteralContextualType.ts(29,5): error TS2345: Argument of type '{}[]' is not assignable to parameter of type '{ [x: number]: IAnimal; }'.
==== tests/cases/compiler/arrayLiteralContextualType.ts (2 errors) ====
interface IAnimal {
name: string;
}
class Giraffe {
name = "Giraffe";
neckLength = "3m";
}
class Elephant {
name = "Elephant";
trunkDiameter = "20cm";
}
function foo(animals: IAnimal[]) { }
function bar(animals: { [n: number]: IAnimal }) { }
foo([
new Giraffe(),
new Elephant()
]); // Legal because of the contextual type IAnimal provided by the parameter
bar([
new Giraffe(),
new Elephant()
]); // Legal because of the contextual type IAnimal provided by the parameter
var arr = [new Giraffe(), new Elephant()];
foo(arr); // Error because of no contextual type
~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'IAnimal[]'.
!!! error TS2345: Type '{}' is not assignable to type 'IAnimal'.
bar(arr); // Error because of no contextual type
~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type '{ [x: number]: IAnimal; }'.
@@ -26,8 +26,8 @@ bar([
]); // Legal because of the contextual type IAnimal provided by the parameter
var arr = [new Giraffe(), new Elephant()];
foo(arr); // Error because of no contextual type
bar(arr); // Error because of no contextual type
foo(arr); // ok because arr is Array<Giraffe|Elephant> not {}[]
bar(arr); // ok because arr is Array<Giraffe|Elephant> not {}[]
//// [arrayLiteralContextualType.js]
var Giraffe = (function () {
@@ -57,5 +57,5 @@ bar([
new Elephant()
]); // Legal because of the contextual type IAnimal provided by the parameter
var arr = [new Giraffe(), new Elephant()];
foo(arr); // Error because of no contextual type
bar(arr); // Error because of no contextual type
foo(arr); // ok because arr is Array<Giraffe|Elephant> not {}[]
bar(arr); // ok because arr is Array<Giraffe|Elephant> not {}[]
@@ -0,0 +1,86 @@
=== tests/cases/compiler/arrayLiteralContextualType.ts ===
interface IAnimal {
>IAnimal : IAnimal
name: string;
>name : string
}
class Giraffe {
>Giraffe : Giraffe
name = "Giraffe";
>name : string
neckLength = "3m";
>neckLength : string
}
class Elephant {
>Elephant : Elephant
name = "Elephant";
>name : string
trunkDiameter = "20cm";
>trunkDiameter : string
}
function foo(animals: IAnimal[]) { }
>foo : (animals: IAnimal[]) => void
>animals : IAnimal[]
>IAnimal : IAnimal
function bar(animals: { [n: number]: IAnimal }) { }
>bar : (animals: { [x: number]: IAnimal; }) => void
>animals : { [x: number]: IAnimal; }
>n : number
>IAnimal : IAnimal
foo([
>foo([ new Giraffe(), new Elephant()]) : void
>foo : (animals: IAnimal[]) => void
>[ new Giraffe(), new Elephant()] : IAnimal[]
new Giraffe(),
>new Giraffe() : Giraffe
>Giraffe : typeof Giraffe
new Elephant()
>new Elephant() : Elephant
>Elephant : typeof Elephant
]); // Legal because of the contextual type IAnimal provided by the parameter
bar([
>bar([ new Giraffe(), new Elephant()]) : void
>bar : (animals: { [x: number]: IAnimal; }) => void
>[ new Giraffe(), new Elephant()] : IAnimal[]
new Giraffe(),
>new Giraffe() : Giraffe
>Giraffe : typeof Giraffe
new Elephant()
>new Elephant() : Elephant
>Elephant : typeof Elephant
]); // Legal because of the contextual type IAnimal provided by the parameter
var arr = [new Giraffe(), new Elephant()];
>arr : Array<Giraffe | Elephant>
>[new Giraffe(), new Elephant()] : Array<Giraffe | Elephant>
>new Giraffe() : Giraffe
>Giraffe : typeof Giraffe
>new Elephant() : Elephant
>Elephant : typeof Elephant
foo(arr); // ok because arr is Array<Giraffe|Elephant> not {}[]
>foo(arr) : void
>foo : (animals: IAnimal[]) => void
>arr : Array<Giraffe | Elephant>
bar(arr); // ok because arr is Array<Giraffe|Elephant> not {}[]
>bar(arr) : void
>bar : (animals: { [x: number]: IAnimal; }) => void
>arr : Array<Giraffe | Elephant>
@@ -23,8 +23,8 @@ var as = [a, b]; // { x: number; y?: number };[]
>b : { x: number; z?: number; }
var bs = [b, a]; // { x: number; z?: number };[]
>bs : { x: number; z?: number; }[]
>[b, a] : { x: number; z?: number; }[]
>bs : { x: number; y?: number; }[]
>[b, a] : { x: number; y?: number; }[]
>b : { x: number; z?: number; }
>a : { x: number; y?: number; }
@@ -2,28 +2,21 @@
// Empty array literal with no contextual type has type Undefined[]
var arr1= [[], [1], ['']];
var arr1: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK
var arr2 = [[null], [1], ['']];
var arr2: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK
// Array literal with elements of only EveryType E has type E[]
var stringArrArr = [[''], [""]];
var stringArrArr: string[][];
var stringArr = ['', ""];
var stringArr: string[];
var numberArr = [0, 0.0, 0x00, 1e1];
var numberArr: number[];
var boolArr = [false, true, false, true];
var boolArr: boolean[];
class C { private p; }
var classArr = [new C(), new C()];
var classArr: C[]; // Should be OK
var classTypeArray = [C, C, C];
var classTypeArray: Array<typeof C>; // Should OK, not be a parse error
@@ -31,7 +24,6 @@ var classTypeArray: Array<typeof C>; // Should OK, not be a parse error
// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[]
var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
var context2: Array<{}>; // Should be OK
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
class Base { private p; }
@@ -53,31 +45,23 @@ var __extends = this.__extends || function (d, b) {
d.prototype = new __();
};
var arr1 = [[], [1], ['']];
var arr1; // Bug 825172: Error ({}[] does not match {}[]), but should be OK
var arr2 = [[null], [1], ['']];
var arr2; // Bug 825172: Error ({}[] does not match {}[]), but should be OK
// Array literal with elements of only EveryType E has type E[]
var stringArrArr = [[''], [""]];
var stringArrArr;
var stringArr = ['', ""];
var stringArr;
var numberArr = [0, 0.0, 0x00, 1e1];
var numberArr;
var boolArr = [false, true, false, true];
var boolArr;
var C = (function () {
function C() {
}
return C;
})();
var classArr = [new C(), new C()];
var classArr; // Should be OK
var classTypeArray = [C, C, C];
var classTypeArray; // Should OK, not be a parse error
// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[]
var context1 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
var context2; // Should be OK
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
var Base = (function () {
function Base() {
+6 -32
View File
@@ -2,25 +2,19 @@
// Empty array literal with no contextual type has type Undefined[]
var arr1= [[], [1], ['']];
>arr1 : {}[]
>[[], [1], ['']] : {}[]
>arr1 : Array<string[] | number[]>
>[[], [1], ['']] : Array<string[] | number[]>
>[] : undefined[]
>[1] : number[]
>[''] : string[]
var arr1: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK
>arr1 : {}[]
var arr2 = [[null], [1], ['']];
>arr2 : {}[]
>[[null], [1], ['']] : {}[]
>arr2 : Array<string[] | number[]>
>[[null], [1], ['']] : Array<string[] | number[]>
>[null] : null[]
>[1] : number[]
>[''] : string[]
var arr2: {}[]; // Bug 825172: Error ({}[] does not match {}[]), but should be OK
>arr2 : {}[]
// Array literal with elements of only EveryType E has type E[]
var stringArrArr = [[''], [""]];
@@ -29,30 +23,18 @@ var stringArrArr = [[''], [""]];
>[''] : string[]
>[""] : string[]
var stringArrArr: string[][];
>stringArrArr : string[][]
var stringArr = ['', ""];
>stringArr : string[]
>['', ""] : string[]
var stringArr: string[];
>stringArr : string[]
var numberArr = [0, 0.0, 0x00, 1e1];
>numberArr : number[]
>[0, 0.0, 0x00, 1e1] : number[]
var numberArr: number[];
>numberArr : number[]
var boolArr = [false, true, false, true];
>boolArr : boolean[]
>[false, true, false, true] : boolean[]
var boolArr: boolean[];
>boolArr : boolean[]
class C { private p; }
>C : C
>p : any
@@ -65,10 +47,6 @@ var classArr = [new C(), new C()];
>new C() : C
>C : typeof C
var classArr: C[]; // Should be OK
>classArr : C[]
>C : C
var classTypeArray = [C, C, C];
>classTypeArray : typeof C[]
>[C, C, C] : typeof C[]
@@ -98,8 +76,8 @@ var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '
>c : number
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
>context2 : {}[]
>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : {}[]
>context2 : Array<{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }>
>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : Array<{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }>
>{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; }
>a : string
>b : number
@@ -109,10 +87,6 @@ var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
>b : number
>c : number
var context2: Array<{}>; // Should be OK
>context2 : {}[]
>Array : T[]
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
class Base { private p; }
>Base : Base
@@ -61,8 +61,8 @@ var xs = [list, myList]; // {}[]
>myList : MyList<number>
var ys = [list, list2]; // {}[]
>ys : {}[]
>[list, list2] : {}[]
>ys : Array<List<number> | List<string>>
>[list, list2] : Array<List<number> | List<string>>
>list : List<number>
>list2 : List<string>
@@ -54,8 +54,8 @@ var r4 = true ? a : b; // typeof a
>b : { x: number; z?: number; }
var r5 = true ? b : a; // typeof b
>r5 : { x: number; z?: number; }
>true ? b : a : { x: number; z?: number; }
>r5 : { x: number; y?: number; }
>true ? b : a : { x: number; y?: number; }
>b : { x: number; z?: number; }
>a : { x: number; y?: number; }
@@ -1,14 +1,9 @@
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(11,10): error TS2367: No best common type exists between 'number' and 'string'.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(12,10): error TS2367: No best common type exists between 'Derived' and 'Derived2'.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(15,12): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(18,15): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(19,12): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(22,15): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(22,28): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(23,12): error TS2367: No best common type exists between 'T' and 'U'.
==== tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts (8 errors) ====
==== tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts (3 errors) ====
// conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist)
// these are errors
@@ -20,24 +15,16 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfC
var derived2: Derived2;
var r2 = true ? 1 : '';
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'number' and 'string'.
var r9 = true ? derived : derived2;
~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Derived' and 'Derived2'.
function foo<T, U>(t: T, u: U) {
return true ? t : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
}
function foo2<T extends U, U>(t: T, u: U) { // Error for referencing own type parameter
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
return true ? t : u; // Ok because BCT(T, U) = U
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
}
function foo3<T extends U, U extends V, V>(t: T, u: U) {
@@ -46,6 +33,4 @@ tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfC
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
return true ? t : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
}
@@ -1,10 +1,9 @@
tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2323: Type '{}' is not assignable to type 'boolean'.
tests/cases/compiler/conditionalExpression1.ts(1,19): error TS2367: No best common type exists between 'number' and 'string'.
tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2322: Type 'string | number' is not assignable to type 'boolean':
Type 'string' is not assignable to type 'boolean'.
==== tests/cases/compiler/conditionalExpression1.ts (2 errors) ====
==== tests/cases/compiler/conditionalExpression1.ts (1 errors) ====
var x: boolean = (true ? 1 : ""); // should be an error
~
!!! error TS2323: Type '{}' is not assignable to type 'boolean'.
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'number' and 'string'.
!!! error TS2322: Type 'string | number' is not assignable to type 'boolean':
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
@@ -1,20 +1,21 @@
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(12,1): error TS2367: No best common type exists between 'A' and 'B'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(13,15): error TS2367: No best common type exists between 'A' and 'B'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,5): error TS2322: Type '{}' is not assignable to type 'A':
Property 'propertyA' is missing in type '{}'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,18): error TS2366: No best common type exists between 'A', 'A', and 'B'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(17,5): error TS2322: Type '{}' is not assignable to type 'B':
Property 'propertyB' is missing in type '{}'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(17,18): error TS2366: No best common type exists between 'B', 'A', and 'B'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,5): error TS2323: Type '{}' is not assignable to type '(t: X) => number'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,33): error TS2366: No best common type exists between '(t: X) => number', '(m: X) => number', and '(n: X) => string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,5): error TS2323: Type '{}' is not assignable to type '(t: X) => string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,33): error TS2366: No best common type exists between '(t: X) => string', '(m: X) => number', and '(n: X) => string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(21,5): error TS2323: Type '{}' is not assignable to type '(t: X) => boolean'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(21,34): error TS2366: No best common type exists between '(t: X) => boolean', '(m: X) => number', and '(n: X) => string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(15,5): error TS2322: Type 'A | B' is not assignable to type 'A':
Type 'B' is not assignable to type 'A':
Property 'propertyA' is missing in type 'B'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(16,5): error TS2322: Type 'A | B' is not assignable to type 'B':
Type 'A' is not assignable to type 'B':
Property 'propertyB' is missing in type 'A'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(18,5): error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => number':
Type '(n: X) => string' is not assignable to type '(t: X) => number':
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(19,5): error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => string':
Type '(m: X) => number' is not assignable to type '(t: X) => string':
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts(20,5): error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => boolean':
Type '(m: X) => number' is not assignable to type '(t: X) => boolean':
Type 'number' is not assignable to type 'boolean'.
==== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts (12 errors) ====
==== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithoutIdenticalBCT.ts (5 errors) ====
//Cond ? Expr1 : Expr2, Expr1 and Expr2 have no identical best common type
class X { propertyX: any; propertyX1: number; propertyX2: string };
class A extends X { propertyA: number };
@@ -24,41 +25,34 @@ tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithou
var a: A;
var b: B;
//Expect to have compiler errors
//Be not contextually typed
// No errors anymore, uses union types
true ? a : b;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'A' and 'B'.
var result1 = true ? a : b;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'A' and 'B'.
//Be contextually typed and and bct is not identical
//Be contextually typed and and bct is not identical, results in errors that union type is not assignable to target
var result2: A = true ? a : b;
~~~~~~~
!!! error TS2322: Type '{}' is not assignable to type 'A':
!!! error TS2322: Property 'propertyA' is missing in type '{}'.
~~~~~~~~~~~~
!!! error TS2366: No best common type exists between 'A', 'A', and 'B'.
!!! error TS2322: Type 'A | B' is not assignable to type 'A':
!!! error TS2322: Type 'B' is not assignable to type 'A':
!!! error TS2322: Property 'propertyA' is missing in type 'B'.
var result3: B = true ? a : b;
~~~~~~~
!!! error TS2322: Type '{}' is not assignable to type 'B':
!!! error TS2322: Property 'propertyB' is missing in type '{}'.
~~~~~~~~~~~~
!!! error TS2366: No best common type exists between 'B', 'A', and 'B'.
!!! error TS2322: Type 'A | B' is not assignable to type 'B':
!!! error TS2322: Type 'A' is not assignable to type 'B':
!!! error TS2322: Property 'propertyB' is missing in type 'A'.
var result4: (t: X) => number = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
~~~~~~~
!!! error TS2323: Type '{}' is not assignable to type '(t: X) => number'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2366: No best common type exists between '(t: X) => number', '(m: X) => number', and '(n: X) => string'.
!!! error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => number':
!!! error TS2322: Type '(n: X) => string' is not assignable to type '(t: X) => number':
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var result5: (t: X) => string = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
~~~~~~~
!!! error TS2323: Type '{}' is not assignable to type '(t: X) => string'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2366: No best common type exists between '(t: X) => string', '(m: X) => number', and '(n: X) => string'.
!!! error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => string':
!!! error TS2322: Type '(m: X) => number' is not assignable to type '(t: X) => string':
!!! error TS2322: Type 'number' is not assignable to type 'string'.
var result6: (t: X) => boolean = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
~~~~~~~
!!! error TS2323: Type '{}' is not assignable to type '(t: X) => boolean'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2366: No best common type exists between '(t: X) => boolean', '(m: X) => number', and '(n: X) => string'.
!!! error TS2322: Type '{ (m: X): number; } | { (n: X): string; }' is not assignable to type '(t: X) => boolean':
!!! error TS2322: Type '(m: X) => number' is not assignable to type '(t: X) => boolean':
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
@@ -8,12 +8,11 @@ var x: X;
var a: A;
var b: B;
//Expect to have compiler errors
//Be not contextually typed
// No errors anymore, uses union types
true ? a : b;
var result1 = true ? a : b;
//Be contextually typed and and bct is not identical
//Be contextually typed and and bct is not identical, results in errors that union type is not assignable to target
var result2: A = true ? a : b;
var result3: B = true ? a : b;
@@ -54,11 +53,10 @@ var B = (function (_super) {
var x;
var a;
var b;
//Expect to have compiler errors
//Be not contextually typed
// No errors anymore, uses union types
true ? a : b;
var result1 = true ? a : b;
//Be contextually typed and and bct is not identical
//Be contextually typed and and bct is not identical, results in errors that union type is not assignable to target
var result2 = true ? a : b;
var result3 = true ? a : b;
var result4 = true ? function (m) { return m.propertyX1; } : function (n) { return n.propertyX2; };
@@ -1,11 +1,13 @@
tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '{}[]' is not assignable to type '{ id: number; }[]':
Type '{}' is not assignable to type '{ id: number; }':
Property 'id' is missing in type '{}'.
tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type 'Array<number | { id: number; }>' is not assignable to type '{ id: number; }[]':
Type 'number | { id: number; }' is not assignable to type '{ id: number; }':
Type 'number' is not assignable to type '{ id: number; }':
Property 'id' is missing in type 'Number'.
==== tests/cases/compiler/contextualTyping21.ts (1 errors) ====
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, 1];
~~~
!!! error TS2322: Type '{}[]' is not assignable to type '{ id: number; }[]':
!!! error TS2322: Type '{}' is not assignable to type '{ id: number; }':
!!! error TS2322: Property 'id' is missing in type '{}'.
!!! error TS2322: Type 'Array<number | { id: number; }>' is not assignable to type '{ id: number; }[]':
!!! error TS2322: Type 'number | { id: number; }' is not assignable to type '{ id: number; }':
!!! error TS2322: Type 'number' is not assignable to type '{ id: number; }':
!!! error TS2322: Property 'id' is missing in type 'Number'.
@@ -1,9 +1,11 @@
tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
Type '{}' is not assignable to type 'number'.
tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
Type 'string | number' is not assignable to type 'number':
Type 'string' is not assignable to type 'number'.
==== tests/cases/compiler/contextualTyping30.ts (1 errors) ====
function foo(param:number[]){}; foo([1, "a"]);
~~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type '{}' is not assignable to type 'number'.
!!! error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type 'string | number' is not assignable to type 'number':
!!! error TS2345: Type 'string' is not assignable to type 'number'.
@@ -1,9 +1,11 @@
tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type '{}[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
Type '{}' is not assignable to type '{ (): number; (i: number): number; }'.
tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type 'Array<{ (): number; } | { (): string; }>' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
Type '{ (): number; } | { (): string; }' is not assignable to type '{ (): number; (i: number): number; }':
Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'.
==== tests/cases/compiler/contextualTyping33.ts (1 errors) ====
function foo(param: {():number; (i:number):number; }[]) { }; foo([function(){return 1;}, function(){return "foo"}]);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
!!! error TS2345: Type '{}' is not assignable to type '{ (): number; (i: number): number; }'.
!!! error TS2345: Argument of type 'Array<{ (): number; } | { (): string; }>' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
!!! error TS2345: Type '{ (): number; } | { (): string; }' is not assignable to type '{ (): number; (i: number): number; }':
!!! error TS2345: Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'.
@@ -1,7 +1,8 @@
tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type '{}[]' is not assignable to type 'I':
tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type 'Array<number | Date>' is not assignable to type 'I':
Index signatures are incompatible:
Type '{}' is not assignable to type 'Date':
Property 'toDateString' is missing in type '{}'.
Type 'number | Date' is not assignable to type 'Date':
Type 'number' is not assignable to type 'Date':
Property 'toDateString' is missing in type 'Number'.
==== tests/cases/compiler/contextualTypingOfArrayLiterals1.ts (1 errors) ====
@@ -11,10 +12,11 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ
var x3: I = [new Date(), 1];
~~
!!! error TS2322: Type '{}[]' is not assignable to type 'I':
!!! error TS2322: Type 'Array<number | Date>' is not assignable to type 'I':
!!! error TS2322: Index signatures are incompatible:
!!! error TS2322: Type '{}' is not assignable to type 'Date':
!!! error TS2322: Property 'toDateString' is missing in type '{}'.
!!! error TS2322: Type 'number | Date' is not assignable to type 'Date':
!!! error TS2322: Type 'number' is not assignable to type 'Date':
!!! error TS2322: Property 'toDateString' is missing in type 'Number'.
var r2 = x3[1];
r2.getDate();
@@ -1,8 +1,11 @@
tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS2323: Type '{}' is not assignable to type '(a: A) => void'.
tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,26): error TS2366: No best common type exists between '(a: A) => void', '(a: C) => number', and '(b: number) => void'.
tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS2322: Type '{ (a: C): number; } | { (b: number): void; }' is not assignable to type '(a: A) => void':
Type '(b: number) => void' is not assignable to type '(a: A) => void':
Types of parameters 'b' and 'a' are incompatible:
Type 'number' is not assignable to type 'A':
Property 'foo' is missing in type 'Number'.
==== tests/cases/compiler/contextualTypingOfConditionalExpression2.ts (2 errors) ====
==== tests/cases/compiler/contextualTypingOfConditionalExpression2.ts (1 errors) ====
class A {
foo: number;
}
@@ -15,7 +18,9 @@ tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,26): error T
var x2: (a: A) => void = true ? (a: C) => a.foo : (b: number) => { };
~~
!!! error TS2323: Type '{}' is not assignable to type '(a: A) => void'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2366: No best common type exists between '(a: A) => void', '(a: C) => number', and '(b: number) => void'.
!!! error TS2322: Type '{ (a: C): number; } | { (b: number): void; }' is not assignable to type '(a: A) => void':
!!! error TS2322: Type '(b: number) => void' is not assignable to type '(a: A) => void':
!!! error TS2322: Types of parameters 'b' and 'a' are incompatible:
!!! error TS2322: Type 'number' is not assignable to type 'A':
!!! error TS2322: Property 'foo' is missing in type 'Number'.
@@ -1,9 +1,12 @@
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(2,22): error TS2339: Property 'foo' does not exist on type 'string'.
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,10): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (1 errors) ====
==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (2 errors) ====
var f10: <T>(x: T, b: () => (a: T) => void, y: T) => T;
f10('', () => a => a.foo, ''); // a is string, fixed by first parameter
f10('', () => a => a.foo, ''); // a is string
~~~
!!! error TS2339: Property 'foo' does not exist on type 'string'.
var r9 = f10('', () => (a => a.foo), 1); // now a should be any
var r9 = f10('', () => (a => a.foo), 1); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
@@ -1,9 +1,9 @@
//// [contextualTypingWithFixedTypeParameters1.ts]
var f10: <T>(x: T, b: () => (a: T) => void, y: T) => T;
f10('', () => a => a.foo, ''); // a is string, fixed by first parameter
var r9 = f10('', () => (a => a.foo), 1); // now a should be any
f10('', () => a => a.foo, ''); // a is string
var r9 = f10('', () => (a => a.foo), 1); // error
//// [contextualTypingWithFixedTypeParameters1.js]
var f10;
f10('', function () { return function (a) { return a.foo; }; }, ''); // a is string, fixed by first parameter
var r9 = f10('', function () { return (function (a) { return a.foo; }); }, 1); // now a should be any
f10('', function () { return function (a) { return a.foo; }; }, ''); // a is string
var r9 = f10('', function () { return (function (a) { return a.foo; }); }, 1); // error
@@ -17,10 +17,10 @@ var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 };
>s : string
var v2 = (s: string) => s.length || function (s) { s.length };
>v2 : (s: string) => {}
>(s: string) => s.length || function (s) { s.length } : (s: string) => {}
>v2 : (s: string) => number | { (s: any): void; }
>(s: string) => s.length || function (s) { s.length } : (s: string) => number | { (s: any): void; }
>s : string
>s.length || function (s) { s.length } : {}
>s.length || function (s) { s.length } : number | { (s: any): void; }
>s.length : number
>s : string
>length : number
@@ -31,10 +31,10 @@ var v2 = (s: string) => s.length || function (s) { s.length };
>length : any
var v3 = (s: string) => s.length || function (s: number) { return 1 };
>v3 : (s: string) => {}
>(s: string) => s.length || function (s: number) { return 1 } : (s: string) => {}
>v3 : (s: string) => number | { (s: number): number; }
>(s: string) => s.length || function (s: number) { return 1 } : (s: string) => number | { (s: number): number; }
>s : string
>s.length || function (s: number) { return 1 } : {}
>s.length || function (s: number) { return 1 } : number | { (s: number): number; }
>s.length : number
>s : string
>length : number
@@ -42,10 +42,10 @@ var v3 = (s: string) => s.length || function (s: number) { return 1 };
>s : number
var v4 = (s: number) => 1 || function (s: string) { return s.length };
>v4 : (s: number) => {}
>(s: number) => 1 || function (s: string) { return s.length } : (s: number) => {}
>v4 : (s: number) => number | { (s: string): number; }
>(s: number) => 1 || function (s: string) { return s.length } : (s: number) => number | { (s: string): number; }
>s : number
>1 || function (s: string) { return s.length } : {}
>1 || function (s: string) { return s.length } : number | { (s: string): number; }
>function (s: string) { return s.length } : (s: string) => number
>s : string
>s.length : number
@@ -17,10 +17,10 @@ var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 };
>s : string
var v2 = (s: string) => s.length || function (s) { s.aaa };
>v2 : (s: string) => {}
>(s: string) => s.length || function (s) { s.aaa } : (s: string) => {}
>v2 : (s: string) => number | { (s: any): void; }
>(s: string) => s.length || function (s) { s.aaa } : (s: string) => number | { (s: any): void; }
>s : string
>s.length || function (s) { s.aaa } : {}
>s.length || function (s) { s.aaa } : number | { (s: any): void; }
>s.length : number
>s : string
>length : number
@@ -1,31 +1,27 @@
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(4,6): error TS2339: Property 'length' does not exist on type '{}'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(10,6): error TS2339: Property 'length' does not exist on type 'Object'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(18,27): error TS2339: Property 'length' does not exist on type '{}'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(2,6): error TS2339: Property 'length' does not exist on type '{}'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(5,6): error TS2339: Property 'length' does not exist on type 'Object'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(8,14): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts (3 errors) ====
var obj1: {};
obj1.length;
~~~~~~
!!! error TS2339: Property 'length' does not exist on type '{}'.
var obj2: Object;
obj2.length;
~~~~~~
!!! error TS2339: Property 'length' does not exist on type 'Object'.
function concat<T>(x: T, y: T): T { return null; }
var result = concat(1, ""); // error
~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var elementCount = result.length;
var result = concat(1, "");
function concat2<T, U>(x: T, y: U) { return null; }
var result2 = concat2(1, ""); // result2 will be number|string
var elementCount2 = result.length;
var elementCount = result.length; // would like to get an error by now
~~~~~~
!!! error TS2339: Property 'length' does not exist on type '{}'.
@@ -1,22 +1,18 @@
//// [defaultBestCommonTypesHaveDecls.ts]
var obj1: {};
obj1.length;
var obj2: Object;
obj2.length;
function concat<T>(x: T, y: T): T { return null; }
var result = concat(1, ""); // error
var elementCount = result.length;
var result = concat(1, "");
function concat2<T, U>(x: T, y: U) { return null; }
var result2 = concat2(1, ""); // result2 will be number|string
var elementCount2 = result.length;
var elementCount = result.length; // would like to get an error by now
//// [defaultBestCommonTypesHaveDecls.js]
@@ -27,5 +23,10 @@ obj2.length;
function concat(x, y) {
return null;
}
var result = concat(1, "");
var elementCount = result.length; // would like to get an error by now
var result = concat(1, ""); // error
var elementCount = result.length;
function concat2(x, y) {
return null;
}
var result2 = concat2(1, ""); // result2 will be number|string
var elementCount2 = result.length;
+4 -4
View File
@@ -157,8 +157,8 @@ enum E9 {
// (refer to .js to validate)
// Enum constant members are propagated
var doNotPropagate = [
>doNotPropagate : {}[]
>[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : {}[]
>doNotPropagate : Array<E3 | E4 | E7 | E8>
>[ E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z] : Array<E3 | E4 | E7 | E8>
E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z
>E8.B : E8
@@ -183,8 +183,8 @@ var doNotPropagate = [
];
// Enum computed members are not propagated
var doPropagate = [
>doPropagate : {}[]
>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : {}[]
>doPropagate : Array<E5 | E6 | E9>
>[ E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C] : Array<E5 | E6 | E9>
E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C
>E9.A : E9
@@ -0,0 +1,8 @@
tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts(2,1): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts (1 errors) ====
function bar<T>(item1: T, item2: T) { }
bar(1, ""); // Should be ok
~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
@@ -1,13 +0,0 @@
=== tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts ===
function bar<T>(item1: T, item2: T) { }
>bar : <T>(item1: T, item2: T) => void
>T : T
>item1 : T
>T : T
>item2 : T
>T : T
bar(1, ""); // Should be ok
>bar(1, "") : void
>bar : <T>(item1: T, item2: T) => void
@@ -7,7 +7,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(40,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(43,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(46,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '{}[]'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array<C | D<string>>'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(50,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D<string>[]', but here has type 'D<number>[]'.
tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(53,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'.
@@ -79,7 +79,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'.
for( var arr = [new C(), new C2(), new D<string>()];;){}
~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '{}[]'.
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array<C | D<string>>'.
for(var arr2 = [new D<string>()];;){}
for( var arr2 = new Array<D<number>>();;){}
@@ -127,11 +127,11 @@ var x12: Genric<Base> = { func: n => { return [d1, d2]; } };
>x12 : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -243,11 +243,11 @@ class x24 { member: Genric<Base> = { func: n => { return [d1, d2]; } } }
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -359,11 +359,11 @@ class x36 { private member: Genric<Base> = { func: n => { return [d1, d2]; } } }
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -475,11 +475,11 @@ class x48 { public member: Genric<Base> = { func: n => { return [d1, d2]; } } }
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -591,11 +591,11 @@ class x60 { static member: Genric<Base> = { func: n => { return [d1, d2]; } } }
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -707,11 +707,11 @@ class x72 { private static member: Genric<Base> = { func: n => { return [d1, d2]
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -823,11 +823,11 @@ class x84 { public static member: Genric<Base> = { func: n => { return [d1, d2];
>member : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -939,11 +939,11 @@ class x96 { constructor(parm: Genric<Base> = { func: n => { return [d1, d2]; } }
>parm : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -1055,11 +1055,11 @@ class x108 { constructor(public parm: Genric<Base> = { func: n => { return [d1,
>parm : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -1171,11 +1171,11 @@ class x120 { constructor(private parm: Genric<Base> = { func: n => { return [d1,
>parm : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -1287,11 +1287,11 @@ function x132(parm: Genric<Base> = { func: n => { return [d1, d2]; } }) { }
>parm : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -1391,11 +1391,11 @@ function x144(): Genric<Base> { return { func: n => { return [d1, d2]; } }; }
>x144 : () => Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -1539,18 +1539,18 @@ function x156(): Genric<Base> { return { func: n => { return [d1, d2]; } }; retu
>x156 : () => Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -1661,12 +1661,12 @@ var x168: () => Genric<Base> = () => { return { func: n => { return [d1, d2]; }
>x168 : () => Genric<Base>
>Genric : Genric<T>
>Base : Base
>() => { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => {}[]; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>() => { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -1777,12 +1777,12 @@ var x180: () => Genric<Base> = function() { return { func: n => { return [d1, d2
>x180 : () => Genric<Base>
>Genric : Genric<T>
>Base : Base
>function() { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => {}[]; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>function() { return { func: n => { return [d1, d2]; } }; } : () => { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -1894,11 +1894,11 @@ module x192 { var t: Genric<Base> = { func: n => { return [d1, d2]; } }; }
>t : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -2010,11 +2010,11 @@ module x204 { export var t: Genric<Base> = { func: n => { return [d1, d2]; } };
>t : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -2098,11 +2098,11 @@ var x216 = <Genric<Base>>{ func: n => { return [d1, d2]; } };
><Genric<Base>>{ func: n => { return [d1, d2]; } } : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -2323,13 +2323,13 @@ var x236: Genric<Base>; x236 = { func: n => { return [d1, d2]; } };
>x236 : Genric<Base>
>Genric : Genric<T>
>Base : Base
>x236 = { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>x236 = { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>x236 : Genric<Base>
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -2463,13 +2463,13 @@ var x248: { n: Genric<Base>; } = { n: { func: n => { return [d1, d2]; } } };
>n : Genric<Base>
>Genric : Genric<T>
>Base : Base
>{ n: { func: n => { return [d1, d2]; } } } : { n: { func: (n: Base[]) => {}[]; }; }
>n : { func: (n: Base[]) => {}[]; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ n: { func: n => { return [d1, d2]; } } } : { n: { func: (n: Base[]) => Array<Derived1 | Derived2>; }; }
>n : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -2543,11 +2543,11 @@ var x260: Genric<Base>[] = [{ func: n => { return [d1, d2]; } }];
>Genric : Genric<T>
>Base : Base
>[{ func: n => { return [d1, d2]; } }] : Genric<Base>[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -2976,18 +2976,18 @@ var x296: Genric<Base> = true ? { func: n => { return [d1, d2]; } } : { func: n
>Genric : Genric<T>
>Base : Base
>true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } } : Genric<Base>
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -3111,11 +3111,11 @@ var x308: Genric<Base> = true ? undefined : { func: n => { return [d1, d2]; } };
>Base : Base
>true ? undefined : { func: n => { return [d1, d2]; } } : Genric<Base>
>undefined : undefined
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -3238,11 +3238,11 @@ var x320: Genric<Base> = true ? { func: n => { return [d1, d2]; } } : undefined;
>Genric : Genric<T>
>Base : Base
>true ? { func: n => { return [d1, d2]; } } : undefined : Genric<Base>
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
>undefined : undefined
@@ -3379,11 +3379,11 @@ function x332(n: Genric<Base>) { }; x332({ func: n => { return [d1, d2]; } });
>Base : Base
>x332({ func: n => { return [d1, d2]; } }) : void
>x332 : (n: Genric<Base>) => void
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -3543,11 +3543,11 @@ var x344 = (n: Genric<Base>) => n; x344({ func: n => { return [d1, d2]; } });
>n : Genric<Base>
>x344({ func: n => { return [d1, d2]; } }) : Genric<Base>
>x344 : (n: Genric<Base>) => Genric<Base>
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -3695,11 +3695,11 @@ var x356 = function(n: Genric<Base>) { }; x356({ func: n => { return [d1, d2]; }
>Base : Base
>x356({ func: n => { return [d1, d2]; } }) : void
>x356 : (n: Genric<Base>) => void
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => {}[]; }
>func : (n: Base[]) => {}[]
>n => { return [d1, d2]; } : (n: Base[]) => {}[]
>{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => Array<Derived1 | Derived2>; }
>func : (n: Base[]) => Array<Derived1 | Derived2>
>n => { return [d1, d2]; } : (n: Base[]) => Array<Derived1 | Derived2>
>n : Base[]
>[d1, d2] : {}[]
>[d1, d2] : Array<Derived1 | Derived2>
>d1 : Derived1
>d2 : Derived2
@@ -49,7 +49,7 @@ _.all([true, 1, null, 'yes'], _.identity);
>_.all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => boolean
>_ : Underscore.Static
>all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => boolean
>[true, 1, null, 'yes'] : {}[]
>[true, 1, null, 'yes'] : Array<string | number | boolean>
>_.identity : <T>(value: T) => T
>_ : Underscore.Static
>identity : <T>(value: T) => T
@@ -40,10 +40,10 @@ var r3 = foo<number[]>([]); // number[]
>[] : number[]
var r4 = foo([1, '']); // {}[]
>r4 : {}[]
>foo([1, '']) : {}[]
>r4 : Array<string | number>
>foo([1, '']) : Array<string | number>
>foo : <T>(t: T) => T
>[1, ''] : {}[]
>[1, ''] : Array<string | number>
var r5 = foo<any[]>([1, '']); // any[]
>r5 : any[]
@@ -0,0 +1,58 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(26,18): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(30,15): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(33,15): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(34,16): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(35,23): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts (5 errors) ====
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using function arguments, no errors expected
function foo<T>(x: (a: T) => T) {
return x(null);
}
var r = foo(<U>(x: U) => ''); // {}
var r2 = foo<string>(<U>(x: U) => ''); // string
var r3 = foo(x => ''); // {}
function foo2<T, U>(x: T, cb: (a: T) => U) {
return cb(x);
}
var r4 = foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
var r5 = foo2(1, (a) => ''); // string
var r6 = foo2<string, number>('', <Z>(a: Z) => 1);
function foo3<T, U>(x: T, cb: (a: T) => U, y: U) {
return cb(x);
}
var r7 = foo3(1, <Z>(a: Z) => '', ''); // string
var r8 = foo3(1, function (a) { return '' }, 1); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var r9 = foo3<number, string>(1, (a) => '', ''); // string
function other<T, U>(t: T, u: U) {
var r10 = foo2(1, (x: T) => ''); // error
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r10 = foo2(1, (x) => ''); // string
var r11 = foo3(1, (x: T) => '', ''); // error
~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r11b = foo3(1, (x: T) => '', 1); // error
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r12 = foo3(1, function (a) { return '' }, 1); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
}
@@ -24,16 +24,16 @@ function foo3<T, U>(x: T, cb: (a: T) => U, y: U) {
var r7 = foo3(1, <Z>(a: Z) => '', ''); // string
var r8 = foo3(1, function (a) { return '' }, 1); // {}
var r8 = foo3(1, function (a) { return '' }, 1); // error
var r9 = foo3<number, string>(1, (a) => '', ''); // string
function other<T, U>(t: T, u: U) {
var r10 = foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made
var r10 = foo2(1, (x: T) => ''); // error
var r10 = foo2(1, (x) => ''); // string
var r11 = foo3(1, (x: T) => '', ''); // string
var r11b = foo3(1, (x: T) => '', 1); // {}
var r12 = foo3(1, function (a) { return '' }, 1); // {}
var r11 = foo3(1, (x: T) => '', ''); // error
var r11b = foo3(1, (x: T) => '', 1); // error
var r12 = foo3(1, function (a) { return '' }, 1); // error
}
//// [genericCallWithFunctionTypedArguments.js]
@@ -59,14 +59,14 @@ function foo3(x, cb, y) {
var r7 = foo3(1, function (a) { return ''; }, ''); // string
var r8 = foo3(1, function (a) {
return '';
}, 1); // {}
}, 1); // error
var r9 = foo3(1, function (a) { return ''; }, ''); // string
function other(t, u) {
var r10 = foo2(1, function (x) { return ''; }); // string, non-generic signature allows inferences to be made
var r10 = foo2(1, function (x) { return ''; }); // error
var r10 = foo2(1, function (x) { return ''; }); // string
var r11 = foo3(1, function (x) { return ''; }, ''); // string
var r11b = foo3(1, function (x) { return ''; }, 1); // {}
var r11 = foo3(1, function (x) { return ''; }, ''); // error
var r11b = foo3(1, function (x) { return ''; }, 1); // error
var r12 = foo3(1, function (a) {
return '';
}, 1); // {}
}, 1); // error
}
@@ -1,173 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts ===
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using function arguments, no errors expected
function foo<T>(x: (a: T) => T) {
>foo : <T>(x: (a: T) => T) => T
>T : T
>x : (a: T) => T
>a : T
>T : T
>T : T
return x(null);
>x(null) : T
>x : (a: T) => T
}
var r = foo(<U>(x: U) => ''); // {}
>r : {}
>foo(<U>(x: U) => '') : {}
>foo : <T>(x: (a: T) => T) => T
><U>(x: U) => '' : <U>(x: U) => string
>U : U
>x : U
>U : U
var r2 = foo<string>(<U>(x: U) => ''); // string
>r2 : string
>foo<string>(<U>(x: U) => '') : string
>foo : <T>(x: (a: T) => T) => T
><U>(x: U) => '' : <U>(x: U) => string
>U : U
>x : U
>U : U
var r3 = foo(x => ''); // {}
>r3 : {}
>foo(x => '') : {}
>foo : <T>(x: (a: T) => T) => T
>x => '' : (x: {}) => string
>x : {}
function foo2<T, U>(x: T, cb: (a: T) => U) {
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>T : T
>U : U
>x : T
>T : T
>cb : (a: T) => U
>a : T
>T : T
>U : U
return cb(x);
>cb(x) : U
>cb : (a: T) => U
>x : T
}
var r4 = foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
>r4 : string
>foo2(1, function <Z>(a: Z) { return '' }) : string
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>function <Z>(a: Z) { return '' } : <Z>(a: Z) => string
>Z : Z
>a : Z
>Z : Z
var r5 = foo2(1, (a) => ''); // string
>r5 : string
>foo2(1, (a) => '') : string
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(a) => '' : (a: number) => string
>a : number
var r6 = foo2<string, number>('', <Z>(a: Z) => 1);
>r6 : number
>foo2<string, number>('', <Z>(a: Z) => 1) : number
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
><Z>(a: Z) => 1 : <Z>(a: Z) => number
>Z : Z
>a : Z
>Z : Z
function foo3<T, U>(x: T, cb: (a: T) => U, y: U) {
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>T : T
>U : U
>x : T
>T : T
>cb : (a: T) => U
>a : T
>T : T
>U : U
>y : U
>U : U
return cb(x);
>cb(x) : U
>cb : (a: T) => U
>x : T
}
var r7 = foo3(1, <Z>(a: Z) => '', ''); // string
>r7 : string
>foo3(1, <Z>(a: Z) => '', '') : string
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
><Z>(a: Z) => '' : <Z>(a: Z) => string
>Z : Z
>a : Z
>Z : Z
var r8 = foo3(1, function (a) { return '' }, 1); // {}
>r8 : {}
>foo3(1, function (a) { return '' }, 1) : {}
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>function (a) { return '' } : (a: number) => string
>a : number
var r9 = foo3<number, string>(1, (a) => '', ''); // string
>r9 : string
>foo3<number, string>(1, (a) => '', '') : string
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>(a) => '' : (a: number) => string
>a : number
function other<T, U>(t: T, u: U) {
>other : <T, U>(t: T, u: U) => void
>T : T
>U : U
>t : T
>T : T
>u : U
>U : U
var r10 = foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made
>r10 : string
>foo2(1, (x: T) => '') : string
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r10 = foo2(1, (x) => ''); // string
>r10 : string
>foo2(1, (x) => '') : string
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(x) => '' : (x: number) => string
>x : number
var r11 = foo3(1, (x: T) => '', ''); // string
>r11 : string
>foo3(1, (x: T) => '', '') : string
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r11b = foo3(1, (x: T) => '', 1); // {}
>r11b : {}
>foo3(1, (x: T) => '', 1) : {}
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r12 = foo3(1, function (a) { return '' }, 1); // {}
>r12 : {}
>foo3(1, function (a) { return '' }, 1) : {}
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>function (a) { return '' } : (a: number) => string
>a : number
}
@@ -0,0 +1,50 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(29,10): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(40,10): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts (2 errors) ====
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using construct signature arguments, no errors expected
function foo<T>(x: new(a: T) => T) {
return new x(null);
}
interface I {
new <T>(x: T): T;
}
interface I2<T> {
new (x: T): T;
}
var i: I;
var i2: I2<string>;
var a: {
new <T>(x: T): T;
}
var r = foo(i); // any
var r2 = foo<string>(i); // string
var r3 = foo(i2); // string
var r3b = foo(a); // any
function foo2<T, U>(x: T, cb: new(a: T) => U) {
return new cb(x);
}
var r4 = foo2(1, i2); // error
~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r4b = foo2(1, a); // any
var r5 = foo2(1, i); // any
var r6 = foo2<string, string>('', i2); // string
function foo3<T, U>(x: T, cb: new(a: T) => U, y: U) {
return new cb(x);
}
var r7 = foo3(null, i, ''); // any
var r7b = foo3(null, a, ''); // any
var r8 = foo3(1, i2, 1); // error
~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r9 = foo3<string, string>('', i2, ''); // string
@@ -27,7 +27,7 @@ function foo2<T, U>(x: T, cb: new(a: T) => U) {
return new cb(x);
}
var r4 = foo2(1, i2); // string, instantiated generic
var r4 = foo2(1, i2); // error
var r4b = foo2(1, a); // any
var r5 = foo2(1, i); // any
var r6 = foo2<string, string>('', i2); // string
@@ -38,7 +38,7 @@ function foo3<T, U>(x: T, cb: new(a: T) => U, y: U) {
var r7 = foo3(null, i, ''); // any
var r7b = foo3(null, a, ''); // any
var r8 = foo3(1, i2, 1); // {}
var r8 = foo3(1, i2, 1); // error
var r9 = foo3<string, string>('', i2, ''); // string
//// [genericCallWithFunctionTypedArguments2.js]
@@ -57,7 +57,7 @@ var r3b = foo(a); // any
function foo2(x, cb) {
return new cb(x);
}
var r4 = foo2(1, i2); // string, instantiated generic
var r4 = foo2(1, i2); // error
var r4b = foo2(1, a); // any
var r5 = foo2(1, i); // any
var r6 = foo2('', i2); // string
@@ -66,5 +66,5 @@ function foo3(x, cb, y) {
}
var r7 = foo3(null, i, ''); // any
var r7b = foo3(null, a, ''); // any
var r8 = foo3(1, i2, 1); // {}
var r8 = foo3(1, i2, 1); // error
var r9 = foo3('', i2, ''); // string
@@ -1,161 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts ===
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using construct signature arguments, no errors expected
function foo<T>(x: new(a: T) => T) {
>foo : <T>(x: new (a: T) => T) => T
>T : T
>x : new (a: T) => T
>a : T
>T : T
>T : T
return new x(null);
>new x(null) : T
>x : new (a: T) => T
}
interface I {
>I : I
new <T>(x: T): T;
>T : T
>x : T
>T : T
>T : T
}
interface I2<T> {
>I2 : I2<T>
>T : T
new (x: T): T;
>x : T
>T : T
>T : T
}
var i: I;
>i : I
>I : I
var i2: I2<string>;
>i2 : I2<string>
>I2 : I2<T>
var a: {
>a : new <T>(x: T) => T
new <T>(x: T): T;
>T : T
>x : T
>T : T
>T : T
}
var r = foo(i); // any
>r : any
>foo(i) : any
>foo : <T>(x: new (a: T) => T) => T
>i : I
var r2 = foo<string>(i); // string
>r2 : string
>foo<string>(i) : string
>foo : <T>(x: new (a: T) => T) => T
>i : I
var r3 = foo(i2); // string
>r3 : string
>foo(i2) : string
>foo : <T>(x: new (a: T) => T) => T
>i2 : I2<string>
var r3b = foo(a); // any
>r3b : any
>foo(a) : any
>foo : <T>(x: new (a: T) => T) => T
>a : new <T>(x: T) => T
function foo2<T, U>(x: T, cb: new(a: T) => U) {
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>T : T
>U : U
>x : T
>T : T
>cb : new (a: T) => U
>a : T
>T : T
>U : U
return new cb(x);
>new cb(x) : U
>cb : new (a: T) => U
>x : T
}
var r4 = foo2(1, i2); // string, instantiated generic
>r4 : string
>foo2(1, i2) : string
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>i2 : I2<string>
var r4b = foo2(1, a); // any
>r4b : any
>foo2(1, a) : any
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>a : new <T>(x: T) => T
var r5 = foo2(1, i); // any
>r5 : any
>foo2(1, i) : any
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>i : I
var r6 = foo2<string, string>('', i2); // string
>r6 : string
>foo2<string, string>('', i2) : string
>foo2 : <T, U>(x: T, cb: new (a: T) => U) => U
>i2 : I2<string>
function foo3<T, U>(x: T, cb: new(a: T) => U, y: U) {
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
>T : T
>U : U
>x : T
>T : T
>cb : new (a: T) => U
>a : T
>T : T
>U : U
>y : U
>U : U
return new cb(x);
>new cb(x) : U
>cb : new (a: T) => U
>x : T
}
var r7 = foo3(null, i, ''); // any
>r7 : any
>foo3(null, i, '') : any
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
>i : I
var r7b = foo3(null, a, ''); // any
>r7b : any
>foo3(null, a, '') : any
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
>a : new <T>(x: T) => T
var r8 = foo3(1, i2, 1); // {}
>r8 : {}
>foo3(1, i2, 1) : {}
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
>i2 : I2<string>
var r9 = foo3<string, string>('', i2, ''); // string
>r9 : string
>foo3<string, string>('', i2, '') : string
>foo3 : <T, U>(x: T, cb: new (a: T) => U, y: U) => U
>i2 : I2<string>
@@ -1,51 +1,106 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(14,17): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(15,18): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(24,19): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(36,32): error TS2345: Argument of type '(x: E) => F' is not assignable to parameter of type '(x: E) => E'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(10,29): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(15,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(16,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(25,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(37,36): error TS2345: Argument of type '(x: E) => F' is not assignable to parameter of type '(x: E) => E'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(50,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(51,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(60,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(67,51): error TS2304: Cannot find name 'U'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(67,57): error TS2304: Cannot find name 'U'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts (4 errors) ====
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts (10 errors) ====
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
function foo<T>(a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
module onlyT {
function foo<T>(a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => '');
var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => '');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
function other2<T extends Date>(x: T) {
var r7 = foo((a: T) => a, (b: T) => b); // T => T
// BUG 835518
var r9 = r7(new Date()); // should be ok
~~~~~~~~~~
function other2<T extends Date>(x: T) {
var r7 = foo((a: T) => a, (b: T) => b); // T => T
// BUG 835518
var r9 = r7(new Date()); // should be ok
~~~~~~~~~~
!!! error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'.
var r10 = r7(1); // error
~
var r10 = r7(1); // error
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
}
}
function foo2<T extends Date>(a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
function foo2<T extends Date>(a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
function other3<T extends RegExp>(x: T) {
var r7 = foo2((a: T) => a, (b: T) => b); // error
~~~~~~~~~~~
function other3<T extends RegExp>(x: T) {
var r7 = foo2((a: T) => a, (b: T) => b); // error
~~~~~~~~~~~
!!! error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'.
var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date
var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date
}
enum E { A }
enum F { A }
function foo3<T>(x: T, a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
var r7 = foo3(E.A, (x) => E.A, (x) => F.A); // error
~~~~~~~~~~
!!! error TS2345: Argument of type '(x: E) => F' is not assignable to parameter of type '(x: E) => E'.
}
enum E { A }
enum F { A }
module TU {
function foo<T, U>(a: (x: T) => T, b: (x: U) => U) {
var r: (x: T) => T;
return r;
}
function foo3<T>(x: T, a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => '');
var r7 = foo3(E.A, (x) => E.A, (x) => F.A); // error
~~~~~~~~~~
!!! error TS2345: Argument of type '(x: E) => F' is not assignable to parameter of type '(x: E) => E'.
function other2<T extends Date>(x: T) {
var r7 = foo((a: T) => a, (b: T) => b);
var r9 = r7(new Date());
~~~~~~~~~~
!!! error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'.
var r10 = r7(1);
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
}
function foo2<T extends Date, U extends Date>(a: (x: T) => T, b: (x: U) => U) {
var r: (x: T) => T;
return r;
}
function other3<T extends RegExp>(x: T) {
var r7 = foo2((a: T) => a, (b: T) => b);
~~~~~~~~~~~
!!! error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'.
var r7b = foo2((a) => a, (b) => b);
}
enum E { A }
enum F { A }
function foo3<T>(x: T, a: (x: T) => T, b: (x: U) => U) {
~
!!! error TS2304: Cannot find name 'U'.
~
!!! error TS2304: Cannot find name 'U'.
var r: (x: T) => T;
return r;
}
var r7 = foo3(E.A, (x) => E.A, (x) => F.A);
}
@@ -2,72 +2,146 @@
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
function foo<T>(a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
module onlyT {
function foo<T>(a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => '');
function other2<T extends Date>(x: T) {
var r7 = foo((a: T) => a, (b: T) => b); // T => T
// BUG 835518
var r9 = r7(new Date()); // should be ok
var r10 = r7(1); // error
}
function foo2<T extends Date>(a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
function other3<T extends RegExp>(x: T) {
var r7 = foo2((a: T) => a, (b: T) => b); // error
var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date
}
enum E { A }
enum F { A }
function foo3<T>(x: T, a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
var r7 = foo3(E.A, (x) => E.A, (x) => F.A); // error
}
var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => '');
module TU {
function foo<T, U>(a: (x: T) => T, b: (x: U) => U) {
var r: (x: T) => T;
return r;
}
function other2<T extends Date>(x: T) {
var r7 = foo((a: T) => a, (b: T) => b); // T => T
// BUG 835518
var r9 = r7(new Date()); // should be ok
var r10 = r7(1); // error
}
var r1: (x: {}) => {} = foo((x: number) => 1, (x: string) => '');
function foo2<T extends Date>(a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
function other2<T extends Date>(x: T) {
var r7 = foo((a: T) => a, (b: T) => b);
var r9 = r7(new Date());
var r10 = r7(1);
}
function other3<T extends RegExp>(x: T) {
var r7 = foo2((a: T) => a, (b: T) => b); // error
var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date
}
function foo2<T extends Date, U extends Date>(a: (x: T) => T, b: (x: U) => U) {
var r: (x: T) => T;
return r;
}
enum E { A }
enum F { A }
function other3<T extends RegExp>(x: T) {
var r7 = foo2((a: T) => a, (b: T) => b);
var r7b = foo2((a) => a, (b) => b);
}
function foo3<T>(x: T, a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
enum E { A }
enum F { A }
var r7 = foo3(E.A, (x) => E.A, (x) => F.A); // error
function foo3<T>(x: T, a: (x: T) => T, b: (x: U) => U) {
var r: (x: T) => T;
return r;
}
var r7 = foo3(E.A, (x) => E.A, (x) => F.A);
}
//// [genericCallWithGenericSignatureArguments2.js]
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
function foo(a, b) {
var r;
return r;
}
var r1 = foo(function (x) { return 1; }, function (x) { return ''; });
function other2(x) {
var r7 = foo(function (a) { return a; }, function (b) { return b; }); // T => T
// BUG 835518
var r9 = r7(new Date()); // should be ok
var r10 = r7(1); // error
}
function foo2(a, b) {
var r;
return r;
}
function other3(x) {
var r7 = foo2(function (a) { return a; }, function (b) { return b; }); // error
var r7b = foo2(function (a) { return a; }, function (b) { return b; }); // valid, T is inferred to be Date
}
var E;
(function (E) {
E[E["A"] = 0] = "A";
})(E || (E = {}));
var F;
(function (F) {
F[F["A"] = 0] = "A";
})(F || (F = {}));
function foo3(x, a, b) {
var r;
return r;
}
var r7 = foo3(0 /* A */, function (x) { return 0 /* A */; }, function (x) { return 0 /* A */; }); // error
var onlyT;
(function (onlyT) {
function foo(a, b) {
var r;
return r;
}
var r1 = foo(function (x) { return 1; }, function (x) { return ''; });
function other2(x) {
var r7 = foo(function (a) { return a; }, function (b) { return b; }); // T => T
// BUG 835518
var r9 = r7(new Date()); // should be ok
var r10 = r7(1); // error
}
function foo2(a, b) {
var r;
return r;
}
function other3(x) {
var r7 = foo2(function (a) { return a; }, function (b) { return b; }); // error
var r7b = foo2(function (a) { return a; }, function (b) { return b; }); // valid, T is inferred to be Date
}
var E;
(function (E) {
E[E["A"] = 0] = "A";
})(E || (E = {}));
var F;
(function (F) {
F[F["A"] = 0] = "A";
})(F || (F = {}));
function foo3(x, a, b) {
var r;
return r;
}
var r7 = foo3(0 /* A */, function (x) { return 0 /* A */; }, function (x) { return 0 /* A */; }); // error
})(onlyT || (onlyT = {}));
var TU;
(function (TU) {
function foo(a, b) {
var r;
return r;
}
var r1 = foo(function (x) { return 1; }, function (x) { return ''; });
function other2(x) {
var r7 = foo(function (a) { return a; }, function (b) { return b; });
var r9 = r7(new Date());
var r10 = r7(1);
}
function foo2(a, b) {
var r;
return r;
}
function other3(x) {
var r7 = foo2(function (a) { return a; }, function (b) { return b; });
var r7b = foo2(function (a) { return a; }, function (b) { return b; });
}
var E;
(function (E) {
E[E["A"] = 0] = "A";
})(E || (E = {}));
var F;
(function (F) {
F[F["A"] = 0] = "A";
})(F || (F = {}));
function foo3(x, a, b) {
var r;
return r;
}
var r7 = foo3(0 /* A */, function (x) { return 0 /* A */; }, function (x) { return 0 /* A */; });
})(TU || (TU = {}));
@@ -0,0 +1,42 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts(32,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts(33,11): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts (2 errors) ====
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
function foo<T>(x: T, a: (x: T) => T, b: (x: T) => T) {
var r: (x: T) => T;
return r;
}
var r1 = foo('', (x: string) => '', (x: Object) => null); // any => any
var r1ii = foo('', (x) => '', (x) => null); // string => string
var r2 = foo('', (x: string) => '', (x: Object) => ''); // string => string
var r3 = foo(null, (x: Object) => '', (x: string) => ''); // Object => Object
var r4 = foo(null, (x) => '', (x) => ''); // any => any
var r5 = foo(new Object(), (x) => '', (x) => ''); // Object => Object
enum E { A }
enum F { A }
var r6 = foo(E.A, (x: number) => E.A, (x: F) => F.A); // number => number
function foo2<T, U>(x: T, a: (x: T) => U, b: (x: T) => U) {
var r: (x: T) => U;
return r;
}
var r8 = foo2('', (x) => '', (x) => null); // string => string
var r9 = foo2(null, (x) => '', (x) => ''); // any => any
var r10 = foo2(null, (x: Object) => '', (x: string) => ''); // Object => Object
var x: (a: string) => boolean;
var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
@@ -30,8 +30,8 @@ var r9 = foo2(null, (x) => '', (x) => ''); // any => any
var r10 = foo2(null, (x: Object) => '', (x: string) => ''); // Object => Object
var x: (a: string) => boolean;
var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // {} => {}
var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // (string => boolean) => {}
var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // error
var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // error
//// [genericCallWithGenericSignatureArguments3.js]
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
@@ -63,5 +63,5 @@ var r8 = foo2('', function (x) { return ''; }, function (x) { return null; }); /
var r9 = foo2(null, function (x) { return ''; }, function (x) { return ''; }); // any => any
var r10 = foo2(null, function (x) { return ''; }, function (x) { return ''; }); // Object => Object
var x;
var r11 = foo2(x, function (a1) { return function (n) { return 1; }; }, function (a2) { return 2; }); // {} => {}
var r12 = foo2(x, function (a1) { return function (n) { return 1; }; }, function (a2) { return 2; }); // (string => boolean) => {}
var r11 = foo2(x, function (a1) { return function (n) { return 1; }; }, function (a2) { return 2; }); // error
var r12 = foo2(x, function (a1) { return function (n) { return 1; }; }, function (a2) { return 2; }); // error
@@ -1,202 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts ===
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
function foo<T>(x: T, a: (x: T) => T, b: (x: T) => T) {
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>T : T
>x : T
>T : T
>a : (x: T) => T
>x : T
>T : T
>T : T
>b : (x: T) => T
>x : T
>T : T
>T : T
var r: (x: T) => T;
>r : (x: T) => T
>x : T
>T : T
>T : T
return r;
>r : (x: T) => T
}
var r1 = foo('', (x: string) => '', (x: Object) => null); // any => any
>r1 : (x: any) => any
>foo('', (x: string) => '', (x: Object) => null) : (x: any) => any
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x: string) => '' : (x: string) => string
>x : string
>(x: Object) => null : (x: Object) => any
>x : Object
>Object : Object
var r1ii = foo('', (x) => '', (x) => null); // string => string
>r1ii : (x: string) => string
>foo('', (x) => '', (x) => null) : (x: string) => string
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x) => '' : (x: string) => string
>x : string
>(x) => null : (x: string) => any
>x : string
var r2 = foo('', (x: string) => '', (x: Object) => ''); // string => string
>r2 : (x: Object) => Object
>foo('', (x: string) => '', (x: Object) => '') : (x: Object) => Object
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x: string) => '' : (x: string) => string
>x : string
>(x: Object) => '' : (x: Object) => string
>x : Object
>Object : Object
var r3 = foo(null, (x: Object) => '', (x: string) => ''); // Object => Object
>r3 : (x: Object) => Object
>foo(null, (x: Object) => '', (x: string) => '') : (x: Object) => Object
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x: Object) => '' : (x: Object) => string
>x : Object
>Object : Object
>(x: string) => '' : (x: string) => string
>x : string
var r4 = foo(null, (x) => '', (x) => ''); // any => any
>r4 : (x: any) => any
>foo(null, (x) => '', (x) => '') : (x: any) => any
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>(x) => '' : (x: any) => string
>x : any
>(x) => '' : (x: any) => string
>x : any
var r5 = foo(new Object(), (x) => '', (x) => ''); // Object => Object
>r5 : (x: Object) => Object
>foo(new Object(), (x) => '', (x) => '') : (x: Object) => Object
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>new Object() : Object
>Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; }
>(x) => '' : (x: Object) => string
>x : Object
>(x) => '' : (x: Object) => string
>x : Object
enum E { A }
>E : E
>A : E
enum F { A }
>F : F
>A : F
var r6 = foo(E.A, (x: number) => E.A, (x: F) => F.A); // number => number
>r6 : (x: number) => number
>foo(E.A, (x: number) => E.A, (x: F) => F.A) : (x: number) => number
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>E.A : E
>E : typeof E
>A : E
>(x: number) => E.A : (x: number) => E
>x : number
>E.A : E
>E : typeof E
>A : E
>(x: F) => F.A : (x: F) => F
>x : F
>F : F
>F.A : F
>F : typeof F
>A : F
function foo2<T, U>(x: T, a: (x: T) => U, b: (x: T) => U) {
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>T : T
>U : U
>x : T
>T : T
>a : (x: T) => U
>x : T
>T : T
>U : U
>b : (x: T) => U
>x : T
>T : T
>U : U
var r: (x: T) => U;
>r : (x: T) => U
>x : T
>T : T
>U : U
return r;
>r : (x: T) => U
}
var r8 = foo2('', (x) => '', (x) => null); // string => string
>r8 : (x: string) => any
>foo2('', (x) => '', (x) => null) : (x: string) => any
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>(x) => '' : (x: string) => string
>x : string
>(x) => null : (x: string) => any
>x : string
var r9 = foo2(null, (x) => '', (x) => ''); // any => any
>r9 : (x: any) => string
>foo2(null, (x) => '', (x) => '') : (x: any) => string
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>(x) => '' : (x: any) => string
>x : any
>(x) => '' : (x: any) => string
>x : any
var r10 = foo2(null, (x: Object) => '', (x: string) => ''); // Object => Object
>r10 : (x: Object) => string
>foo2(null, (x: Object) => '', (x: string) => '') : (x: Object) => string
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>(x: Object) => '' : (x: Object) => string
>x : Object
>Object : Object
>(x: string) => '' : (x: string) => string
>x : string
var x: (a: string) => boolean;
>x : (a: string) => boolean
>a : string
var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // {} => {}
>r11 : (x: {}) => {}
>foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2) : (x: {}) => {}
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>x : (a: string) => boolean
>(a1: (y: string) => string) => (n: Object) => 1 : (a1: (y: string) => string) => (n: Object) => number
>a1 : (y: string) => string
>y : string
>(n: Object) => 1 : (n: Object) => number
>n : Object
>Object : Object
>(a2: (z: string) => string) => 2 : (a2: (z: string) => string) => number
>a2 : (z: string) => string
>z : string
var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // (string => boolean) => {}
>r12 : (x: (a: string) => boolean) => {}
>foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2) : (x: (a: string) => boolean) => {}
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>x : (a: string) => boolean
>(a1: (y: string) => boolean) => (n: Object) => 1 : (a1: (y: string) => boolean) => (n: Object) => number
>a1 : (y: string) => boolean
>y : string
>(n: Object) => 1 : (n: Object) => number
>n : Object
>Object : Object
>(a2: (z: string) => boolean) => 2 : (a2: (z: string) => boolean) => number
>a2 : (z: string) => boolean
>z : string
@@ -0,0 +1,14 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,9): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts (1 errors) ====
function foo<T>(x: { bar: T; baz: T }) {
return x;
}
var r = foo({ bar: 1, baz: '' }); // error
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r2 = foo({ bar: 1, baz: 1 }); // T = number
var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo
var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object
@@ -3,7 +3,7 @@ function foo<T>(x: { bar: T; baz: T }) {
return x;
}
var r = foo({ bar: 1, baz: '' }); // T = {}
var r = foo({ bar: 1, baz: '' }); // error
var r2 = foo({ bar: 1, baz: 1 }); // T = number
var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo
var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object
@@ -12,7 +12,7 @@ var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object
function foo(x) {
return x;
}
var r = foo({ bar: 1, baz: '' }); // T = {}
var r = foo({ bar: 1, baz: '' }); // error
var r2 = foo({ bar: 1, baz: 1 }); // T = number
var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo
var r4 = foo({ bar: 1, baz: '' }); // T = Object
@@ -1,49 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts ===
function foo<T>(x: { bar: T; baz: T }) {
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>T : T
>x : { bar: T; baz: T; }
>bar : T
>T : T
>baz : T
>T : T
return x;
>x : { bar: T; baz: T; }
}
var r = foo({ bar: 1, baz: '' }); // T = {}
>r : { bar: {}; baz: {}; }
>foo({ bar: 1, baz: '' }) : { bar: {}; baz: {}; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>{ bar: 1, baz: '' } : { bar: number; baz: string; }
>bar : number
>baz : string
var r2 = foo({ bar: 1, baz: 1 }); // T = number
>r2 : { bar: number; baz: number; }
>foo({ bar: 1, baz: 1 }) : { bar: number; baz: number; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>{ bar: 1, baz: 1 } : { bar: number; baz: number; }
>bar : number
>baz : number
var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo
>r3 : { bar: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; }
>foo({ bar: foo, baz: foo }) : { bar: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>{ bar: foo, baz: foo } : { bar: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; baz: <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }; }
>bar : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>baz : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object
>r4 : { bar: Object; baz: Object; }
>foo<Object>({ bar: 1, baz: '' }) : { bar: Object; baz: Object; }
>foo : <T>(x: { bar: T; baz: T; }) => { bar: T; baz: T; }
>Object : Object
>{ bar: 1, baz: '' } : { bar: number; baz: string; }
>bar : number
>baz : string
@@ -1,3 +1,4 @@
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(2,9): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(4,22): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type '{ x: number; y: number; }'.
Types of property 'y' are incompatible:
Type 'string' is not assignable to type 'number'.
@@ -12,9 +13,11 @@ tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts(7,22): error TS23
Type 'number' is not assignable to type 'string'.
==== tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts (4 errors) ====
==== tests/cases/compiler/genericCallWithObjectLiteralArguments1.ts (5 errors) ====
function foo<T>(n: { x: T; y: T }, m: T) { return m; }
var x = foo({ x: 3, y: "" }, 4); // no error, x is Object, the best common type
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
// these are all errors
var x2 = foo<number>({ x: 3, y: "" }, 4);
~~~~~~~~~~~~~~~
@@ -0,0 +1,27 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts(20,9): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts (1 errors) ====
class C {
private x: string;
}
class D {
private x: string;
}
class X<T> {
x: T;
}
function foo<T>(t: X<T>, t2: X<T>) {
var x: T;
return x;
}
var c1 = new X<C>();
var d1 = new X<D>();
var r = foo(c1, d1); // error
~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r2 = foo(c1, c1); // ok
@@ -1,68 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts ===
class C {
>C : C
private x: string;
>x : string
}
class D {
>D : D
private x: string;
>x : string
}
class X<T> {
>X : X<T>
>T : T
x: T;
>x : T
>T : T
}
function foo<T>(t: X<T>, t2: X<T>) {
>foo : <T>(t: X<T>, t2: X<T>) => T
>T : T
>t : X<T>
>X : X<T>
>T : T
>t2 : X<T>
>X : X<T>
>T : T
var x: T;
>x : T
>T : T
return x;
>x : T
}
var c1 = new X<C>();
>c1 : X<C>
>new X<C>() : X<C>
>X : typeof X
>C : C
var d1 = new X<D>();
>d1 : X<D>
>new X<D>() : X<D>
>X : typeof X
>D : D
var r = foo(c1, d1); // error
>r : {}
>foo(c1, d1) : {}
>foo : <T>(t: X<T>, t2: X<T>) => T
>c1 : X<C>
>d1 : X<D>
var r2 = foo(c1, c1); // ok
>r2 : C
>foo(c1, c1) : C
>foo : <T>(t: X<T>, t2: X<T>) => T
>c1 : X<C>
>c1 : X<C>
@@ -22,7 +22,7 @@ class Derived2 extends Base {
// returns {}[]
function f<T extends Base, U extends Base>(a: { x: T; y: U }) {
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => {}[]
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => Array<T | U>
>T : T
>Base : Base
>U : U
@@ -34,7 +34,7 @@ function f<T extends Base, U extends Base>(a: { x: T; y: U }) {
>U : U
return [a.x, a.y];
>[a.x, a.y] : {}[]
>[a.x, a.y] : Array<T | U>
>a.x : T
>a : { x: T; y: U; }
>x : T
@@ -44,9 +44,9 @@ function f<T extends Base, U extends Base>(a: { x: T; y: U }) {
}
var r = f({ x: new Derived(), y: new Derived2() }); // {}[]
>r : {}[]
>f({ x: new Derived(), y: new Derived2() }) : {}[]
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => {}[]
>r : Array<Derived | Derived2>
>f({ x: new Derived(), y: new Derived2() }) : Array<Derived | Derived2>
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => Array<T | U>
>{ x: new Derived(), y: new Derived2() } : { x: Derived; y: Derived2; }
>x : Derived
>new Derived() : Derived
@@ -56,9 +56,9 @@ var r = f({ x: new Derived(), y: new Derived2() }); // {}[]
>Derived2 : typeof Derived2
var r2 = f({ x: new Base(), y: new Derived2() }); // {}[]
>r2 : {}[]
>f({ x: new Base(), y: new Derived2() }) : {}[]
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => {}[]
>r2 : Base[]
>f({ x: new Base(), y: new Derived2() }) : Base[]
>f : <T extends Base, U extends Base>(a: { x: T; y: U; }) => Array<T | U>
>{ x: new Base(), y: new Derived2() } : { x: Base; y: Derived2; }
>x : Base
>new Base() : Base
@@ -1,7 +1,8 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(18,10): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts(20,29): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts (1 errors) ====
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints3.ts (2 errors) ====
// Generic call with constraints infering type parameter from object member properties
class Base {
@@ -20,6 +21,8 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObj
}
var r1 = f({ x: new Derived(), y: new Derived2() }); // ok, both extend Base
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
function f2<T extends Base, U extends { x: T; y: T }>(a: U) {
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -0,0 +1,54 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts(36,14): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts (1 errors) ====
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them
// Inferences are made quadratic-pairwise to and from these overload sets
module NonGenericParameter {
var a: {
new(x: boolean): boolean;
new(x: string): string;
}
function foo4(cb: typeof a) {
return new cb(null);
}
var r = foo4(a);
var b: { new <T>(x: T): T };
var r2 = foo4(b);
}
module GenericParameter {
function foo5<T>(cb: { new(x: T): string; new(x: number): T }) {
return cb;
}
var a: {
new (x: boolean): string;
new (x: number): boolean;
}
var r5 = foo5(a); // new{} => string; new(x:number) => {}
var b: { new<T>(x: T): string; new<T>(x: number): T; }
var r7 = foo5(b); // new any => string; new(x:number) => any
function foo6<T>(cb: { new(x: T): string; new(x: T, y?: T): string }) {
return cb;
}
var r8 = foo6(a); // error
~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string
function foo7<T>(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) {
return cb;
}
var r13 = foo7(1, b); // new any => string; new(x:any, y?:any) => string
var c: { new <T>(x: T): string; <T>(x: number): T; }
var c2: { new <T>(x: T): string; new<T>(x: number): T; }
var r14 = foo7(1, c); // new any => string; new(x:any, y?:any) => string
var r15 = foo7(1, c2); // new any => string; new(x:any, y?:any) => string
}
@@ -34,7 +34,7 @@ module GenericParameter {
return cb;
}
var r8 = foo6(a); // new{} => string; new(x:{}, y?:{}) => string
var r8 = foo6(a); // error
var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string
function foo7<T>(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) {
@@ -73,7 +73,7 @@ var GenericParameter;
function foo6(cb) {
return cb;
}
var r8 = foo6(a); // new{} => string; new(x:{}, y?:{}) => string
var r8 = foo6(a); // error
var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string
function foo7(x, cb) {
return cb;
@@ -1,173 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithOverloadedConstructorTypedArguments.ts ===
// Function typed arguments with multiple signatures must be passed an implementation that matches all of them
// Inferences are made quadratic-pairwise to and from these overload sets
module NonGenericParameter {
>NonGenericParameter : typeof NonGenericParameter
var a: {
>a : { new (x: boolean): boolean; new (x: string): string; }
new(x: boolean): boolean;
>x : boolean
new(x: string): string;
>x : string
}
function foo4(cb: typeof a) {
>foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean
>cb : { new (x: boolean): boolean; new (x: string): string; }
>a : { new (x: boolean): boolean; new (x: string): string; }
return new cb(null);
>new cb(null) : boolean
>cb : { new (x: boolean): boolean; new (x: string): string; }
}
var r = foo4(a);
>r : boolean
>foo4(a) : boolean
>foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean
>a : { new (x: boolean): boolean; new (x: string): string; }
var b: { new <T>(x: T): T };
>b : new <T>(x: T) => T
>T : T
>x : T
>T : T
>T : T
var r2 = foo4(b);
>r2 : boolean
>foo4(b) : boolean
>foo4 : (cb: { new (x: boolean): boolean; new (x: string): string; }) => boolean
>b : new <T>(x: T) => T
}
module GenericParameter {
>GenericParameter : typeof GenericParameter
function foo5<T>(cb: { new(x: T): string; new(x: number): T }) {
>foo5 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
>T : T
>cb : { new (x: T): string; new (x: number): T; }
>x : T
>T : T
>x : number
>T : T
return cb;
>cb : { new (x: T): string; new (x: number): T; }
}
var a: {
>a : { new (x: boolean): string; new (x: number): boolean; }
new (x: boolean): string;
>x : boolean
new (x: number): boolean;
>x : number
}
var r5 = foo5(a); // new{} => string; new(x:number) => {}
>r5 : { new (x: boolean): string; new (x: number): boolean; }
>foo5(a) : { new (x: boolean): string; new (x: number): boolean; }
>foo5 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
>a : { new (x: boolean): string; new (x: number): boolean; }
var b: { new<T>(x: T): string; new<T>(x: number): T; }
>b : { new <T>(x: T): string; new <T>(x: number): T; }
>T : T
>x : T
>T : T
>T : T
>x : number
>T : T
var r7 = foo5(b); // new any => string; new(x:number) => any
>r7 : { new (x: any): string; new (x: number): any; }
>foo5(b) : { new (x: any): string; new (x: number): any; }
>foo5 : <T>(cb: { new (x: T): string; new (x: number): T; }) => { new (x: T): string; new (x: number): T; }
>b : { new <T>(x: T): string; new <T>(x: number): T; }
function foo6<T>(cb: { new(x: T): string; new(x: T, y?: T): string }) {
>foo6 : <T>(cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>T : T
>cb : { new (x: T): string; new (x: T, y?: T): string; }
>x : T
>T : T
>x : T
>T : T
>y : T
>T : T
return cb;
>cb : { new (x: T): string; new (x: T, y?: T): string; }
}
var r8 = foo6(a); // new{} => string; new(x:{}, y?:{}) => string
>r8 : { new (x: {}): string; new (x: {}, y?: {}): string; }
>foo6(a) : { new (x: {}): string; new (x: {}, y?: {}): string; }
>foo6 : <T>(cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>a : { new (x: boolean): string; new (x: number): boolean; }
var r9 = foo6(b); // new any => string; new(x:any, y?:any) => string
>r9 : { new (x: any): string; new (x: any, y?: any): string; }
>foo6(b) : { new (x: any): string; new (x: any, y?: any): string; }
>foo6 : <T>(cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>b : { new <T>(x: T): string; new <T>(x: number): T; }
function foo7<T>(x:T, cb: { new(x: T): string; new(x: T, y?: T): string }) {
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>T : T
>x : T
>T : T
>cb : { new (x: T): string; new (x: T, y?: T): string; }
>x : T
>T : T
>x : T
>T : T
>y : T
>T : T
return cb;
>cb : { new (x: T): string; new (x: T, y?: T): string; }
}
var r13 = foo7(1, b); // new any => string; new(x:any, y?:any) => string
>r13 : { new (x: any): string; new (x: any, y?: any): string; }
>foo7(1, b) : { new (x: any): string; new (x: any, y?: any): string; }
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>b : { new <T>(x: T): string; new <T>(x: number): T; }
var c: { new <T>(x: T): string; <T>(x: number): T; }
>c : { <T>(x: number): T; new <T>(x: T): string; }
>T : T
>x : T
>T : T
>T : T
>x : number
>T : T
var c2: { new <T>(x: T): string; new<T>(x: number): T; }
>c2 : { new <T>(x: T): string; new <T>(x: number): T; }
>T : T
>x : T
>T : T
>T : T
>x : number
>T : T
var r14 = foo7(1, c); // new any => string; new(x:any, y?:any) => string
>r14 : { new (x: any): string; new (x: any, y?: any): string; }
>foo7(1, c) : { new (x: any): string; new (x: any, y?: any): string; }
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>c : { <T>(x: number): T; new <T>(x: T): string; }
var r15 = foo7(1, c2); // new any => string; new(x:any, y?:any) => string
>r15 : { new (x: any): string; new (x: any, y?: any): string; }
>foo7(1, c2) : { new (x: any): string; new (x: any, y?: any): string; }
>foo7 : <T>(x: T, cb: { new (x: T): string; new (x: T, y?: T): string; }) => { new (x: T): string; new (x: T, y?: T): string; }
>c2 : { new <T>(x: T): string; new <T>(x: number): T; }
}
@@ -0,0 +1,81 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(57,19): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(60,19): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(61,20): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(62,30): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts (4 errors) ====
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using function arguments, no errors expected
module ImmediatelyFix {
class C<T> {
foo<T>(x: (a: T) => T) {
return x(null);
}
}
var c = new C<number>();
var r = c.foo(<U>(x: U) => ''); // {}
var r2 = c.foo<string>(<U>(x: U) => ''); // string
var r3 = c.foo(x => ''); // {}
class C2<T> {
foo(x: (a: T) => T) {
return x(null);
}
}
var c2 = new C2<number>();
var ra = c2.foo(<U>(x: U) => 1); // number
var r3a = c2.foo(x => 1); // number
}
module WithCandidates {
class C<T> {
foo2<T, U>(x: T, cb: (a: T) => U) {
return cb(x);
}
}
var c: C<number>;
var r4 = c.foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
var r5 = c.foo2(1, (a) => ''); // string
var r6 = c.foo2<string, number>('', <Z>(a: Z) => 1); // number
class C2<T, U> {
foo3(x: T, cb: (a: T) => U, y: U) {
return cb(x);
}
}
var c2: C2<number, string>;
var r7 = c2.foo3(1, <Z>(a: Z) => '', ''); // string
var r8 = c2.foo3(1, function (a) { return '' }, ''); // string
class C3<T, U> {
foo3<T,U>(x: T, cb: (a: T) => U, y: U) {
return cb(x);
}
}
var c3: C3<number, string>;
function other<T, U>(t: T, u: U) {
var r10 = c.foo2(1, (x: T) => ''); // error
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r10 = c.foo2(1, (x) => ''); // string
var r11 = c3.foo3(1, (x: T) => '', ''); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r11b = c3.foo3(1, (x: T) => '', 1); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r12 = c3.foo3(1, function (a) { return '' }, 1); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
}
}
@@ -55,12 +55,12 @@ module WithCandidates {
var c3: C3<number, string>;
function other<T, U>(t: T, u: U) {
var r10 = c.foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made
var r10 = c.foo2(1, (x: T) => ''); // error
var r10 = c.foo2(1, (x) => ''); // string
var r11 = c3.foo3(1, (x: T) => '', ''); // string
var r11b = c3.foo3(1, (x: T) => '', 1); // {}
var r12 = c3.foo3(1, function (a) { return '' }, 1); // {}
var r11 = c3.foo3(1, (x: T) => '', ''); // error
var r11b = c3.foo3(1, (x: T) => '', 1); // error
var r12 = c3.foo3(1, function (a) { return '' }, 1); // error
}
}
@@ -132,12 +132,12 @@ var WithCandidates;
})();
var c3;
function other(t, u) {
var r10 = c.foo2(1, function (x) { return ''; }); // string, non-generic signature allows inferences to be made
var r10 = c.foo2(1, function (x) { return ''; }); // error
var r10 = c.foo2(1, function (x) { return ''; }); // string
var r11 = c3.foo3(1, function (x) { return ''; }, ''); // string
var r11b = c3.foo3(1, function (x) { return ''; }, 1); // {}
var r11 = c3.foo3(1, function (x) { return ''; }, ''); // error
var r11b = c3.foo3(1, function (x) { return ''; }, 1); // error
var r12 = c3.foo3(1, function (a) {
return '';
}, 1); // {}
}, 1); // error
}
})(WithCandidates || (WithCandidates = {}));
@@ -1,297 +0,0 @@
=== tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts ===
// Generic functions used as arguments for function typed parameters are not used to make inferences from
// Using function arguments, no errors expected
module ImmediatelyFix {
>ImmediatelyFix : typeof ImmediatelyFix
class C<T> {
>C : C<T>
>T : T
foo<T>(x: (a: T) => T) {
>foo : <T>(x: (a: T) => T) => T
>T : T
>x : (a: T) => T
>a : T
>T : T
>T : T
return x(null);
>x(null) : T
>x : (a: T) => T
}
}
var c = new C<number>();
>c : C<number>
>new C<number>() : C<number>
>C : typeof C
var r = c.foo(<U>(x: U) => ''); // {}
>r : {}
>c.foo(<U>(x: U) => '') : {}
>c.foo : <T>(x: (a: T) => T) => T
>c : C<number>
>foo : <T>(x: (a: T) => T) => T
><U>(x: U) => '' : <U>(x: U) => string
>U : U
>x : U
>U : U
var r2 = c.foo<string>(<U>(x: U) => ''); // string
>r2 : string
>c.foo<string>(<U>(x: U) => '') : string
>c.foo : <T>(x: (a: T) => T) => T
>c : C<number>
>foo : <T>(x: (a: T) => T) => T
><U>(x: U) => '' : <U>(x: U) => string
>U : U
>x : U
>U : U
var r3 = c.foo(x => ''); // {}
>r3 : {}
>c.foo(x => '') : {}
>c.foo : <T>(x: (a: T) => T) => T
>c : C<number>
>foo : <T>(x: (a: T) => T) => T
>x => '' : (x: {}) => string
>x : {}
class C2<T> {
>C2 : C2<T>
>T : T
foo(x: (a: T) => T) {
>foo : (x: (a: T) => T) => T
>x : (a: T) => T
>a : T
>T : T
>T : T
return x(null);
>x(null) : T
>x : (a: T) => T
}
}
var c2 = new C2<number>();
>c2 : C2<number>
>new C2<number>() : C2<number>
>C2 : typeof C2
var ra = c2.foo(<U>(x: U) => 1); // number
>ra : number
>c2.foo(<U>(x: U) => 1) : number
>c2.foo : (x: (a: number) => number) => number
>c2 : C2<number>
>foo : (x: (a: number) => number) => number
><U>(x: U) => 1 : <U>(x: U) => number
>U : U
>x : U
>U : U
var r3a = c2.foo(x => 1); // number
>r3a : number
>c2.foo(x => 1) : number
>c2.foo : (x: (a: number) => number) => number
>c2 : C2<number>
>foo : (x: (a: number) => number) => number
>x => 1 : (x: number) => number
>x : number
}
module WithCandidates {
>WithCandidates : typeof WithCandidates
class C<T> {
>C : C<T>
>T : T
foo2<T, U>(x: T, cb: (a: T) => U) {
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>T : T
>U : U
>x : T
>T : T
>cb : (a: T) => U
>a : T
>T : T
>U : U
return cb(x);
>cb(x) : U
>cb : (a: T) => U
>x : T
}
}
var c: C<number>;
>c : C<number>
>C : C<T>
var r4 = c.foo2(1, function <Z>(a: Z) { return '' }); // string, contextual signature instantiation is applied to generic functions
>r4 : string
>c.foo2(1, function <Z>(a: Z) { return '' }) : string
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>c : C<number>
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>function <Z>(a: Z) { return '' } : <Z>(a: Z) => string
>Z : Z
>a : Z
>Z : Z
var r5 = c.foo2(1, (a) => ''); // string
>r5 : string
>c.foo2(1, (a) => '') : string
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>c : C<number>
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(a) => '' : (a: number) => string
>a : number
var r6 = c.foo2<string, number>('', <Z>(a: Z) => 1); // number
>r6 : number
>c.foo2<string, number>('', <Z>(a: Z) => 1) : number
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>c : C<number>
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
><Z>(a: Z) => 1 : <Z>(a: Z) => number
>Z : Z
>a : Z
>Z : Z
class C2<T, U> {
>C2 : C2<T, U>
>T : T
>U : U
foo3(x: T, cb: (a: T) => U, y: U) {
>foo3 : (x: T, cb: (a: T) => U, y: U) => U
>x : T
>T : T
>cb : (a: T) => U
>a : T
>T : T
>U : U
>y : U
>U : U
return cb(x);
>cb(x) : U
>cb : (a: T) => U
>x : T
}
}
var c2: C2<number, string>;
>c2 : C2<number, string>
>C2 : C2<T, U>
var r7 = c2.foo3(1, <Z>(a: Z) => '', ''); // string
>r7 : string
>c2.foo3(1, <Z>(a: Z) => '', '') : string
>c2.foo3 : (x: number, cb: (a: number) => string, y: string) => string
>c2 : C2<number, string>
>foo3 : (x: number, cb: (a: number) => string, y: string) => string
><Z>(a: Z) => '' : <Z>(a: Z) => string
>Z : Z
>a : Z
>Z : Z
var r8 = c2.foo3(1, function (a) { return '' }, ''); // string
>r8 : string
>c2.foo3(1, function (a) { return '' }, '') : string
>c2.foo3 : (x: number, cb: (a: number) => string, y: string) => string
>c2 : C2<number, string>
>foo3 : (x: number, cb: (a: number) => string, y: string) => string
>function (a) { return '' } : (a: number) => string
>a : number
class C3<T, U> {
>C3 : C3<T, U>
>T : T
>U : U
foo3<T,U>(x: T, cb: (a: T) => U, y: U) {
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>T : T
>U : U
>x : T
>T : T
>cb : (a: T) => U
>a : T
>T : T
>U : U
>y : U
>U : U
return cb(x);
>cb(x) : U
>cb : (a: T) => U
>x : T
}
}
var c3: C3<number, string>;
>c3 : C3<number, string>
>C3 : C3<T, U>
function other<T, U>(t: T, u: U) {
>other : <T, U>(t: T, u: U) => void
>T : T
>U : U
>t : T
>T : T
>u : U
>U : U
var r10 = c.foo2(1, (x: T) => ''); // string, non-generic signature allows inferences to be made
>r10 : string
>c.foo2(1, (x: T) => '') : string
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>c : C<number>
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r10 = c.foo2(1, (x) => ''); // string
>r10 : string
>c.foo2(1, (x) => '') : string
>c.foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>c : C<number>
>foo2 : <T, U>(x: T, cb: (a: T) => U) => U
>(x) => '' : (x: number) => string
>x : number
var r11 = c3.foo3(1, (x: T) => '', ''); // string
>r11 : string
>c3.foo3(1, (x: T) => '', '') : string
>c3.foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>c3 : C3<number, string>
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r11b = c3.foo3(1, (x: T) => '', 1); // {}
>r11b : {}
>c3.foo3(1, (x: T) => '', 1) : {}
>c3.foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>c3 : C3<number, string>
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>(x: T) => '' : (x: T) => string
>x : T
>T : T
var r12 = c3.foo3(1, function (a) { return '' }, 1); // {}
>r12 : {}
>c3.foo3(1, function (a) { return '' }, 1) : {}
>c3.foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>c3 : C3<number, string>
>foo3 : <T, U>(x: T, cb: (a: T) => U, y: U) => U
>function (a) { return '' } : (a: number) => string
>a : number
}
}
@@ -1,10 +1,14 @@
tests/cases/compiler/genericRestArgs.ts(2,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/genericRestArgs.ts(5,34): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
tests/cases/compiler/genericRestArgs.ts(10,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type 'number' is not assignable to parameter of type 'any[]'.
==== tests/cases/compiler/genericRestArgs.ts (2 errors) ====
==== tests/cases/compiler/genericRestArgs.ts (4 errors) ====
function makeArrayG<T>(...items: T[]): T[] { return items; }
var a1Ga = makeArrayG(1, ""); // no error
~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var a1Gb = makeArrayG<any>(1, "");
var a1Gc = makeArrayG<Object>(1, "");
var a1Gd = makeArrayG<number>(1, ""); // error
@@ -15,6 +19,8 @@ tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type '
return [item1, item2, item3];
}
var a2Ga = makeArrayGOpt(1, "");
~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var a2Gb = makeArrayG<any>(1, "");
var a2Gc = makeArrayG<any[]>(1, ""); // error
~
@@ -42,12 +42,12 @@ declare var _: Underscore.Static;
>Static : Underscore.Static
var r = _.all([true, 1, null, 'yes'], _.identity);
>r : {}
>_.all([true, 1, null, 'yes'], _.identity) : {}
>r : string | number | boolean
>_.all([true, 1, null, 'yes'], _.identity) : string | number | boolean
>_.all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => T
>_ : Underscore.Static
>all : <T>(list: T[], iterator?: Underscore.Iterator<T, boolean>, context?: any) => T
>[true, 1, null, 'yes'] : {}[]
>[true, 1, null, 'yes'] : Array<string | number | boolean>
>_.identity : <T>(value: T) => T
>_ : Underscore.Static
>identity : <T>(value: T) => T
@@ -1,6 +1,6 @@
=== tests/cases/compiler/genericsManyTypeParameters.ts ===
function Foo<
>Foo : <a1, a21, a31, a41, a51, a61, a119, a22, a32, a42, a52, a62, a219, a23, a33, a43, a53, a63, a319, a24, a34, a44, a54, a64, a419, a25, a35, a45, a55, a65, a519, a26, a36, a46, a56, a66, a619, a27, a37, a47, a57, a67, a71, a28, a38, a48, a58, a68, a81, a29, a39, a49, a59, a69, a91, a210, a310, a410, a510, a610, a111, a211, a311, a411, a511, a611, a112, a212, a312, a412, a512, a612, a113, a213, a313, a413, a513, a613, a114, a214, a314, a414, a514, a614, a115, a215, a315, a415, a515, a615, a116, a216, a316, a416, a516, a616, a117, a217, a317, a417, a517, a617, a118, a218, a318, a418, a518, a618>(x1: a1, y1: a21, z1: a31, a1: a41, b1: a51, c1: a61, x2: a119, y2: a22, z2: a32, a2: a42, b2: a52, c2: a62, x3: a219, y3: a23, z3: a33, a3: a43, b3: a53, c3: a63, x4: a319, y4: a24, z4: a34, a4: a44, b4: a54, c4: a64, x5: a419, y5: a25, z5: a35, a5: a45, b5: a55, c5: a65, x6: a519, y6: a26, z6: a36, a6: a46, b6: a56, c6: a66, x7: a619, y7: a27, z7: a37, a7: a47, b7: a57, c7: a67, x8: a71, y8: a28, z8: a38, a8: a48, b8: a58, c8: a68, x9: a81, y9: a29, z9: a39, a9: a49, b9: a59, c9: a69, x10: a91, y12: a210, z10: a310, a10: a410, b10: a510, c10: a610, x11: a111, y13: a211, z11: a311, a11: a411, b11: a511, c11: a611, x12: a112, y14: a212, z12: a312, a12: a412, b12: a512, c12: a612, x13: a113, y15: a213, z13: a313, a13: a413, b13: a513, c13: a613, x14: a114, y16: a214, z14: a314, a14: a414, b14: a514, c14: a614, x15: a115, y17: a215, z15: a315, a15: a415, b15: a515, c15: a615, x16: a116, y18: a216, z16: a316, a16: a416, b16: a516, c16: a616, x17: a117, y19: a217, z17: a317, a17: a417, b17: a517, c17: a617, x18: a118, y10: a218, z18: a318, a18: a418, b18: a518, c18: a618) => {}[]
>Foo : <a1, a21, a31, a41, a51, a61, a119, a22, a32, a42, a52, a62, a219, a23, a33, a43, a53, a63, a319, a24, a34, a44, a54, a64, a419, a25, a35, a45, a55, a65, a519, a26, a36, a46, a56, a66, a619, a27, a37, a47, a57, a67, a71, a28, a38, a48, a58, a68, a81, a29, a39, a49, a59, a69, a91, a210, a310, a410, a510, a610, a111, a211, a311, a411, a511, a611, a112, a212, a312, a412, a512, a612, a113, a213, a313, a413, a513, a613, a114, a214, a314, a414, a514, a614, a115, a215, a315, a415, a515, a615, a116, a216, a316, a416, a516, a616, a117, a217, a317, a417, a517, a617, a118, a218, a318, a418, a518, a618>(x1: a1, y1: a21, z1: a31, a1: a41, b1: a51, c1: a61, x2: a119, y2: a22, z2: a32, a2: a42, b2: a52, c2: a62, x3: a219, y3: a23, z3: a33, a3: a43, b3: a53, c3: a63, x4: a319, y4: a24, z4: a34, a4: a44, b4: a54, c4: a64, x5: a419, y5: a25, z5: a35, a5: a45, b5: a55, c5: a65, x6: a519, y6: a26, z6: a36, a6: a46, b6: a56, c6: a66, x7: a619, y7: a27, z7: a37, a7: a47, b7: a57, c7: a67, x8: a71, y8: a28, z8: a38, a8: a48, b8: a58, c8: a68, x9: a81, y9: a29, z9: a39, a9: a49, b9: a59, c9: a69, x10: a91, y12: a210, z10: a310, a10: a410, b10: a510, c10: a610, x11: a111, y13: a211, z11: a311, a11: a411, b11: a511, c11: a611, x12: a112, y14: a212, z12: a312, a12: a412, b12: a512, c12: a612, x13: a113, y15: a213, z13: a313, a13: a413, b13: a513, c13: a613, x14: a114, y16: a214, z14: a314, a14: a414, b14: a514, c14: a614, x15: a115, y17: a215, z15: a315, a15: a415, b15: a515, c15: a615, x16: a116, y18: a216, z16: a316, a16: a416, b16: a516, c16: a616, x17: a117, y19: a217, z17: a317, a17: a417, b17: a517, c17: a617, x18: a118, y10: a218, z18: a318, a18: a418, b18: a518, c18: a618) => Array<a1 | a21 | a31 | a41 | a51 | a61 | a119 | a22 | a32 | a42 | a52 | a62 | a219 | a23 | a33 | a43 | a53 | a63 | a319 | a24 | a34 | a44 | a54 | a64 | a419 | a25 | a35 | a45 | a55 | a65 | a519 | a26 | a36 | a46 | a56 | a66 | a619 | a27 | a37 | a47 | a57 | a67 | a71 | a28 | a38 | a48 | a58 | a68 | a81 | a29 | a39 | a49 | a59 | a69 | a91 | a210 | a310 | a410 | a510 | a610 | a111 | a211 | a311 | a411 | a511 | a611 | a112 | a212 | a312 | a412 | a512 | a612 | a113 | a213 | a313 | a413 | a513 | a613 | a114 | a214 | a314 | a414 | a514 | a614 | a115 | a215 | a315 | a415 | a515 | a615 | a116 | a216 | a316 | a416 | a516 | a616 | a117 | a217 | a317 | a417 | a517 | a617 | a118 | a218 | a318 | a418 | a518 | a618>
a1, a21, a31, a41, a51, a61,
>a1 : a1
@@ -402,7 +402,7 @@ function Foo<
)
{
return [x1 , y1 , z1 , a1 , b1 , c1,
>[x1 , y1 , z1 , a1 , b1 , c1, x2 , y2 , z2 , a2 , b2 , c2, x3 , y3 , z3 , a3 , b3 , c3, x4 , y4 , z4 , a4 , b4 , c4, x5 , y5 , z5 , a5 , b5 , c5, x6 , y6 , z6 , a6 , b6 , c6, x7 , y7 , z7 , a7 , b7 , c7, x8 , y8 , z8 , a8 , b8 , c8, x9 , y9 , z9 , a9 , b9 , c9, x10 , y12 , z10 , a10 , b10 , c10, x11 , y13 , z11 , a11 , b11 , c11, x12 , y14 , z12 , a12 , b12 , c12, x13 , y15 , z13 , a13 , b13 , c13, x14 , y16 , z14 , a14 , b14 , c14, x15 , y17 , z15 , a15 , b15 , c15, x16 , y18 , z16 , a16 , b16 , c16, x17 , y19 , z17 , a17 , b17 , c17, x18 , y10 , z18 , a18 , b18 , c18] : {}[]
>[x1 , y1 , z1 , a1 , b1 , c1, x2 , y2 , z2 , a2 , b2 , c2, x3 , y3 , z3 , a3 , b3 , c3, x4 , y4 , z4 , a4 , b4 , c4, x5 , y5 , z5 , a5 , b5 , c5, x6 , y6 , z6 , a6 , b6 , c6, x7 , y7 , z7 , a7 , b7 , c7, x8 , y8 , z8 , a8 , b8 , c8, x9 , y9 , z9 , a9 , b9 , c9, x10 , y12 , z10 , a10 , b10 , c10, x11 , y13 , z11 , a11 , b11 , c11, x12 , y14 , z12 , a12 , b12 , c12, x13 , y15 , z13 , a13 , b13 , c13, x14 , y16 , z14 , a14 , b14 , c14, x15 , y17 , z15 , a15 , b15 , c15, x16 , y18 , z16 , a16 , b16 , c16, x17 , y19 , z17 , a17 , b17 , c17, x18 , y10 , z18 , a18 , b18 , c18] : Array<a1 | a21 | a31 | a41 | a51 | a61 | a119 | a22 | a32 | a42 | a52 | a62 | a219 | a23 | a33 | a43 | a53 | a63 | a319 | a24 | a34 | a44 | a54 | a64 | a419 | a25 | a35 | a45 | a55 | a65 | a519 | a26 | a36 | a46 | a56 | a66 | a619 | a27 | a37 | a47 | a57 | a67 | a71 | a28 | a38 | a48 | a58 | a68 | a81 | a29 | a39 | a49 | a59 | a69 | a91 | a210 | a310 | a410 | a510 | a610 | a111 | a211 | a311 | a411 | a511 | a611 | a112 | a212 | a312 | a412 | a512 | a612 | a113 | a213 | a313 | a413 | a513 | a613 | a114 | a214 | a314 | a414 | a514 | a614 | a115 | a215 | a315 | a415 | a515 | a615 | a116 | a216 | a316 | a416 | a516 | a616 | a117 | a217 | a317 | a417 | a517 | a617 | a118 | a218 | a318 | a418 | a518 | a618>
>x1 : a1
>y1 : a21
>z1 : a31
@@ -1,5 +1,6 @@
tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'string[]'.
Type '{}' is not assignable to type 'string'.
tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'string[]'.
Type 'string | number' is not assignable to type 'string':
Type 'number' is not assignable to type 'string'.
==== tests/cases/compiler/heterogeneousArrayAndOverloads.ts (1 errors) ====
@@ -13,7 +14,8 @@ tests/cases/compiler/heterogeneousArrayAndOverloads.ts(9,19): error TS2345: Argu
this.test([]);
this.test([1, 2, "hi", 5]); // Error
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'string[]'.
!!! error TS2345: Type '{}' is not assignable to type 'string'.
!!! error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'string[]'.
!!! error TS2345: Type 'string | number' is not assignable to type 'string':
!!! error TS2345: Type 'number' is not assignable to type 'string'.
}
}
@@ -2,16 +2,16 @@
// type of an array is the best common type of its elements (plus its contextual type if it exists)
var a = [1, '']; // {}[]
>a : {}[]
>[1, ''] : {}[]
>a : Array<string | number>
>[1, ''] : Array<string | number>
var b = [1, null]; // number[]
>b : number[]
>[1, null] : number[]
var c = [1, '', null]; // {}[]
>c : {}[]
>[1, '', null] : {}[]
>c : Array<string | number>
>[1, '', null] : Array<string | number>
var d = [{}, 1]; // {}[]
>d : {}[]
@@ -31,8 +31,8 @@ var f = [[], [1]]; // number[][]
>[1] : number[]
var g = [[1], ['']]; // {}[]
>g : {}[]
>[[1], ['']] : {}[]
>g : Array<string[] | number[]>
>[[1], ['']] : Array<string[] | number[]>
>[1] : number[]
>[''] : string[]
@@ -46,8 +46,8 @@ var h = [{ foo: 1, bar: '' }, { foo: 2 }]; // {foo: number}[]
>foo : number
var i = [{ foo: 1, bar: '' }, { foo: '' }]; // {}[]
>i : {}[]
>[{ foo: 1, bar: '' }, { foo: '' }] : {}[]
>i : Array<{ foo: number; bar: string; } | { foo: string; }>
>[{ foo: 1, bar: '' }, { foo: '' }] : Array<{ foo: number; bar: string; } | { foo: string; }>
>{ foo: 1, bar: '' } : { foo: number; bar: string; }
>foo : number
>bar : string
@@ -55,8 +55,8 @@ var i = [{ foo: 1, bar: '' }, { foo: '' }]; // {}[]
>foo : string
var j = [() => 1, () => '']; // {}[]
>j : {}[]
>[() => 1, () => ''] : {}[]
>j : Array<{ (): number; } | { (): string; }>
>[() => 1, () => ''] : Array<{ (): number; } | { (): string; }>
>() => 1 : () => number
>() => '' : () => string
@@ -80,8 +80,8 @@ var m = [() => 1, () => '', () => null]; // { (): any }[]
>() => null : () => any
var n = [[() => 1], [() => '']]; // {}[]
>n : {}[]
>[[() => 1], [() => '']] : {}[]
>n : Array<{ (): number; }[] | { (): string; }[]>
>[[() => 1], [() => '']] : Array<{ (): number; }[] | { (): string; }[]>
>[() => 1] : { (): number; }[]
>() => 1 : () => number
>[() => ''] : { (): string; }[]
@@ -129,8 +129,8 @@ module Derived {
>base : Base
var i = [{ foo: base, basear: derived }, { foo: derived }]; // {foo: Derived}[]
>i : {}[]
>[{ foo: base, basear: derived }, { foo: derived }] : {}[]
>i : Array<{ foo: Base; basear: Derived; } | { foo: Derived; }>
>[{ foo: base, basear: derived }, { foo: derived }] : Array<{ foo: Base; basear: Derived; } | { foo: Derived; }>
>{ foo: base, basear: derived } : { foo: Base; basear: Derived; }
>foo : Base
>base : Base
@@ -149,8 +149,8 @@ module Derived {
>derived : Derived
var k = [() => base, () => 1]; // {}[]~
>k : {}[]
>[() => base, () => 1] : {}[]
>k : Array<{ (): Base; } | { (): number; }>
>[() => base, () => 1] : Array<{ (): Base; } | { (): number; }>
>() => base : () => Base
>base : Base
>() => 1 : () => number
@@ -182,8 +182,8 @@ module Derived {
>derived : Derived
var o = [derived, derived2]; // {}[]
>o : {}[]
>[derived, derived2] : {}[]
>o : Array<Derived | Derived2>
>[derived, derived2] : Array<Derived | Derived2>
>derived : Derived
>derived2 : Derived2
@@ -195,8 +195,8 @@ module Derived {
>base : Base
var q = [[() => derived2], [() => derived]]; // {}[]
>q : {}[]
>[[() => derived2], [() => derived]] : {}[]
>q : Array<{ (): Derived2; }[] | { (): Derived; }[]>
>[[() => derived2], [() => derived]] : Array<{ (): Derived2; }[] | { (): Derived; }[]>
>[() => derived2] : { (): Derived2; }[]
>() => derived2 : () => Derived2
>derived2 : Derived2
@@ -257,19 +257,19 @@ function foo<T, U>(t: T, u: U) {
>t : T
var c = [t, u]; // {}[]
>c : {}[]
>[t, u] : {}[]
>c : Array<T | U>
>[t, u] : Array<T | U>
>t : T
>u : U
var d = [t, 1]; // {}[]
>d : {}[]
>[t, 1] : {}[]
>d : Array<number | T>
>[t, 1] : Array<number | T>
>t : T
var e = [() => t, () => u]; // {}[]
>e : {}[]
>[() => t, () => u] : {}[]
>e : Array<{ (): T; } | { (): U; }>
>[() => t, () => u] : Array<{ (): T; } | { (): U; }>
>() => t : () => T
>t : T
>() => u : () => U
@@ -308,19 +308,19 @@ function foo2<T extends Base, U extends Derived>(t: T, u: U) {
>t : T
var c = [t, u]; // {}[]
>c : {}[]
>[t, u] : {}[]
>c : Array<T | U>
>[t, u] : Array<T | U>
>t : T
>u : U
var d = [t, 1]; // {}[]
>d : {}[]
>[t, 1] : {}[]
>d : Array<number | T>
>[t, 1] : Array<number | T>
>t : T
var e = [() => t, () => u]; // {}[]
>e : {}[]
>[() => t, () => u] : {}[]
>e : Array<{ (): T; } | { (): U; }>
>[() => t, () => u] : Array<{ (): T; } | { (): U; }>
>() => t : () => T
>t : T
>() => u : () => U
@@ -342,8 +342,8 @@ function foo2<T extends Base, U extends Derived>(t: T, u: U) {
>base : Base
var h = [t, derived]; // Derived[]
>h : {}[]
>[t, derived] : {}[]
>h : Array<Derived | T>
>[t, derived] : Array<Derived | T>
>t : T
>derived : Derived
@@ -383,19 +383,19 @@ function foo3<T extends Derived, U extends Derived>(t: T, u: U) {
>t : T
var c = [t, u]; // {}[]
>c : {}[]
>[t, u] : {}[]
>c : Array<T | U>
>[t, u] : Array<T | U>
>t : T
>u : U
var d = [t, 1]; // {}[]
>d : {}[]
>[t, 1] : {}[]
>d : Array<number | T>
>[t, 1] : Array<number | T>
>t : T
var e = [() => t, () => u]; // {}[]
>e : {}[]
>[() => t, () => u] : {}[]
>e : Array<{ (): T; } | { (): U; }>
>[() => t, () => u] : Array<{ (): T; } | { (): U; }>
>() => t : () => T
>t : T
>() => u : () => U
@@ -458,19 +458,19 @@ function foo4<T extends Base, U extends Base>(t: T, u: U) {
>t : T
var c = [t, u]; // BUG 821629
>c : {}[]
>[t, u] : {}[]
>c : Array<T | U>
>[t, u] : Array<T | U>
>t : T
>u : U
var d = [t, 1]; // {}[]
>d : {}[]
>[t, 1] : {}[]
>d : Array<number | T>
>[t, 1] : Array<number | T>
>t : T
var e = [() => t, () => u]; // {}[]
>e : {}[]
>[() => t, () => u] : {}[]
>e : Array<{ (): T; } | { (): U; }>
>[() => t, () => u] : Array<{ (): T; } | { (): U; }>
>() => t : () => T
>t : T
>() => u : () => U
@@ -492,8 +492,8 @@ function foo4<T extends Base, U extends Base>(t: T, u: U) {
>base : Base
var h = [t, derived]; // Derived[]
>h : {}[]
>[t, derived] : {}[]
>h : Array<Derived | T>
>[t, derived] : Array<Derived | T>
>t : T
>derived : Derived
@@ -504,8 +504,8 @@ function foo4<T extends Base, U extends Base>(t: T, u: U) {
>base : Base
var j = [u, derived]; // Derived[]
>j : {}[]
>[u, derived] : {}[]
>j : Array<Derived | U>
>[u, derived] : Array<Derived | U>
>u : U
>derived : Derived
@@ -7,7 +7,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(40,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(43,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(46,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '{}[]'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array<C | D<string>>'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(50,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D<string>[]', but here has type 'D<number>[]'.
tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(53,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'.
@@ -79,7 +79,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'.
var arr = [new C(), new C2(), new D<string>()];
~~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '{}[]'.
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'Array<C | D<string>>'.
var arr2 = [new D<string>()];
var arr2 = new Array<D<number>>();
@@ -108,38 +108,38 @@ var rb2 = a2 || a2; // boolean || boolean is boolean
>a2 : boolean
var rb3 = a3 || a2; // number || boolean is {}
>rb3 : {}
>a3 || a2 : {}
>rb3 : number | boolean
>a3 || a2 : number | boolean
>a3 : number
>a2 : boolean
var rb4 = a4 || a2; // string || boolean is {}
>rb4 : {}
>a4 || a2 : {}
>rb4 : string | boolean
>a4 || a2 : string | boolean
>a4 : string
>a2 : boolean
var rb5 = a5 || a2; // void || boolean is {}
>rb5 : {}
>a5 || a2 : {}
>rb5 : boolean | void
>a5 || a2 : boolean | void
>a5 : void
>a2 : boolean
var rb6 = a6 || a2; // enum || boolean is {}
>rb6 : {}
>a6 || a2 : {}
>rb6 : boolean | E
>a6 || a2 : boolean | E
>a6 : E
>a2 : boolean
var rb7 = a7 || a2; // object || boolean is {}
>rb7 : {}
>a7 || a2 : {}
>rb7 : boolean | { a: string; }
>a7 || a2 : boolean | { a: string; }
>a7 : { a: string; }
>a2 : boolean
var rb8 = a8 || a2; // array || boolean is {}
>rb8 : {}
>a8 || a2 : {}
>rb8 : boolean | string[]
>a8 || a2 : boolean | string[]
>a8 : string[]
>a2 : boolean
@@ -161,8 +161,8 @@ var rc1 = a1 || a3; // any || number is any
>a3 : number
var rc2 = a2 || a3; // boolean || number is {}
>rc2 : {}
>a2 || a3 : {}
>rc2 : number | boolean
>a2 || a3 : number | boolean
>a2 : boolean
>a3 : number
@@ -173,14 +173,14 @@ var rc3 = a3 || a3; // number || number is number
>a3 : number
var rc4 = a4 || a3; // string || number is {}
>rc4 : {}
>a4 || a3 : {}
>rc4 : string | number
>a4 || a3 : string | number
>a4 : string
>a3 : number
var rc5 = a5 || a3; // void || number is {}
>rc5 : {}
>a5 || a3 : {}
>rc5 : number | void
>a5 || a3 : number | void
>a5 : void
>a3 : number
@@ -191,14 +191,14 @@ var rc6 = a6 || a3; // enum || number is number
>a3 : number
var rc7 = a7 || a3; // object || number is {}
>rc7 : {}
>a7 || a3 : {}
>rc7 : number | { a: string; }
>a7 || a3 : number | { a: string; }
>a7 : { a: string; }
>a3 : number
var rc8 = a8 || a3; // array || number is {}
>rc8 : {}
>a8 || a3 : {}
>rc8 : number | string[]
>a8 || a3 : number | string[]
>a8 : string[]
>a3 : number
@@ -220,14 +220,14 @@ var rd1 = a1 || a4; // any || string is any
>a4 : string
var rd2 = a2 || a4; // boolean || string is {}
>rd2 : {}
>a2 || a4 : {}
>rd2 : string | boolean
>a2 || a4 : string | boolean
>a2 : boolean
>a4 : string
var rd3 = a3 || a4; // number || string is {}
>rd3 : {}
>a3 || a4 : {}
>rd3 : string | number
>a3 || a4 : string | number
>a3 : number
>a4 : string
@@ -238,26 +238,26 @@ var rd4 = a4 || a4; // string || string is string
>a4 : string
var rd5 = a5 || a4; // void || string is {}
>rd5 : {}
>a5 || a4 : {}
>rd5 : string | void
>a5 || a4 : string | void
>a5 : void
>a4 : string
var rd6 = a6 || a4; // enum || string is {}
>rd6 : {}
>a6 || a4 : {}
>rd6 : string | E
>a6 || a4 : string | E
>a6 : E
>a4 : string
var rd7 = a7 || a4; // object || string is {}
>rd7 : {}
>a7 || a4 : {}
>rd7 : string | { a: string; }
>a7 || a4 : string | { a: string; }
>a7 : { a: string; }
>a4 : string
var rd8 = a8 || a4; // array || string is {}
>rd8 : {}
>a8 || a4 : {}
>rd8 : string | string[]
>a8 || a4 : string | string[]
>a8 : string[]
>a4 : string
@@ -279,20 +279,20 @@ var re1 = a1 || a5; // any || void is any
>a5 : void
var re2 = a2 || a5; // boolean || void is {}
>re2 : {}
>a2 || a5 : {}
>re2 : boolean | void
>a2 || a5 : boolean | void
>a2 : boolean
>a5 : void
var re3 = a3 || a5; // number || void is {}
>re3 : {}
>a3 || a5 : {}
>re3 : number | void
>a3 || a5 : number | void
>a3 : number
>a5 : void
var re4 = a4 || a5; // string || void is {}
>re4 : {}
>a4 || a5 : {}
>re4 : string | void
>a4 || a5 : string | void
>a4 : string
>a5 : void
@@ -303,20 +303,20 @@ var re5 = a5 || a5; // void || void is void
>a5 : void
var re6 = a6 || a5; // enum || void is {}
>re6 : {}
>a6 || a5 : {}
>re6 : void | E
>a6 || a5 : void | E
>a6 : E
>a5 : void
var re7 = a7 || a5; // object || void is {}
>re7 : {}
>a7 || a5 : {}
>re7 : void | { a: string; }
>a7 || a5 : void | { a: string; }
>a7 : { a: string; }
>a5 : void
var re8 = a8 || a5; // array || void is {}
>re8 : {}
>a8 || a5 : {}
>re8 : void | string[]
>a8 || a5 : void | string[]
>a8 : string[]
>a5 : void
@@ -338,8 +338,8 @@ var rg1 = a1 || a6; // any || enum is any
>a6 : E
var rg2 = a2 || a6; // boolean || enum is {}
>rg2 : {}
>a2 || a6 : {}
>rg2 : boolean | E
>a2 || a6 : boolean | E
>a2 : boolean
>a6 : E
@@ -350,14 +350,14 @@ var rg3 = a3 || a6; // number || enum is number
>a6 : E
var rg4 = a4 || a6; // string || enum is {}
>rg4 : {}
>a4 || a6 : {}
>rg4 : string | E
>a4 || a6 : string | E
>a4 : string
>a6 : E
var rg5 = a5 || a6; // void || enum is {}
>rg5 : {}
>a5 || a6 : {}
>rg5 : void | E
>a5 || a6 : void | E
>a5 : void
>a6 : E
@@ -368,14 +368,14 @@ var rg6 = a6 || a6; // enum || enum is E
>a6 : E
var rg7 = a7 || a6; // object || enum is {}
>rg7 : {}
>a7 || a6 : {}
>rg7 : E | { a: string; }
>a7 || a6 : E | { a: string; }
>a7 : { a: string; }
>a6 : E
var rg8 = a8 || a6; // array || enum is {}
>rg8 : {}
>a8 || a6 : {}
>rg8 : string[] | E
>a8 || a6 : string[] | E
>a8 : string[]
>a6 : E
@@ -397,32 +397,32 @@ var rh1 = a1 || a7; // any || object is any
>a7 : { a: string; }
var rh2 = a2 || a7; // boolean || object is {}
>rh2 : {}
>a2 || a7 : {}
>rh2 : boolean | { a: string; }
>a2 || a7 : boolean | { a: string; }
>a2 : boolean
>a7 : { a: string; }
var rh3 = a3 || a7; // number || object is {}
>rh3 : {}
>a3 || a7 : {}
>rh3 : number | { a: string; }
>a3 || a7 : number | { a: string; }
>a3 : number
>a7 : { a: string; }
var rh4 = a4 || a7; // string || object is {}
>rh4 : {}
>a4 || a7 : {}
>rh4 : string | { a: string; }
>a4 || a7 : string | { a: string; }
>a4 : string
>a7 : { a: string; }
var rh5 = a5 || a7; // void || object is {}
>rh5 : {}
>a5 || a7 : {}
>rh5 : void | { a: string; }
>a5 || a7 : void | { a: string; }
>a5 : void
>a7 : { a: string; }
var rh6 = a6 || a7; // enum || object is {}
>rh6 : {}
>a6 || a7 : {}
>rh6 : E | { a: string; }
>a6 || a7 : E | { a: string; }
>a6 : E
>a7 : { a: string; }
@@ -433,8 +433,8 @@ var rh7 = a7 || a7; // object || object is object
>a7 : { a: string; }
var rh8 = a8 || a7; // array || object is {}
>rh8 : {}
>a8 || a7 : {}
>rh8 : string[] | { a: string; }
>a8 || a7 : string[] | { a: string; }
>a8 : string[]
>a7 : { a: string; }
@@ -456,38 +456,38 @@ var ri1 = a1 || a8; // any || array is any
>a8 : string[]
var ri2 = a2 || a8; // boolean || array is {}
>ri2 : {}
>a2 || a8 : {}
>ri2 : boolean | string[]
>a2 || a8 : boolean | string[]
>a2 : boolean
>a8 : string[]
var ri3 = a3 || a8; // number || array is {}
>ri3 : {}
>a3 || a8 : {}
>ri3 : number | string[]
>a3 || a8 : number | string[]
>a3 : number
>a8 : string[]
var ri4 = a4 || a8; // string || array is {}
>ri4 : {}
>a4 || a8 : {}
>ri4 : string | string[]
>a4 || a8 : string | string[]
>a4 : string
>a8 : string[]
var ri5 = a5 || a8; // void || array is {}
>ri5 : {}
>a5 || a8 : {}
>ri5 : void | string[]
>a5 || a8 : void | string[]
>a5 : void
>a8 : string[]
var ri6 = a6 || a8; // enum || array is {}
>ri6 : {}
>a6 || a8 : {}
>ri6 : string[] | E
>a6 || a8 : string[] | E
>a6 : E
>a8 : string[]
var ri7 = a7 || a8; // object || array is {}
>ri7 : {}
>a7 || a8 : {}
>ri7 : string[] | { a: string; }
>a7 || a8 : string[] | { a: string; }
>a7 : { a: string; }
>a8 : string[]
@@ -22,8 +22,8 @@ function fn1<T, U>(t: T, u: U) {
>t : T
var r3 = t || u;
>r3 : {}
>t || u : {}
>r3 : T | U
>t || u : T | U
>t : T
>u : U
@@ -47,8 +47,8 @@ function fn2<T, U/* extends T*/, V/* extends T*/>(t: T, u: U, v: V) {
>V : V
var r1 = t || u;
>r1 : {}
>t || u : {}
>r1 : T | U
>t || u : T | U
>t : T
>u : U
@@ -67,8 +67,8 @@ function fn2<T, U/* extends T*/, V/* extends T*/>(t: T, u: U, v: V) {
>u : U
var r5 = u || v;
>r5 : {}
>u || v : {}
>r5 : U | V
>u || v : U | V
>u : U
>v : V
@@ -95,8 +95,8 @@ function fn3<T extends { a: string; b: string }, U extends { a: string; b: numbe
>U : U
var r1 = t || u;
>r1 : {}
>t || u : {}
>r1 : T | U
>t || u : T | U
>t : T
>u : U
@@ -1,5 +1,6 @@
tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
Type '{}' is not assignable to type 'number'.
tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
Type 'string | number' is not assignable to type 'number':
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(11,11): error TS2346: Supplied parameters do not match any signature of call target.
@@ -15,8 +16,9 @@ tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(11,11): e
var r6 = map<Object, Object>([1, ""], (x) => x.toString());
var r7 = map<number, string>([1, ""], (x) => x.toString()); // error
~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type '{}' is not assignable to type 'number'.
!!! error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type 'string | number' is not assignable to type 'number':
!!! error TS2345: Type 'string' is not assignable to type 'number'.
var r7b = map<number>([1, ""], (x) => x.toString()); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
@@ -1,22 +0,0 @@
tests/cases/compiler/nonContextuallyTypedLogicalOr.ts(16,10): error TS2339: Property 'dummy' does not exist on type '{}'.
==== tests/cases/compiler/nonContextuallyTypedLogicalOr.ts (1 errors) ====
interface Contextual {
dummy;
p?: number;
}
interface Ellement {
dummy;
p: any;
}
var c: Contextual;
var e: Ellement;
// This should error. Even though we are contextually typing e with Contextual, the RHS still
// needs to be a supertype of the LHS to win as the best common type.
(c || e).dummy;
~~~~~
!!! error TS2339: Property 'dummy' does not exist on type '{}'.
@@ -12,13 +12,9 @@ interface Ellement {
var c: Contextual;
var e: Ellement;
// This should error. Even though we are contextually typing e with Contextual, the RHS still
// needs to be a supertype of the LHS to win as the best common type.
(c || e).dummy;
//// [nonContextuallyTypedLogicalOr.js]
var c;
var e;
// This should error. Even though we are contextually typing e with Contextual, the RHS still
// needs to be a supertype of the LHS to win as the best common type.
(c || e).dummy;
@@ -0,0 +1,37 @@
=== tests/cases/compiler/nonContextuallyTypedLogicalOr.ts ===
interface Contextual {
>Contextual : Contextual
dummy;
>dummy : any
p?: number;
>p : number
}
interface Ellement {
>Ellement : Ellement
dummy;
>dummy : any
p: any;
>p : any
}
var c: Contextual;
>c : Contextual
>Contextual : Contextual
var e: Ellement;
>e : Ellement
>Ellement : Ellement
(c || e).dummy;
>(c || e).dummy : any
>(c || e) : Contextual | Ellement
>c || e : Contextual | Ellement
>c : Contextual
>e : Ellement
>dummy : any
@@ -10,9 +10,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(55,5): error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: number]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: unknown; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }':
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: number]: string | number; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: unknown; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }':
Index signatures are incompatible:
Type '{}' is not assignable to type 'string'.
Type 'string | number' is not assignable to type 'string':
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'.
@@ -116,9 +117,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
// error
var b: { [x: number]: string; } = {
~
!!! error TS2322: Type '{ [x: number]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: unknown; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }':
!!! error TS2322: Type '{ [x: number]: string | number; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: unknown; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }':
!!! error TS2322: Index signatures are incompatible:
!!! error TS2322: Type '{}' is not assignable to type 'string'.
!!! error TS2322: Type 'string | number' is not assignable to type 'string':
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a: '',
b: 1,
c: () => { },
@@ -4,10 +4,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(26,5): error TS2412: Property '"4.0"' of type 'string' is not assignable to numeric index type 'A'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(35,5): error TS2412: Property '"4.0"' of type 'string' is not assignable to numeric index type 'A'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: {}; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }':
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: string | number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }':
Index signatures are incompatible:
Type '{}' is not assignable to type 'A':
Property 'foo' is missing in type '{}'.
Type 'string | number | A' is not assignable to type 'A':
Type 'string' is not assignable to type 'A'.
==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts (7 errors) ====
@@ -63,10 +63,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
// error
var b: { [x: number]: A } = {
~
!!! error TS2322: Type '{ [x: number]: {}; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }':
!!! error TS2322: Type '{ [x: number]: string | number | A; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }':
!!! error TS2322: Index signatures are incompatible:
!!! error TS2322: Type '{}' is not assignable to type 'A':
!!! error TS2322: Property 'foo' is missing in type '{}'.
!!! error TS2322: Type 'string | number | A' is not assignable to type 'A':
!!! error TS2322: Type 'string' is not assignable to type 'A'.
1.0: new A(),
2.0: new B(),
"2.5": new B(),
@@ -1,7 +1,8 @@
tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(16,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error TS2304: Cannot find name 'runTestCase'.
==== tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts (1 errors) ====
==== tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts (2 errors) ====
/// Copyright (c) 2012 Ecma International. All rights reserved.
/// Ecma International makes this code available under the terms and conditions set
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
@@ -18,6 +19,8 @@ tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error T
var one = 1;
var _float = -(4/3);
var a = new Array(false,undefined,null,"0",obj,-1.3333333333333, "str",-0,true,+0, one, 1,0, false, _float, -(4/3));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
if (a.indexOf(-(4/3)) === 14 && // a[14]=_float===-(4/3)
a.indexOf(0) === 7 && // a[7] = +0, 0===+0
a.indexOf(-0) === 7 && // a[7] = +0, -0===+0
@@ -1,3 +1,4 @@
tests/cases/compiler/promisePermutations.ts(74,70): error TS2345: Argument of type '(x: number) => IPromise<number>' is not assignable to parameter of type '(value: IPromise<number>) => IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(79,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
tests/cases/compiler/promisePermutations.ts(82,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
tests/cases/compiler/promisePermutations.ts(83,19): error TS2345: Argument of type '(x: number, y?: string) => Promise<string>' is not assignable to parameter of type '(value: string) => Promise<string>'.
@@ -19,13 +20,20 @@ tests/cases/compiler/promisePermutations.ts(120,19): error TS2345: Argument of t
tests/cases/compiler/promisePermutations.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations.ts(122,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(126,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(129,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations.ts(134,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(137,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations.ts(144,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations.ts(152,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations.ts(156,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => Promise<string>'.
tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
==== tests/cases/compiler/promisePermutations.ts (25 errors) ====
==== tests/cases/compiler/promisePermutations.ts (33 errors) ====
interface Promise<T> {
then<U>(success?: (value: T) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>;
then<U>(success?: (value: T) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>;
@@ -39,7 +47,7 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
then<U>(success?: (value: T) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
done?<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
done? <U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
}
declare function testFunction(): IPromise<number>;
@@ -99,7 +107,9 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
var s3a = s3.then(testFunction3, testFunction3, testFunction3);
var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P);
var s3c = s3.then(testFunction3P, testFunction3, testFunction3);
var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3);
var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number) => IPromise<number>' is not assignable to parameter of type '(value: IPromise<number>) => IPromise<number>'.
var r4: IPromise<string>;
var sIPromise: (x: any) => IPromise<string>;
@@ -118,7 +128,7 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number, y?: string) => Promise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var r5: IPromise<string>;
var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error
@@ -197,6 +207,8 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@@ -210,7 +222,9 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
@@ -218,6 +232,8 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(x => x);
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@@ -225,17 +241,25 @@ tests/cases/compiler/promisePermutations.ts(158,21): error TS2345: Argument of t
var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var s11: Promise<number>;
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => Promise<string>'.
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var r12 = testFunction12(x => x);
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
@@ -12,7 +12,7 @@ interface IPromise<T> {
then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
then<U>(success?: (value: T) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
done?<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
done? <U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
}
declare function testFunction(): IPromise<number>;
@@ -72,7 +72,7 @@ var s3: Promise<number>;
var s3a = s3.then(testFunction3, testFunction3, testFunction3);
var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P);
var s3c = s3.then(testFunction3P, testFunction3, testFunction3);
var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3);
var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); // error
var r4: IPromise<string>;
var sIPromise: (x: any) => IPromise<string>;
@@ -83,7 +83,7 @@ var s4: Promise<string>;
var s4a = s4.then(testFunction4, testFunction4, testFunction4); // error
var s4b = s4.then(testFunction4P, testFunction4P, testFunction4P); // error
var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var r5: IPromise<string>;
var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error
@@ -135,7 +135,7 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error
var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
@@ -150,15 +150,15 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok
var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error
var s11: Promise<number>;
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error
var r12 = testFunction12(x => x);
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
@@ -192,7 +192,7 @@ var s3;
var s3a = s3.then(testFunction3, testFunction3, testFunction3);
var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P);
var s3c = s3.then(testFunction3P, testFunction3, testFunction3);
var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3);
var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); // error
var r4;
var sIPromise;
var sPromise;
@@ -249,7 +249,7 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error
var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(function (x) { return x; });
var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok
@@ -263,14 +263,14 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok
var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11;
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error
var s11;
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error
var r12 = testFunction12(function (x) { return x; });
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
var s12 = testFunction12(function (x) { return x; });
@@ -20,15 +20,20 @@ tests/cases/compiler/promisePermutations2.ts(119,19): error TS2345: Argument of
tests/cases/compiler/promisePermutations2.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations2.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(125,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations2.ts(128,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations2.ts(131,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations2.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations2.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(136,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations2.ts(143,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations2.ts(151,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations2.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations2.ts(157,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations2.ts(158,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => Promise<string>'.
tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
==== tests/cases/compiler/promisePermutations2.ts (28 errors) ====
==== tests/cases/compiler/promisePermutations2.ts (33 errors) ====
// same as promisePermutations but without the same overloads in Promise<T>
interface Promise<T> {
@@ -41,7 +46,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
then<U>(success?: (value: T) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
done?<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
done? <U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
}
declare function testFunction(): IPromise<number>;
@@ -122,7 +127,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number, y?: string) => Promise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var r5: IPromise<string>;
var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error
@@ -200,7 +205,9 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@@ -214,14 +221,18 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(x => x);
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@@ -229,11 +240,15 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var s11: Promise<number>;
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
~~~~~~~~~~~~~~
@@ -11,7 +11,7 @@ interface IPromise<T> {
then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
then<U>(success?: (value: T) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
done?<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
done? <U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
}
declare function testFunction(): IPromise<number>;
@@ -82,7 +82,7 @@ var s4: Promise<string>;
var s4a = s4.then(testFunction4, testFunction4, testFunction4); // error
var s4b = s4.then(testFunction4P, testFunction4P, testFunction4P); // error
var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var r5: IPromise<string>;
var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error
@@ -126,7 +126,7 @@ var r9: IPromise<number>;
var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // error
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@@ -134,14 +134,14 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error
var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // error
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(x => x);
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@@ -149,11 +149,11 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok
var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error
var s11: Promise<number>;
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok
@@ -241,7 +241,7 @@ var r9;
var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // error
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@@ -249,13 +249,13 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error
var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(function (x) { return x; });
var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // error
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(function (x) { return x; });
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@@ -263,10 +263,10 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok
var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11;
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // error
var s11;
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok
@@ -1,4 +1,5 @@
tests/cases/compiler/promisePermutations3.ts(68,69): error TS2345: Argument of type '(x: number) => IPromise<number>' is not assignable to parameter of type '(value: IPromise<number>) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(73,70): error TS2345: Argument of type '(x: number) => IPromise<number>' is not assignable to parameter of type '(value: IPromise<number>) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(78,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(81,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(82,19): error TS2345: Argument of type '(x: number, y?: string) => Promise<string>' is not assignable to parameter of type '(value: string) => Promise<string>'.
@@ -20,15 +21,21 @@ tests/cases/compiler/promisePermutations3.ts(119,19): error TS2345: Argument of
tests/cases/compiler/promisePermutations3.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations3.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(125,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(128,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations3.ts(131,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations3.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(136,11): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations3.ts(143,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations3.ts(151,12): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/promisePermutations3.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(157,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(158,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => Promise<string>'.
tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<any>'.
==== tests/cases/compiler/promisePermutations3.ts (28 errors) ====
==== tests/cases/compiler/promisePermutations3.ts (35 errors) ====
// same as promisePermutations but without the same overloads in IPromise<T>
interface Promise<T> {
@@ -41,7 +48,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
interface IPromise<T> {
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
done?<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
done? <U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
}
declare function testFunction(): IPromise<number>;
@@ -104,6 +111,8 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P);
var s3c = s3.then(testFunction3P, testFunction3, testFunction3);
var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3);
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number) => IPromise<number>' is not assignable to parameter of type '(value: IPromise<number>) => IPromise<number>'.
var r4: IPromise<string>;
var sIPromise: (x: any) => IPromise<string>;
@@ -122,7 +131,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number, y?: string) => Promise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var r5: IPromise<string>;
var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error
@@ -200,7 +209,9 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@@ -214,14 +225,18 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(x => x);
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@@ -229,7 +244,9 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
@@ -240,8 +257,12 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => Promise<string>'.
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ (x: number): Promise<number>; (x: string): Promise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
var r12 = testFunction12(x => x);
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
@@ -11,7 +11,7 @@ interface Promise<T> {
interface IPromise<T> {
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
done?<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
done? <U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
}
declare function testFunction(): IPromise<number>;
@@ -82,7 +82,7 @@ var s4: Promise<string>;
var s4a = s4.then(testFunction4, testFunction4, testFunction4); // error
var s4b = s4.then(testFunction4P, testFunction4P, testFunction4P); // error
var s4c = s4.then(testFunction4P, testFunction4, testFunction4); // error
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var s4d = s4.then(sIPromise, testFunction4P, testFunction4).then(sIPromise, testFunction4P, testFunction4);
var r5: IPromise<string>;
var r5a = r5.then(testFunction5, testFunction5, testFunction5); // error
@@ -126,7 +126,7 @@ var r9: IPromise<number>;
var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // error
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@@ -134,14 +134,14 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error
var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(x => x);
var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // error
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(x => x);
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@@ -149,15 +149,15 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok
var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok
var s11: Promise<number>;
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error
var r12 = testFunction12(x => x);
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
@@ -241,7 +241,7 @@ var r9;
var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // error
var r9e = r9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s9;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
@@ -249,13 +249,13 @@ var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error
var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error
var s9d = s9.then(sPromise, sPromise, sPromise); // ok
var s9e = s9.then(nPromise, nPromise, nPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // ok
var s9f = s9.then(testFunction, sIPromise, nIPromise); // error
var s9g = s9.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var r10 = testFunction10(function (x) { return x; });
var r10a = r10.then(testFunction10, testFunction10, testFunction10); // ok
var r10b = r10.then(sIPromise, sIPromise, sIPromise); // ok
var r10c = r10.then(nIPromise, nIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok
var r10d = r10.then(testFunction, sIPromise, nIPromise); // error
var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok
var s10 = testFunction10P(function (x) { return x; });
var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok
@@ -263,14 +263,14 @@ var s10b = s10.then(testFunction10P, testFunction10P, testFunction10P); // ok
var s10c = s10.then(testFunction10P, testFunction10, testFunction10); // ok
var s10d = s10.then(sPromise, sPromise, sPromise); // ok
var s10e = s10.then(nIPromise, nPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // ok
var s10f = s10.then(testFunctionP, sIPromise, nIPromise); // error
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11;
var r11a = r11.then(testFunction11, testFunction11, testFunction11); // ok
var s11;
var s11a = s11.then(testFunction11, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // ok
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // ok
var s11b = s11.then(testFunction11P, testFunction11P, testFunction11P); // error
var s11c = s11.then(testFunction11P, testFunction11, testFunction11); // error
var r12 = testFunction12(function (x) { return x; });
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
var s12 = testFunction12(function (x) { return x; });
@@ -24,9 +24,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'.
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }':
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | MyString | { (): void; }; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }':
Index signatures are incompatible:
Type '{}' is not assignable to type 'string'.
Type 'string | number | MyString | { (): void; }' is not assignable to type 'string':
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts (27 errors) ====
@@ -159,9 +160,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon
// error
var b: { [x: string]: string; } = {
~
!!! error TS2322: Type '{ [x: string]: {}; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }':
!!! error TS2322: Type '{ [x: string]: string | number | MyString | { (): void; }; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo: () => string; }' is not assignable to type '{ [x: string]: string; }':
!!! error TS2322: Index signatures are incompatible:
!!! error TS2322: Type '{}' is not assignable to type 'string'.
!!! error TS2322: Type 'string | number | MyString | { (): void; }' is not assignable to type 'string':
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a: '',
b: 1,
c: () => { },
@@ -1,46 +1,10 @@
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(7,7): error TS2416: Class 'D1<T, U>' incorrectly extends base class 'C3<T>':
Types of property 'foo' are incompatible:
Type 'U' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(12,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(13,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(38,14): error TS2367: No best common type exists between 'number' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(39,14): error TS2367: No best common type exists between 'T' and 'number'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(41,14): error TS2367: No best common type exists between 'string' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(42,14): error TS2367: No best common type exists between 'T' and 'string'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(44,14): error TS2367: No best common type exists between 'boolean' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(45,14): error TS2367: No best common type exists between 'T' and 'boolean'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(47,14): error TS2367: No best common type exists between 'Date' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(48,14): error TS2367: No best common type exists between 'T' and 'Date'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(50,14): error TS2367: No best common type exists between 'RegExp' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(51,14): error TS2367: No best common type exists between 'T' and 'RegExp'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(53,14): error TS2367: No best common type exists between '{ foo: number; }' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(54,14): error TS2367: No best common type exists between 'T' and '{ foo: number; }'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(56,14): error TS2367: No best common type exists between '() => void' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(57,14): error TS2367: No best common type exists between 'T' and '() => void'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(59,14): error TS2367: No best common type exists between '<T>(x: T) => T' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(60,15): error TS2367: No best common type exists between 'T' and '<T>(x: T) => T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(63,14): error TS2367: No best common type exists between 'I1' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(64,14): error TS2367: No best common type exists between 'T' and 'I1'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(67,15): error TS2367: No best common type exists between 'C1' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(68,15): error TS2367: No best common type exists between 'T' and 'C1'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(72,15): error TS2367: No best common type exists between 'C2<number>' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(73,15): error TS2367: No best common type exists between 'T' and 'C2<number>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(76,15): error TS2367: No best common type exists between 'typeof E' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(77,15): error TS2367: No best common type exists between 'T' and 'typeof E'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(79,15): error TS2367: No best common type exists between 'E' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(80,15): error TS2367: No best common type exists between 'T' and 'E'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(83,15): error TS2367: No best common type exists between 'typeof f' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(84,15): error TS2367: No best common type exists between 'T' and 'typeof f'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(87,15): error TS2367: No best common type exists between 'typeof c' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(88,15): error TS2367: No best common type exists between 'T' and 'typeof c'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(91,19): error TS2367: No best common type exists between 'T' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(92,19): error TS2367: No best common type exists between 'T' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(95,21): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(96,19): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(97,19): error TS2367: No best common type exists between 'U' and 'T'.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (38 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (2 errors) ====
// checking whether other types are subtypes of type parameters
class C3<T> {
@@ -57,11 +21,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
function f1<T, U>(x: T, y: U) {
var r = true ? x : y; // error
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? y : x; // error
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
}
interface I1 { foo: number; }
@@ -87,135 +47,67 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
var r0b = true ? x : u;
var r1 = true ? 1 : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'number' and 'T'.
var r1 = true ? x : 1;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'number'.
var r2 = true ? '' : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'string' and 'T'.
var r2 = true ? x : '';
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'string'.
var r3 = true ? true : x;
~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'boolean' and 'T'.
var r3 = true ? x : true;
~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'boolean'.
var r4 = true ? new Date() : x;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Date' and 'T'.
var r4 = true ? x : new Date();
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'Date'.
var r5 = true ? /1/ : x;
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'RegExp' and 'T'.
var r5 = true ? x : /1/;
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'RegExp'.
var r6 = true ? { foo: 1 } : x;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between '{ foo: number; }' and 'T'.
var r6 = true ? x : { foo: 1 };
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and '{ foo: number; }'.
var r7 = true ? () => { } : x;
~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between '() => void' and 'T'.
var r7 = true ? x : () => { };
~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and '() => void'.
var r8 = true ? <T>(x: T) => { return x } : x;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between '<T>(x: T) => T' and 'T'.
var r8b = true ? x : <T>(x: T) => { return x }; // type parameters not identical across declarations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and '<T>(x: T) => T'.
var i1: I1;
var r9 = true ? i1 : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'I1' and 'T'.
var r9 = true ? x : i1;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'I1'.
var c1: C1;
var r10 = true ? c1 : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'C1' and 'T'.
var r10 = true ? x : c1;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'C1'.
var c2: C2<number>;
var r12 = true ? c2 : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'C2<number>' and 'T'.
var r12 = true ? x : c2;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'C2<number>'.
var r13 = true ? E : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'typeof E' and 'T'.
var r13 = true ? x : E;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'typeof E'.
var r14 = true ? E.A : x;
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'E' and 'T'.
var r14 = true ? x : E.A;
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'E'.
var af: typeof f;
var r15 = true ? af : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'typeof f' and 'T'.
var r15 = true ? x : af;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'typeof f'.
var ac: typeof c;
var r16 = true ? ac : x;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'typeof c' and 'T'.
var r16 = true ? x : ac;
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'typeof c'.
function f17<T>(a: T) {
var r17 = true ? x : a;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'T'.
var r17 = true ? a : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'T'.
}
function f18<T, U extends T>(a: U) {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
var r18 = true ? x : a;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r18 = true ? a : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
}
var r19 = true ? new Object() : x; // BCT is Object
@@ -1,46 +1,18 @@
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(3,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(4,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(5,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(9,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(9,26): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(10,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(11,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(14,14): error TS2367: No best common type exists between 'V' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(15,14): error TS2367: No best common type exists between 'U' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(18,14): error TS2367: No best common type exists between 'V' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(19,14): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(23,13): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(24,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(25,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(28,14): error TS2367: No best common type exists between 'T' and 'Date'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(29,14): error TS2367: No best common type exists between 'Date' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(60,14): error TS2367: No best common type exists between 'number' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(61,14): error TS2367: No best common type exists between 'T' and 'number'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(65,14): error TS2367: No best common type exists between 'string' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(66,14): error TS2367: No best common type exists between 'T' and 'string'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(70,14): error TS2367: No best common type exists between 'boolean' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(71,14): error TS2367: No best common type exists between 'T' and 'boolean'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(118,15): error TS2367: No best common type exists between 'typeof E' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(119,15): error TS2367: No best common type exists between 'T' and 'typeof E'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(121,15): error TS2367: No best common type exists between 'E' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(122,15): error TS2367: No best common type exists between 'T' and 'E'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(143,18): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(144,19): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts(145,19): error TS2367: No best common type exists between 'V' and 'T'.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts (29 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints2.ts (5 errors) ====
// checking whether other types are subtypes of type parameters with constraints
function f1<T extends U, U>(x: T, y: U) {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
var r = true ? x : y;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? y : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
}
// V > U > T
@@ -50,27 +22,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
var r = true ? x : y;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? y : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
// ok
var r2 = true ? z : y;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'U'.
var r2 = true ? y : z;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'V'.
// ok
var r2 = true ? z : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
var r2 = true ? x : z;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
var r2a = true ? z : x;
var r2b = true ? x : z;
}
// Date > U > T
@@ -78,19 +38,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
var r = true ? x : y;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? y : x;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
// ok
var r2 = true ? x : new Date();
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'Date'.
var r2 = true ? new Date() : x;
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Date' and 'T'.
// ok
var r3 = true ? y : new Date();
@@ -121,30 +73,18 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
}
function f5<T extends Number>(x: T) {
var r1 = true ? 1 : x; // error
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'number' and 'T'.
var r1 = true ? x : 1; // error
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'number'.
var r1 = true ? 1 : x; // ok
var r1 = true ? x : 1; // ok
}
function f6<T extends String>(x: T) {
var r2 = true ? '' : x; // error
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'string' and 'T'.
var r2 = true ? x : ''; // error
~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'string'.
var r2 = true ? '' : x; // ok
var r2 = true ? x : ''; // ok
}
function f7<T extends Boolean>(x: T) {
var r3 = true ? true : x; // error
~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'boolean' and 'T'.
var r3 = true ? x : true; // error
~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'boolean'.
var r3 = true ? true : x; // ok
var r3 = true ? x : true; // ok
}
function f8<T extends Date>(x: T) {
@@ -191,19 +131,11 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
}
function f16<T extends E>(x: T) {
var r13 = true ? E : x; // BUG 831833
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'typeof E' and 'T'.
var r13 = true ? x : E; // BUG 831833
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'typeof E'.
var r13 = true ? E : x; // ok
var r13 = true ? x : E; // ok
var r14 = true ? E.A : x; // BUG 831833
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'E' and 'T'.
var r14 = true ? x : E.A; // BUG 831833
~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'E'.
var r14 = true ? E.A : x; // ok
var r14 = true ? x : E.A; // ok
}
function f17<T extends typeof f>(x: T) {
@@ -228,11 +160,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
var r18 = true ? x : a; // ok
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
var r18 = true ? a : x; // ok
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
}
}
@@ -16,8 +16,8 @@ function f2<T extends U, U extends V, V>(x: T, y: U, z: V) {
var r2 = true ? y : z;
// ok
var r2 = true ? z : x;
var r2 = true ? x : z;
var r2a = true ? z : x;
var r2b = true ? x : z;
}
// Date > U > T
@@ -58,18 +58,18 @@ function f4<T extends Number>(x: T) {
}
function f5<T extends Number>(x: T) {
var r1 = true ? 1 : x; // error
var r1 = true ? x : 1; // error
var r1 = true ? 1 : x; // ok
var r1 = true ? x : 1; // ok
}
function f6<T extends String>(x: T) {
var r2 = true ? '' : x; // error
var r2 = true ? x : ''; // error
var r2 = true ? '' : x; // ok
var r2 = true ? x : ''; // ok
}
function f7<T extends Boolean>(x: T) {
var r3 = true ? true : x; // error
var r3 = true ? x : true; // error
var r3 = true ? true : x; // ok
var r3 = true ? x : true; // ok
}
function f8<T extends Date>(x: T) {
@@ -116,11 +116,11 @@ function f15<T extends C2<number>>(x: T) {
}
function f16<T extends E>(x: T) {
var r13 = true ? E : x; // BUG 831833
var r13 = true ? x : E; // BUG 831833
var r13 = true ? E : x; // ok
var r13 = true ? x : E; // ok
var r14 = true ? E.A : x; // BUG 831833
var r14 = true ? x : E.A; // BUG 831833
var r14 = true ? E.A : x; // ok
var r14 = true ? x : E.A; // ok
}
function f17<T extends typeof f>(x: T) {
@@ -171,8 +171,8 @@ function f2(x, y, z) {
var r2 = true ? z : y;
var r2 = true ? y : z;
// ok
var r2 = true ? z : x;
var r2 = true ? x : z;
var r2a = true ? z : x;
var r2b = true ? x : z;
}
// Date > U > T
function f3(x, y) {
@@ -222,16 +222,16 @@ function f4(x) {
var r0b = true ? x : u; // ok
}
function f5(x) {
var r1 = true ? 1 : x; // error
var r1 = true ? x : 1; // error
var r1 = true ? 1 : x; // ok
var r1 = true ? x : 1; // ok
}
function f6(x) {
var r2 = true ? '' : x; // error
var r2 = true ? x : ''; // error
var r2 = true ? '' : x; // ok
var r2 = true ? x : ''; // ok
}
function f7(x) {
var r3 = true ? true : x; // error
var r3 = true ? x : true; // error
var r3 = true ? true : x; // ok
var r3 = true ? x : true; // ok
}
function f8(x) {
var r4 = true ? new Date() : x; // ok
@@ -275,10 +275,10 @@ function f15(x) {
var r12 = true ? x : c2; // ok
}
function f16(x) {
var r13 = true ? E : x; // BUG 831833
var r13 = true ? x : E; // BUG 831833
var r14 = true ? 0 /* A */ : x; // BUG 831833
var r14 = true ? x : 0 /* A */; // BUG 831833
var r13 = true ? E : x; // ok
var r13 = true ? x : E; // ok
var r14 = true ? 0 /* A */ : x; // ok
var r14 = true ? x : 0 /* A */; // ok
}
function f17(x) {
var af;
@@ -1,13 +1,7 @@
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(3,12): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(5,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(6,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(9,14): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(10,14): error TS2367: No best common type exists between 'V' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(13,14): error TS2367: No best common type exists between 'V' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts(14,14): error TS2367: No best common type exists between 'U' and 'V'.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts (7 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints3.ts (1 errors) ====
// checking whether other types are subtypes of type parameters with constraints
function f<T extends U, U, V>(t: T, u: U, v: V) {
@@ -15,25 +9,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
// ok
var r = true ? t : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? u : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
// error
// ok
var r2 = true ? t : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
var r2 = true ? v : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
// error
// ok
var r3 = true ? v : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'U'.
var r3 = true ? u : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'V'.
}
@@ -6,11 +6,11 @@ function f<T extends U, U, V>(t: T, u: U, v: V) {
var r = true ? t : u;
var r = true ? u : t;
// error
// ok
var r2 = true ? t : v;
var r2 = true ? v : t;
// error
// ok
var r3 = true ? v : u;
var r3 = true ? u : v;
}
@@ -21,10 +21,10 @@ function f(t, u, v) {
// ok
var r = true ? t : u;
var r = true ? u : t;
// error
// ok
var r2 = true ? t : v;
var r2 = true ? v : t;
// error
// ok
var r3 = true ? v : u;
var r3 = true ? u : v;
}
@@ -1,11 +1,3 @@
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(6,13): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(7,13): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(10,14): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(11,14): error TS2367: No best common type exists between 'V' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(14,14): error TS2367: No best common type exists between 'V' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(15,14): error TS2367: No best common type exists between 'U' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(26,14): error TS2367: No best common type exists between 'V' and 'Foo'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(27,14): error TS2367: No best common type exists between 'Foo' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(45,7): error TS2416: Class 'D3<T, U, V>' incorrectly extends base class 'B1<Foo>':
Types of property 'foo' are incompatible:
Type 'V' is not assignable to type 'Foo':
@@ -29,34 +21,22 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (18 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (10 errors) ====
// checking whether other types are subtypes of type parameters with constraints
class Foo { foo: number; }
function f<T extends Foo, U extends Foo, V>(t: T, u: U, v: V) {
// error
// ok
var r = true ? t : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r = true ? u : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
// error
// ok
var r2 = true ? t : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
var r2 = true ? v : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
// error
// ok
var r3 = true ? v : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'U'.
var r3 = true ? u : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'V'.
// ok
var r4 = true ? t : new Foo();
@@ -66,13 +46,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
var r5 = true ? u : new Foo();
var r5 = true ? new Foo() : u;
// BUG, should be error
// ok
var r6 = true ? v : new Foo();
~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'Foo'.
var r6 = true ? new Foo() : v;
~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo' and 'V'.
}
@@ -3,15 +3,15 @@
class Foo { foo: number; }
function f<T extends Foo, U extends Foo, V>(t: T, u: U, v: V) {
// error
// ok
var r = true ? t : u;
var r = true ? u : t;
// error
// ok
var r2 = true ? t : v;
var r2 = true ? v : t;
// error
// ok
var r3 = true ? v : u;
var r3 = true ? u : v;
@@ -23,7 +23,7 @@ function f<T extends Foo, U extends Foo, V>(t: T, u: U, v: V) {
var r5 = true ? u : new Foo();
var r5 = true ? new Foo() : u;
// BUG, should be error
// ok
var r6 = true ? v : new Foo();
var r6 = true ? new Foo() : v;
@@ -92,13 +92,13 @@ var Foo = (function () {
return Foo;
})();
function f(t, u, v) {
// error
// ok
var r = true ? t : u;
var r = true ? u : t;
// error
// ok
var r2 = true ? t : v;
var r2 = true ? v : t;
// error
// ok
var r3 = true ? v : u;
var r3 = true ? u : v;
// ok
@@ -107,7 +107,7 @@ function f(t, u, v) {
// ok
var r5 = true ? u : new Foo();
var r5 = true ? new Foo() : u;
// BUG, should be error
// ok
var r6 = true ? v : new Foo();
var r6 = true ? new Foo() : v;
}
@@ -1,30 +1,6 @@
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(4,12): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(4,30): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(4,48): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(6,14): error TS2367: No best common type exists between 'T' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(7,14): error TS2367: No best common type exists between 'U' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(10,14): error TS2367: No best common type exists between 'T' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(11,14): error TS2367: No best common type exists between 'V' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(14,14): error TS2367: No best common type exists between 'V' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(15,14): error TS2367: No best common type exists between 'U' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(18,14): error TS2367: No best common type exists between 'T' and 'Foo<T>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(19,14): error TS2367: No best common type exists between 'Foo<T>' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(22,14): error TS2367: No best common type exists between 'U' and 'Foo<T>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(23,14): error TS2367: No best common type exists between 'Foo<T>' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(26,14): error TS2367: No best common type exists between 'V' and 'Foo<T>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(27,14): error TS2367: No best common type exists between 'Foo<T>' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(31,14): error TS2367: No best common type exists between 'T' and 'Foo<U>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(32,14): error TS2367: No best common type exists between 'Foo<U>' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(35,14): error TS2367: No best common type exists between 'U' and 'Foo<U>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(36,14): error TS2367: No best common type exists between 'Foo<U>' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(39,14): error TS2367: No best common type exists between 'V' and 'Foo<U>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(40,14): error TS2367: No best common type exists between 'Foo<U>' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(44,15): error TS2367: No best common type exists between 'T' and 'Foo<V>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(45,15): error TS2367: No best common type exists between 'Foo<V>' and 'T'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(48,15): error TS2367: No best common type exists between 'U' and 'Foo<V>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(49,15): error TS2367: No best common type exists between 'Foo<V>' and 'U'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(52,15): error TS2367: No best common type exists between 'V' and 'Foo<V>'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(53,15): error TS2367: No best common type exists between 'Foo<V>' and 'V'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(61,14): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(61,32): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(61,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
@@ -111,7 +87,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(153,50): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (99 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (75 errors) ====
// checking whether other types are subtypes of type parameters with constraints
class Foo<T> { foo: T; }
@@ -122,103 +98,55 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
~~~~~~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
// error
// ok
var r1 = true ? t : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'U'.
var r1 = true ? u : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'T'.
// error
// ok
var r2 = true ? t : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'V'.
var r2 = true ? v : t;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'T'.
// error
// ok
var r3 = true ? v : u;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'U'.
var r3 = true ? u : v;
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'V'.
// ok?
// ok
var r4 = true ? t : new Foo<T>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'Foo<T>'.
var r4 = true ? new Foo<T>() : t;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<T>' and 'T'.
// ok?
// ok
var r5 = true ? u : new Foo<T>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'Foo<T>'.
var r5 = true ? new Foo<T>() : u;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<T>' and 'U'.
// ok?
// ok
var r6 = true ? v : new Foo<T>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'Foo<T>'.
var r6 = true ? new Foo<T>() : v;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<T>' and 'V'.
// ok?
// ok
var r7 = true ? t : new Foo<U>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'Foo<U>'.
var r7 = true ? new Foo<U>() : t;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<U>' and 'T'.
// ok?
// ok
var r8 = true ? u : new Foo<U>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'Foo<U>'.
var r8 = true ? new Foo<U>() : u;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<U>' and 'U'.
// ok?
// ok
var r9 = true ? v : new Foo<U>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'Foo<U>'.
var r9 = true ? new Foo<U>() : v;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<U>' and 'V'.
// ok?
// ok
var r10 = true ? t : new Foo<V>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'T' and 'Foo<V>'.
var r10 = true ? new Foo<V>() : t;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<V>' and 'T'.
// ok?
// ok
var r11 = true ? u : new Foo<V>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'U' and 'Foo<V>'.
var r11 = true ? new Foo<V>() : u;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<V>' and 'U'.
// ok?
// ok
var r12 = true ? v : new Foo<V>();
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'V' and 'Foo<V>'.
var r12 = true ? new Foo<V>() : v;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2367: No best common type exists between 'Foo<V>' and 'V'.
}
module M1 {
@@ -3,53 +3,53 @@
class Foo<T> { foo: T; }
function f<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>>(t: T, u: U, v: V) {
// error
// ok
var r1 = true ? t : u;
var r1 = true ? u : t;
// error
// ok
var r2 = true ? t : v;
var r2 = true ? v : t;
// error
// ok
var r3 = true ? v : u;
var r3 = true ? u : v;
// ok?
// ok
var r4 = true ? t : new Foo<T>();
var r4 = true ? new Foo<T>() : t;
// ok?
// ok
var r5 = true ? u : new Foo<T>();
var r5 = true ? new Foo<T>() : u;
// ok?
// ok
var r6 = true ? v : new Foo<T>();
var r6 = true ? new Foo<T>() : v;
// ok?
// ok
var r7 = true ? t : new Foo<U>();
var r7 = true ? new Foo<U>() : t;
// ok?
// ok
var r8 = true ? u : new Foo<U>();
var r8 = true ? new Foo<U>() : u;
// ok?
// ok
var r9 = true ? v : new Foo<U>();
var r9 = true ? new Foo<U>() : v;
// ok?
// ok
var r10 = true ? t : new Foo<V>();
var r10 = true ? new Foo<V>() : t;
// ok?
// ok
var r11 = true ? u : new Foo<V>();
var r11 = true ? new Foo<V>() : u;
// ok?
// ok
var r12 = true ? v : new Foo<V>();
var r12 = true ? new Foo<V>() : v;
}
@@ -171,40 +171,40 @@ var Foo = (function () {
return Foo;
})();
function f(t, u, v) {
// error
// ok
var r1 = true ? t : u;
var r1 = true ? u : t;
// error
// ok
var r2 = true ? t : v;
var r2 = true ? v : t;
// error
// ok
var r3 = true ? v : u;
var r3 = true ? u : v;
// ok?
// ok
var r4 = true ? t : new Foo();
var r4 = true ? new Foo() : t;
// ok?
// ok
var r5 = true ? u : new Foo();
var r5 = true ? new Foo() : u;
// ok?
// ok
var r6 = true ? v : new Foo();
var r6 = true ? new Foo() : v;
// ok?
// ok
var r7 = true ? t : new Foo();
var r7 = true ? new Foo() : t;
// ok?
// ok
var r8 = true ? u : new Foo();
var r8 = true ? new Foo() : u;
// ok?
// ok
var r9 = true ? v : new Foo();
var r9 = true ? new Foo() : v;
// ok?
// ok
var r10 = true ? t : new Foo();
var r10 = true ? new Foo() : t;
// ok?
// ok
var r11 = true ? u : new Foo();
var r11 = true ? new Foo() : u;
// ok?
// ok
var r12 = true ? v : new Foo();
var r12 = true ? new Foo() : v;
}
@@ -368,8 +368,8 @@ var r2a = [r2arg1, r2arg2];
>r2arg2 : (x: number) => string[]
var r2b = [r2arg2, r2arg1];
>r2b : { (x: number): string[]; }[]
>[r2arg2, r2arg1] : { (x: number): string[]; }[]
>r2b : { <T>(x: T): string[]; }[]
>[r2arg2, r2arg1] : { <T>(x: T): string[]; }[]
>r2arg2 : (x: number) => string[]
>r2arg1 : <T>(x: T) => string[]
@@ -399,8 +399,8 @@ var r3a = [r3arg1, r3arg2];
>r3arg2 : (x: number) => void
var r3b = [r3arg2, r3arg1];
>r3b : { (x: number): void; }[]
>[r3arg2, r3arg1] : { (x: number): void; }[]
>r3b : { <T>(x: T): T; }[]
>[r3arg2, r3arg1] : { <T>(x: T): T; }[]
>r3arg2 : (x: number) => void
>r3arg1 : <T>(x: T) => T
@@ -795,8 +795,8 @@ var r12a = [r12arg1, r12arg2];
>r12arg2 : (x: Base[], y: Derived2[]) => Derived[]
var r12b = [r12arg2, r12arg1];
>r12b : { (x: Base[], y: Derived2[]): Derived[]; }[]
>[r12arg2, r12arg1] : { (x: Base[], y: Derived2[]): Derived[]; }[]
>r12b : { <T extends Base[]>(x: Base[], y: T): Derived[]; }[]
>[r12arg2, r12arg1] : { <T extends Base[]>(x: Base[], y: T): Derived[]; }[]
>r12arg2 : (x: Base[], y: Derived2[]) => Derived[]
>r12arg1 : <T extends Base[]>(x: Base[], y: T) => Derived[]
@@ -340,14 +340,14 @@ module Errors {
>r3arg : <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U
var r3a = [r3arg2, r3arg];
>r3a : {}[]
>[r3arg2, r3arg] : {}[]
>r3a : Array<{ <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }>
>[r3arg2, r3arg] : Array<{ <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }>
>r3arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
>r3arg : <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U
var r3b = [r3arg, r3arg2];
>r3b : {}[]
>[r3arg, r3arg2] : {}[]
>r3b : Array<{ <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }>
>[r3arg, r3arg2] : Array<{ <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U): (r: T) => U; } | { (x: (arg: Base) => Derived, y: (arg2: Base) => Derived): (r: Base) => Derived; }>
>r3arg : <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U
>r3arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
@@ -535,8 +535,8 @@ module Errors {
>r7arg3 : <T extends Base>(x: { a: T; b: T; }) => number
var r7e = [r7arg3, r7arg2];
>r7e : { <T extends Base>(x: { a: T; b: T; }): number; }[]
>[r7arg3, r7arg2] : { <T extends Base>(x: { a: T; b: T; }): number; }[]
>r7e : { (x: { a: string; b: number; }): number; }[]
>[r7arg3, r7arg2] : { (x: { a: string; b: number; }): number; }[]
>r7arg3 : <T extends Base>(x: { a: T; b: T; }) => number
>r7arg2 : (x: { a: string; b: number; }) => number
@@ -318,8 +318,8 @@ var r3a = [r3arg, r3arg2];
>r3arg2 : <T>(x: T) => void
var r3b = [r3arg2, r3arg];
>r3b : { <T>(x: T): void; }[]
>[r3arg2, r3arg] : { <T>(x: T): void; }[]
>r3b : { <T>(x: T): T; }[]
>[r3arg2, r3arg] : { <T>(x: T): T; }[]
>r3arg2 : <T>(x: T) => void
>r3arg : <T>(x: T) => T
@@ -442,8 +442,8 @@ var r6a = [r6arg, r6arg2];
>r6arg2 : <T extends Base>(x: (arg: T) => Derived) => T
var r6b = [r6arg2, r6arg];
>r6b : { <T extends Base>(x: (arg: T) => Derived): T; }[]
>[r6arg2, r6arg] : { <T extends Base>(x: (arg: T) => Derived): T; }[]
>r6b : { <T extends Base, U extends Derived>(x: (arg: T) => U): T; }[]
>[r6arg2, r6arg] : { <T extends Base, U extends Derived>(x: (arg: T) => U): T; }[]
>r6arg2 : <T extends Base>(x: (arg: T) => Derived) => T
>r6arg : <T extends Base, U extends Derived>(x: (arg: T) => U) => T
@@ -491,8 +491,8 @@ var r11a = [r11arg, r11arg2];
>r11arg2 : <T>(x: { foo: T; }, y: { foo: T; bar: T; }) => Base
var r11b = [r11arg2, r11arg];
>r11b : { <T>(x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[]
>[r11arg2, r11arg] : { <T>(x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[]
>r11b : { <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[]
>[r11arg2, r11arg] : { <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[]
>r11arg2 : <T>(x: { foo: T; }, y: { foo: T; bar: T; }) => Base
>r11arg : <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }) => Base
@@ -534,8 +534,8 @@ var r15a = [r15arg, r15arg2];
>r15arg2 : <T>(x: { a: T; b: T; }) => T[]
var r15b = [r15arg2, r15arg];
>r15b : { <T>(x: { a: T; b: T; }): T[]; }[]
>[r15arg2, r15arg] : { <T>(x: { a: T; b: T; }): T[]; }[]
>r15b : { <U, V>(x: { a: U; b: V; }): U[]; }[]
>[r15arg2, r15arg] : { <U, V>(x: { a: U; b: V; }): U[]; }[]
>r15arg2 : <T>(x: { a: T; b: T; }) => T[]
>r15arg : <U, V>(x: { a: U; b: V; }) => U[]
@@ -360,8 +360,8 @@ var r2a = [r2arg1, r2arg2];
>r2arg2 : new (x: number) => string[]
var r2b = [r2arg2, r2arg1];
>r2b : { new (x: number): string[]; }[]
>[r2arg2, r2arg1] : { new (x: number): string[]; }[]
>r2b : { new <T>(x: T): string[]; }[]
>[r2arg2, r2arg1] : { new <T>(x: T): string[]; }[]
>r2arg2 : new (x: number) => string[]
>r2arg1 : new <T>(x: T) => string[]
@@ -389,8 +389,8 @@ var r3a = [r3arg1, r3arg2];
>r3arg2 : new (x: number) => void
var r3b = [r3arg2, r3arg1];
>r3b : { new (x: number): void; }[]
>[r3arg2, r3arg1] : { new (x: number): void; }[]
>r3b : { new <T>(x: T): T; }[]
>[r3arg2, r3arg1] : { new <T>(x: T): T; }[]
>r3arg2 : new (x: number) => void
>r3arg1 : new <T>(x: T) => T
@@ -630,14 +630,14 @@ var r9 = foo9(r9arg1); // any
>r9arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U
var r9a = [r9arg1, r9arg2];
>r9a : {}[]
>[r9arg1, r9arg2] : {}[]
>r9a : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>[r9arg1, r9arg2] : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>r9arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U
>r9arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived
var r9b = [r9arg2, r9arg1];
>r9b : {}[]
>[r9arg2, r9arg1] : {}[]
>r9b : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>[r9arg2, r9arg1] : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U): new (r: T) => U; } | { new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>r9arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived
>r9arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => new (r: T) => U
@@ -747,8 +747,8 @@ var r12a = [r12arg1, r12arg2];
>r12arg2 : new (x: Base[], y: Derived2[]) => Derived[]
var r12b = [r12arg2, r12arg1];
>r12b : { new (x: Base[], y: Derived2[]): Derived[]; }[]
>[r12arg2, r12arg1] : { new (x: Base[], y: Derived2[]): Derived[]; }[]
>r12b : { new <T extends Base[]>(x: Base[], y: T): Derived[]; }[]
>[r12arg2, r12arg1] : { new <T extends Base[]>(x: Base[], y: T): Derived[]; }[]
>r12arg2 : new (x: Base[], y: Derived2[]) => Derived[]
>r12arg1 : new <T extends Base[]>(x: Base[], y: T) => Derived[]
@@ -318,14 +318,14 @@ module Errors {
>r3arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U
var r3a = [r3arg2, r3arg1];
>r3a : {}[]
>[r3arg2, r3arg1] : {}[]
>r3a : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>[r3arg2, r3arg1] : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>r3arg2 : new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived
>r3arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U
var r3b = [r3arg1, r3arg2];
>r3b : {}[]
>[r3arg1, r3arg2] : {}[]
>r3b : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>[r3arg1, r3arg2] : Array<{ new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U): new (r: T) => U; } | { new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived): new (r: Base) => Derived; }>
>r3arg1 : new <T extends Base, U extends Derived>(x: new (arg: T) => U, y: (arg2: { foo: number; }) => U) => new (r: T) => U
>r3arg2 : new (x: (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived
@@ -497,8 +497,8 @@ module Errors {
>r7arg3 : new <T extends Base>(x: { a: T; b: T; }) => number
var r7e = [r7arg3, r7arg2];
>r7e : { new <T extends Base>(x: { a: T; b: T; }): number; }[]
>[r7arg3, r7arg2] : { new <T extends Base>(x: { a: T; b: T; }): number; }[]
>r7e : { new (x: { a: string; b: number; }): number; }[]
>[r7arg3, r7arg2] : { new (x: { a: string; b: number; }): number; }[]
>r7arg3 : new <T extends Base>(x: { a: T; b: T; }) => number
>r7arg2 : new (x: { a: string; b: number; }) => number
@@ -307,8 +307,8 @@ var r3a = [r3arg, r3arg2];
>r3arg2 : new <T>(x: T) => void
var r3b = [r3arg2, r3arg];
>r3b : { new <T>(x: T): void; }[]
>[r3arg2, r3arg] : { new <T>(x: T): void; }[]
>r3b : { new <T>(x: T): T; }[]
>[r3arg2, r3arg] : { new <T>(x: T): T; }[]
>r3arg2 : new <T>(x: T) => void
>r3arg : new <T>(x: T) => T
@@ -421,8 +421,8 @@ var r6a = [r6arg, r6arg2];
>r6arg2 : new <T extends Base>(x: new (arg: T) => Derived) => T
var r6b = [r6arg2, r6arg];
>r6b : { new <T extends Base>(x: new (arg: T) => Derived): T; }[]
>[r6arg2, r6arg] : { new <T extends Base>(x: new (arg: T) => Derived): T; }[]
>r6b : { new <T extends Base, U extends Derived>(x: new (arg: T) => U): T; }[]
>[r6arg2, r6arg] : { new <T extends Base, U extends Derived>(x: new (arg: T) => U): T; }[]
>r6arg2 : new <T extends Base>(x: new (arg: T) => Derived) => T
>r6arg : new <T extends Base, U extends Derived>(x: new (arg: T) => U) => T
@@ -466,8 +466,8 @@ var r11a = [r11arg, r11arg2];
>r11arg2 : new <T>(x: { foo: T; }, y: { foo: T; bar: T; }) => Base
var r11b = [r11arg2, r11arg];
>r11b : { new <T>(x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[]
>[r11arg2, r11arg] : { new <T>(x: { foo: T; }, y: { foo: T; bar: T; }): Base; }[]
>r11b : { new <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[]
>[r11arg2, r11arg] : { new <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }): Base; }[]
>r11arg2 : new <T>(x: { foo: T; }, y: { foo: T; bar: T; }) => Base
>r11arg : new <T, U>(x: { foo: T; }, y: { foo: U; bar: U; }) => Base
@@ -505,8 +505,8 @@ var r15a = [r15arg, r15arg2];
>r15arg2 : new <T>(x: { a: T; b: T; }) => T[]
var r15b = [r15arg2, r15arg];
>r15b : { new <T>(x: { a: T; b: T; }): T[]; }[]
>[r15arg2, r15arg] : { new <T>(x: { a: T; b: T; }): T[]; }[]
>r15b : { new <U, V>(x: { a: U; b: V; }): U[]; }[]
>[r15arg2, r15arg] : { new <U, V>(x: { a: U; b: V; }): U[]; }[]
>r15arg2 : new <T>(x: { a: T; b: T; }) => T[]
>r15arg : new <U, V>(x: { a: U; b: V; }) => U[]
@@ -4,10 +4,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
Property '1' is optional in type 'S2' but required in type 'T2'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(26,11): error TS2429: Interface 'S3' incorrectly extends interface 'T3':
Property ''1'' is optional in type 'S3' but required in type 'T3'.
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(33,9): error TS2367: No best common type exists between '{ Foo: Base; }' and '{ Foo?: Derived; }'.
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts (4 errors) ====
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts (3 errors) ====
// Derived member is optional but base member is not, should be an error
interface Base { foo: string; }
@@ -49,6 +48,4 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
// object literal case
var a: { Foo: Base; }
var b: { Foo?: Derived; }
var r = true ? a : b; // error
~~~~~~~~~~~~
!!! error TS2367: No best common type exists between '{ Foo: Base; }' and '{ Foo?: Derived; }'.
var r = true ? a : b; // ok
@@ -31,11 +31,11 @@ interface S3 extends T3 {
// object literal case
var a: { Foo: Base; }
var b: { Foo?: Derived; }
var r = true ? a : b; // error
var r = true ? a : b; // ok
//// [subtypingWithObjectMembersOptionality2.js]
// Derived member is optional but base member is not, should be an error
// object literal case
var a;
var b;
var r = true ? a : b; // error
var r = true ? a : b; // ok
@@ -1,5 +1,6 @@
tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type '{}[]' is not assignable to type 'string[]':
Type '{}' is not assignable to type 'string'.
tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type 'Array<string | number>' is not assignable to type 'string[]':
Type 'string | number' is not assignable to type 'string':
Type 'number' is not assignable to type 'string'.
==== tests/cases/compiler/targetTypeTest3.ts (1 errors) ====
@@ -8,8 +9,9 @@ tests/cases/compiler/targetTypeTest3.ts(4,5): error TS2322: Type '{}[]' is not a
var a : string[] = [1,2,"3"]; // should produce an error
~
!!! error TS2322: Type '{}[]' is not assignable to type 'string[]':
!!! error TS2322: Type '{}' is not assignable to type 'string'.
!!! error TS2322: Type 'Array<string | number>' is not assignable to type 'string[]':
!!! error TS2322: Type 'string | number' is not assignable to type 'string':
!!! error TS2322: Type 'number' is not assignable to type 'string'.
function func1(stuff:any[]) { return stuff; }
@@ -219,7 +219,7 @@ throw [];
>[] : undefined[]
throw ['a', ['b']];
>['a', ['b']] : {}[]
>['a', ['b']] : Array<string | string[]>
>['b'] : string[]
throw /[a-z]/;
@@ -1,7 +1,9 @@
tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(5,19): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
Type '{}' is not assignable to type 'number'.
tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
Type '{}' is not assignable to type 'number'.
tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(5,19): error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
Type 'string | number' is not assignable to type 'number':
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
Type 'string | number' is not assignable to type 'number':
Type 'string' is not assignable to type 'number'.
==== tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts (2 errors) ====
@@ -11,12 +13,14 @@ tests/cases/compiler/trailingCommaInHeterogenousArrayLiteral1.ts(6,19): error TS
// these two should give the same error
this.test([1, 2, "hi", 5, ]);
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type '{}' is not assignable to type 'number'.
!!! error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type 'string | number' is not assignable to type 'number':
!!! error TS2345: Type 'string' is not assignable to type 'number'.
this.test([1, 2, "hi", 5]);
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{}[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type '{}' is not assignable to type 'number'.
!!! error TS2345: Argument of type 'Array<string | number>' is not assignable to parameter of type 'number[]'.
!!! error TS2345: Type 'string | number' is not assignable to type 'number':
!!! error TS2345: Type 'string' is not assignable to type 'number'.
}
}
+16 -14
View File
@@ -1,16 +1,17 @@
tests/cases/compiler/tupleTypes.ts(1,9): error TS1122: A tuple type element list cannot be empty.
tests/cases/compiler/tupleTypes.ts(14,1): error TS2322: Type '{}[]' is not assignable to type '[number, string]':
Property '0' is missing in type '{}[]'.
tests/cases/compiler/tupleTypes.ts(14,1): error TS2322: Type 'Array<string | number>' is not assignable to type '[number, string]':
Property '0' is missing in type 'Array<string | number>'.
tests/cases/compiler/tupleTypes.ts(15,1): error TS2322: Type '[number]' is not assignable to type '[number, string]':
Property '1' is missing in type '[number]'.
tests/cases/compiler/tupleTypes.ts(17,1): error TS2322: Type '[string, number]' is not assignable to type '[number, string]':
Types of property '0' are incompatible:
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/tupleTypes.ts(41,1): error TS2323: Type '{}[]' is not assignable to type '[number, string]'.
tests/cases/compiler/tupleTypes.ts(41,1): error TS2323: Type 'Array<string | number>' is not assignable to type '[number, string]'.
tests/cases/compiler/tupleTypes.ts(47,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]':
Types of property 'pop' are incompatible:
Type '() => {}' is not assignable to type '() => number':
Type '{}' is not assignable to type 'number'.
Type '() => string | number' is not assignable to type '() => number':
Type 'string | number' is not assignable to type 'number':
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/tupleTypes.ts(49,1): error TS2322: Type '[number, {}]' is not assignable to type 'number[]':
Types of property 'pop' are incompatible:
Type '() => {}' is not assignable to type '() => number':
@@ -36,13 +37,13 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
var t0: number;
var t1 = t[1]; // string
var t1: string;
var t2 = t[2]; // {}
var t2: {};
var t2 = t[2]; // number|string
var t2: number|string;
t = []; // Error
~
!!! error TS2322: Type '{}[]' is not assignable to type '[number, string]':
!!! error TS2322: Property '0' is missing in type '{}[]'.
!!! error TS2322: Type 'Array<string | number>' is not assignable to type '[number, string]':
!!! error TS2322: Property '0' is missing in type 'Array<string | number>'.
t = [1]; // Error
~
!!! error TS2322: Type '[number]' is not assignable to type '[number, string]':
@@ -70,15 +71,15 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
var tt0: number;
var tt1 = tt[1];
var tt1: string;
var tt2 = tt[2];
var tt2: {};
var tt2 = tt[2];
var tt2: number | string;
tt = tuple2(1, undefined);
tt = [1, undefined];
tt = [undefined, undefined];
tt = []; // Error
~~
!!! error TS2323: Type '{}[]' is not assignable to type '[number, string]'.
!!! error TS2323: Type 'Array<string | number>' is not assignable to type '[number, string]'.
var a: number[];
var a1: [number, string];
@@ -88,8 +89,9 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n
~
!!! error TS2322: Type '[number, string]' is not assignable to type 'number[]':
!!! error TS2322: Types of property 'pop' are incompatible:
!!! error TS2322: Type '() => {}' is not assignable to type '() => number':
!!! error TS2322: Type '{}' is not assignable to type 'number'.
!!! error TS2322: Type '() => string | number' is not assignable to type '() => number':
!!! error TS2322: Type 'string | number' is not assignable to type 'number':
!!! error TS2322: Type 'string' is not assignable to type 'number'.
a = a2;
a = a3; // Error
~

Some files were not shown because too many files have changed in this diff Show More