mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into disambiguating
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'string | number' is not an array type.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'number | string' is not an array type.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,7): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
@@ -8,7 +8,7 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error
|
||||
var tuple: [number, string] = [2, "3"];
|
||||
for ([a = 1, b = ""] of tuple) {
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2461: Type 'string | number' is not an array type.
|
||||
!!! error TS2461: Type 'number | string' is not an array type.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts(3,6): error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts(3,6): error TS2322: Type 'number | string' is not assignable to type 'string'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts(3,6)
|
||||
var v: string;
|
||||
for (v of union) { }
|
||||
~
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'number | string' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
@@ -3,6 +3,6 @@ var union: string | number[];
|
||||
>union : string | number[]
|
||||
|
||||
for (var v of union) { }
|
||||
>v : string | number
|
||||
>v : number | string
|
||||
>union : string | number[]
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts(2,15): error TS2461: Type 'number | symbol | string[]' is not an array type.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts(2,15): error TS2461: Type 'string[] | number | symbol' is not an array type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts (1 errors) ====
|
||||
var union: string | string[] | number | symbol;
|
||||
for (let v of union) { }
|
||||
~~~~~
|
||||
!!! error TS2461: Type 'number | symbol | string[]' is not an array type.
|
||||
!!! error TS2461: Type 'string[] | number | symbol' is not an array type.
|
||||
@@ -6,14 +6,14 @@ enum Color { R, G, B }
|
||||
>B : Color
|
||||
|
||||
function f1(x: Color | string) {
|
||||
>f1 : (x: string | Color) => void
|
||||
>x : string | Color
|
||||
>f1 : (x: Color | string) => void
|
||||
>x : Color | string
|
||||
>Color : Color
|
||||
|
||||
if (typeof x === "number") {
|
||||
>typeof x === "number" : boolean
|
||||
>typeof x : string
|
||||
>x : string | Color
|
||||
>x : Color | string
|
||||
>"number" : string
|
||||
|
||||
var y = x;
|
||||
@@ -35,14 +35,14 @@ function f1(x: Color | string) {
|
||||
}
|
||||
|
||||
function f2(x: Color | string | string[]) {
|
||||
>f2 : (x: string | Color | string[]) => void
|
||||
>x : string | Color | string[]
|
||||
>f2 : (x: Color | string | string[]) => void
|
||||
>x : Color | string | string[]
|
||||
>Color : Color
|
||||
|
||||
if (typeof x === "object") {
|
||||
>typeof x === "object" : boolean
|
||||
>typeof x : string
|
||||
>x : string | Color | string[]
|
||||
>x : Color | string | string[]
|
||||
>"object" : string
|
||||
|
||||
var y = x;
|
||||
@@ -55,7 +55,7 @@ function f2(x: Color | string | string[]) {
|
||||
if (typeof x === "number") {
|
||||
>typeof x === "number" : boolean
|
||||
>typeof x : string
|
||||
>x : string | Color | string[]
|
||||
>x : Color | string | string[]
|
||||
>"number" : string
|
||||
|
||||
var z = x;
|
||||
@@ -77,7 +77,7 @@ function f2(x: Color | string | string[]) {
|
||||
if (typeof x === "string") {
|
||||
>typeof x === "string" : boolean
|
||||
>typeof x : string
|
||||
>x : string | Color | string[]
|
||||
>x : Color | string | string[]
|
||||
>"string" : string
|
||||
|
||||
var a = x;
|
||||
|
||||
@@ -34,7 +34,7 @@ var d2: IHasVisualizationModel = i || moduleA;
|
||||
var d2: IHasVisualizationModel = moduleA || i;
|
||||
>d2 : IHasVisualizationModel
|
||||
>IHasVisualizationModel : IHasVisualizationModel
|
||||
>moduleA || i : IHasVisualizationModel
|
||||
>moduleA || i : typeof moduleA
|
||||
>moduleA : typeof moduleA
|
||||
>i : IHasVisualizationModel
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
tests/cases/compiler/aliasesInSystemModule1.ts(2,24): error TS2307: Cannot find module 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/aliasesInSystemModule1.ts (1 errors) ====
|
||||
|
||||
import alias = require('foo');
|
||||
~~~~~
|
||||
!!! error TS2307: Cannot find module 'foo'.
|
||||
import cls = alias.Class;
|
||||
export import cls2 = alias.Class;
|
||||
|
||||
let x = new alias.Class();
|
||||
let y = new cls();
|
||||
let z = new cls2();
|
||||
|
||||
module M {
|
||||
export import cls = alias.Class;
|
||||
let x = new alias.Class();
|
||||
let y = new cls();
|
||||
let z = new cls2();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//// [aliasesInSystemModule1.ts]
|
||||
|
||||
import alias = require('foo');
|
||||
import cls = alias.Class;
|
||||
export import cls2 = alias.Class;
|
||||
|
||||
let x = new alias.Class();
|
||||
let y = new cls();
|
||||
let z = new cls2();
|
||||
|
||||
module M {
|
||||
export import cls = alias.Class;
|
||||
let x = new alias.Class();
|
||||
let y = new cls();
|
||||
let z = new cls2();
|
||||
}
|
||||
|
||||
|
||||
//// [aliasesInSystemModule1.js]
|
||||
System.register(['foo'], function(exports_1) {
|
||||
var alias;
|
||||
var cls, cls2, x, y, z, M;
|
||||
return {
|
||||
setters:[
|
||||
function (_alias) {
|
||||
alias = _alias;
|
||||
}],
|
||||
execute: function() {
|
||||
cls = alias.Class;
|
||||
exports_1("cls2", cls2 = alias.Class);
|
||||
x = new alias.Class();
|
||||
y = new cls();
|
||||
z = new cls2();
|
||||
(function (M) {
|
||||
M.cls = alias.Class;
|
||||
var x = new alias.Class();
|
||||
var y = new M.cls();
|
||||
var z = new cls2();
|
||||
})(M || (M = {}));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
tests/cases/compiler/aliasesInSystemModule2.ts(2,21): error TS2307: Cannot find module 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/aliasesInSystemModule2.ts (1 errors) ====
|
||||
|
||||
import {alias} from "foo";
|
||||
~~~~~
|
||||
!!! error TS2307: Cannot find module 'foo'.
|
||||
import cls = alias.Class;
|
||||
export import cls2 = alias.Class;
|
||||
|
||||
let x = new alias.Class();
|
||||
let y = new cls();
|
||||
let z = new cls2();
|
||||
|
||||
module M {
|
||||
export import cls = alias.Class;
|
||||
let x = new alias.Class();
|
||||
let y = new cls();
|
||||
let z = new cls2();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
//// [aliasesInSystemModule2.ts]
|
||||
|
||||
import {alias} from "foo";
|
||||
import cls = alias.Class;
|
||||
export import cls2 = alias.Class;
|
||||
|
||||
let x = new alias.Class();
|
||||
let y = new cls();
|
||||
let z = new cls2();
|
||||
|
||||
module M {
|
||||
export import cls = alias.Class;
|
||||
let x = new alias.Class();
|
||||
let y = new cls();
|
||||
let z = new cls2();
|
||||
}
|
||||
|
||||
//// [aliasesInSystemModule2.js]
|
||||
System.register(["foo"], function(exports_1) {
|
||||
var foo_1;
|
||||
var cls, cls2, x, y, z, M;
|
||||
return {
|
||||
setters:[
|
||||
function (_foo_1) {
|
||||
foo_1 = _foo_1;
|
||||
}],
|
||||
execute: function() {
|
||||
cls = foo_1.alias.Class;
|
||||
exports_1("cls2", cls2 = foo_1.alias.Class);
|
||||
x = new foo_1.alias.Class();
|
||||
y = new cls();
|
||||
z = new cls2();
|
||||
(function (M) {
|
||||
M.cls = foo_1.alias.Class;
|
||||
var x = new foo_1.alias.Class();
|
||||
var y = new M.cls();
|
||||
var z = new cls2();
|
||||
})(M || (M = {}));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -294,8 +294,8 @@ module EmptyTypes {
|
||||
|
||||
// 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; }[]
|
||||
>a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
|
||||
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
|
||||
>{ x: 0, y: 'a' } : { x: number; y: string; }
|
||||
>x : number
|
||||
>0 : number
|
||||
@@ -313,8 +313,8 @@ module EmptyTypes {
|
||||
>'a' : 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; }[]
|
||||
>a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
|
||||
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
|
||||
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
|
||||
>x : any
|
||||
>anyObj : any
|
||||
@@ -332,8 +332,8 @@ module EmptyTypes {
|
||||
>'a' : 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; }[]
|
||||
>a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
|
||||
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
|
||||
>{ x: 0, y: 'a' } : { x: number; y: string; }
|
||||
>x : number
|
||||
>0 : number
|
||||
@@ -366,22 +366,22 @@ module EmptyTypes {
|
||||
>base2 : typeof base2
|
||||
|
||||
var b1 = [baseObj, base2Obj, ifaceObj];
|
||||
>b1 : iface[]
|
||||
>[baseObj, base2Obj, ifaceObj] : iface[]
|
||||
>b1 : base[]
|
||||
>[baseObj, base2Obj, ifaceObj] : base[]
|
||||
>baseObj : base
|
||||
>base2Obj : base2
|
||||
>ifaceObj : iface
|
||||
|
||||
var b2 = [base2Obj, baseObj, ifaceObj];
|
||||
>b2 : iface[]
|
||||
>[base2Obj, baseObj, ifaceObj] : iface[]
|
||||
>b2 : base2[]
|
||||
>[base2Obj, baseObj, ifaceObj] : base2[]
|
||||
>base2Obj : base2
|
||||
>baseObj : base
|
||||
>ifaceObj : iface
|
||||
|
||||
var b3 = [baseObj, ifaceObj, base2Obj];
|
||||
>b3 : iface[]
|
||||
>[baseObj, ifaceObj, base2Obj] : iface[]
|
||||
>b3 : base[]
|
||||
>[baseObj, ifaceObj, base2Obj] : base[]
|
||||
>baseObj : base
|
||||
>ifaceObj : iface
|
||||
>base2Obj : base2
|
||||
@@ -639,7 +639,7 @@ module NonEmptyTypes {
|
||||
>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: derived; } | { x: number; y: base; })[]
|
||||
>{ x: 7, y: new derived() } : { x: number; y: derived; }
|
||||
>x : number
|
||||
>7 : number
|
||||
@@ -658,7 +658,7 @@ module NonEmptyTypes {
|
||||
>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: derived; } | { x: boolean; y: base; })[]
|
||||
>{ x: true, y: new derived() } : { x: boolean; y: derived; }
|
||||
>x : boolean
|
||||
>true : boolean
|
||||
@@ -697,8 +697,8 @@ module NonEmptyTypes {
|
||||
|
||||
// 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; }[]
|
||||
>a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
|
||||
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
|
||||
>{ x: 0, y: 'a' } : { x: number; y: string; }
|
||||
>x : number
|
||||
>0 : number
|
||||
@@ -716,8 +716,8 @@ module NonEmptyTypes {
|
||||
>'a' : 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; }[]
|
||||
>a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
|
||||
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
|
||||
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
|
||||
>x : any
|
||||
>anyObj : any
|
||||
@@ -735,8 +735,8 @@ module NonEmptyTypes {
|
||||
>'a' : 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; }[]
|
||||
>a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
|
||||
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
|
||||
>{ x: 0, y: 'a' } : { x: number; y: string; }
|
||||
>x : number
|
||||
>0 : number
|
||||
@@ -769,29 +769,29 @@ module NonEmptyTypes {
|
||||
>base2 : typeof base2
|
||||
|
||||
var b1 = [baseObj, base2Obj, ifaceObj];
|
||||
>b1 : iface[]
|
||||
>[baseObj, base2Obj, ifaceObj] : iface[]
|
||||
>b1 : (base | base2 | iface)[]
|
||||
>[baseObj, base2Obj, ifaceObj] : (base | base2 | iface)[]
|
||||
>baseObj : base
|
||||
>base2Obj : base2
|
||||
>ifaceObj : iface
|
||||
|
||||
var b2 = [base2Obj, baseObj, ifaceObj];
|
||||
>b2 : iface[]
|
||||
>[base2Obj, baseObj, ifaceObj] : iface[]
|
||||
>b2 : (base2 | base | iface)[]
|
||||
>[base2Obj, baseObj, ifaceObj] : (base2 | base | iface)[]
|
||||
>base2Obj : base2
|
||||
>baseObj : base
|
||||
>ifaceObj : iface
|
||||
|
||||
var b3 = [baseObj, ifaceObj, base2Obj];
|
||||
>b3 : iface[]
|
||||
>[baseObj, ifaceObj, base2Obj] : iface[]
|
||||
>b3 : (base | iface | base2)[]
|
||||
>[baseObj, ifaceObj, base2Obj] : (base | iface | base2)[]
|
||||
>baseObj : base
|
||||
>ifaceObj : iface
|
||||
>base2Obj : base2
|
||||
|
||||
var b4 = [ifaceObj, baseObj, base2Obj];
|
||||
>b4 : iface[]
|
||||
>[ifaceObj, baseObj, base2Obj] : iface[]
|
||||
>b4 : (iface | base | base2)[]
|
||||
>[ifaceObj, baseObj, base2Obj] : (iface | base | base2)[]
|
||||
>ifaceObj : iface
|
||||
>baseObj : base
|
||||
>base2Obj : base2
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
|
||||
Type '{ foo: string; }' is not assignable to type '{ id: number; }'.
|
||||
Property 'id' is missing in type '{ foo: string; }'.
|
||||
Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/arrayCast.ts (1 errors) ====
|
||||
@@ -10,7 +10,7 @@ tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: strin
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
|
||||
!!! error TS2352: Type '{ foo: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2352: Property 'id' is missing in type '{ foo: string; }'.
|
||||
!!! error TS2352: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'.
|
||||
|
||||
// Should succeed, as the {} element causes the type of the array to be {}[]
|
||||
<{ id: number; }[]>[{ foo: "s" }, {}];
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(8,5): error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number' is not assignable to type '() => number'.
|
||||
Type 'string | number' is not assignable to type 'number'.
|
||||
Type '() => number | string' is not assignable to type '() => number'.
|
||||
Type 'number | string' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(14,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
|
||||
Property '0' is missing in type 'number[]'.
|
||||
@@ -19,8 +19,8 @@ tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionConte
|
||||
~~~~
|
||||
!!! error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! 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 '() => number | string' is not assignable to type '() => number'.
|
||||
!!! error TS2322: Type 'number | string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
// In a contextually typed array literal expression containing one or more spread elements,
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
tests/cases/compiler/arrayLiteralTypeInference.ts(13,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'.
|
||||
Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'.
|
||||
Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'.
|
||||
Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'.
|
||||
tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/arrayLiteralTypeInference.ts (2 errors) ====
|
||||
class Action {
|
||||
id: number;
|
||||
}
|
||||
|
||||
class ActionA extends Action {
|
||||
value: string;
|
||||
}
|
||||
|
||||
class ActionB extends Action {
|
||||
trueNess: boolean;
|
||||
}
|
||||
|
||||
var x1: Action[] = [
|
||||
~~
|
||||
!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'.
|
||||
!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'.
|
||||
!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'.
|
||||
{ id: 2, trueness: false },
|
||||
{ id: 3, name: "three" }
|
||||
]
|
||||
|
||||
var x2: Action[] = [
|
||||
new ActionA(),
|
||||
new ActionB()
|
||||
]
|
||||
|
||||
var x3: Action[] = [
|
||||
new Action(),
|
||||
new ActionA(),
|
||||
new ActionB()
|
||||
]
|
||||
|
||||
var z1: { id: number }[] =
|
||||
~~
|
||||
!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'.
|
||||
[
|
||||
{ id: 2, trueness: false },
|
||||
{ id: 3, name: "three" }
|
||||
]
|
||||
|
||||
var z2: { id: number }[] =
|
||||
[
|
||||
new ActionA(),
|
||||
new ActionB()
|
||||
]
|
||||
|
||||
var z3: { id: number }[] =
|
||||
[
|
||||
new Action(),
|
||||
new ActionA(),
|
||||
new ActionB()
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
=== tests/cases/compiler/arrayLiteralTypeInference.ts ===
|
||||
class Action {
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
id: number;
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 0, 14))
|
||||
}
|
||||
|
||||
class ActionA extends Action {
|
||||
>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1))
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
value: string;
|
||||
>value : Symbol(value, Decl(arrayLiteralTypeInference.ts, 4, 30))
|
||||
}
|
||||
|
||||
class ActionB extends Action {
|
||||
>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1))
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
trueNess: boolean;
|
||||
>trueNess : Symbol(trueNess, Decl(arrayLiteralTypeInference.ts, 8, 30))
|
||||
}
|
||||
|
||||
var x1: Action[] = [
|
||||
>x1 : Symbol(x1, Decl(arrayLiteralTypeInference.ts, 12, 3))
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
{ id: 2, trueness: false },
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 13, 5))
|
||||
>trueness : Symbol(trueness, Decl(arrayLiteralTypeInference.ts, 13, 12))
|
||||
|
||||
{ id: 3, name: "three" }
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 14, 5))
|
||||
>name : Symbol(name, Decl(arrayLiteralTypeInference.ts, 14, 12))
|
||||
|
||||
]
|
||||
|
||||
var x2: Action[] = [
|
||||
>x2 : Symbol(x2, Decl(arrayLiteralTypeInference.ts, 17, 3))
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
new ActionA(),
|
||||
>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1))
|
||||
|
||||
new ActionB()
|
||||
>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1))
|
||||
|
||||
]
|
||||
|
||||
var x3: Action[] = [
|
||||
>x3 : Symbol(x3, Decl(arrayLiteralTypeInference.ts, 22, 3))
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
new Action(),
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
new ActionA(),
|
||||
>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1))
|
||||
|
||||
new ActionB()
|
||||
>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1))
|
||||
|
||||
]
|
||||
|
||||
var z1: { id: number }[] =
|
||||
>z1 : Symbol(z1, Decl(arrayLiteralTypeInference.ts, 28, 3))
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 28, 9))
|
||||
|
||||
[
|
||||
{ id: 2, trueness: false },
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 30, 9))
|
||||
>trueness : Symbol(trueness, Decl(arrayLiteralTypeInference.ts, 30, 16))
|
||||
|
||||
{ id: 3, name: "three" }
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 31, 9))
|
||||
>name : Symbol(name, Decl(arrayLiteralTypeInference.ts, 31, 16))
|
||||
|
||||
]
|
||||
|
||||
var z2: { id: number }[] =
|
||||
>z2 : Symbol(z2, Decl(arrayLiteralTypeInference.ts, 34, 3))
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 34, 9))
|
||||
|
||||
[
|
||||
new ActionA(),
|
||||
>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1))
|
||||
|
||||
new ActionB()
|
||||
>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1))
|
||||
|
||||
]
|
||||
|
||||
var z3: { id: number }[] =
|
||||
>z3 : Symbol(z3, Decl(arrayLiteralTypeInference.ts, 40, 3))
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 40, 9))
|
||||
|
||||
[
|
||||
new Action(),
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
new ActionA(),
|
||||
>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1))
|
||||
|
||||
new ActionB()
|
||||
>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1))
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
=== tests/cases/compiler/arrayLiteralTypeInference.ts ===
|
||||
class Action {
|
||||
>Action : Action
|
||||
|
||||
id: number;
|
||||
>id : number
|
||||
}
|
||||
|
||||
class ActionA extends Action {
|
||||
>ActionA : ActionA
|
||||
>Action : Action
|
||||
|
||||
value: string;
|
||||
>value : string
|
||||
}
|
||||
|
||||
class ActionB extends Action {
|
||||
>ActionB : ActionB
|
||||
>Action : Action
|
||||
|
||||
trueNess: boolean;
|
||||
>trueNess : boolean
|
||||
}
|
||||
|
||||
var x1: Action[] = [
|
||||
>x1 : Action[]
|
||||
>Action : Action
|
||||
>[ { id: 2, trueness: false }, { id: 3, name: "three" }] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[]
|
||||
|
||||
{ id: 2, trueness: false },
|
||||
>{ id: 2, trueness: false } : { id: number; trueness: boolean; }
|
||||
>id : number
|
||||
>2 : number
|
||||
>trueness : boolean
|
||||
>false : boolean
|
||||
|
||||
{ id: 3, name: "three" }
|
||||
>{ id: 3, name: "three" } : { id: number; name: string; }
|
||||
>id : number
|
||||
>3 : number
|
||||
>name : string
|
||||
>"three" : string
|
||||
|
||||
]
|
||||
|
||||
var x2: Action[] = [
|
||||
>x2 : Action[]
|
||||
>Action : Action
|
||||
>[ new ActionA(), new ActionB()] : (ActionA | ActionB)[]
|
||||
|
||||
new ActionA(),
|
||||
>new ActionA() : ActionA
|
||||
>ActionA : typeof ActionA
|
||||
|
||||
new ActionB()
|
||||
>new ActionB() : ActionB
|
||||
>ActionB : typeof ActionB
|
||||
|
||||
]
|
||||
|
||||
var x3: Action[] = [
|
||||
>x3 : Action[]
|
||||
>Action : Action
|
||||
>[ new Action(), new ActionA(), new ActionB()] : Action[]
|
||||
|
||||
new Action(),
|
||||
>new Action() : Action
|
||||
>Action : typeof Action
|
||||
|
||||
new ActionA(),
|
||||
>new ActionA() : ActionA
|
||||
>ActionA : typeof ActionA
|
||||
|
||||
new ActionB()
|
||||
>new ActionB() : ActionB
|
||||
>ActionB : typeof ActionB
|
||||
|
||||
]
|
||||
|
||||
var z1: { id: number }[] =
|
||||
>z1 : { id: number; }[]
|
||||
>id : number
|
||||
|
||||
[
|
||||
>[ { id: 2, trueness: false }, { id: 3, name: "three" } ] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[]
|
||||
|
||||
{ id: 2, trueness: false },
|
||||
>{ id: 2, trueness: false } : { id: number; trueness: boolean; }
|
||||
>id : number
|
||||
>2 : number
|
||||
>trueness : boolean
|
||||
>false : boolean
|
||||
|
||||
{ id: 3, name: "three" }
|
||||
>{ id: 3, name: "three" } : { id: number; name: string; }
|
||||
>id : number
|
||||
>3 : number
|
||||
>name : string
|
||||
>"three" : string
|
||||
|
||||
]
|
||||
|
||||
var z2: { id: number }[] =
|
||||
>z2 : { id: number; }[]
|
||||
>id : number
|
||||
|
||||
[
|
||||
>[ new ActionA(), new ActionB() ] : (ActionA | ActionB)[]
|
||||
|
||||
new ActionA(),
|
||||
>new ActionA() : ActionA
|
||||
>ActionA : typeof ActionA
|
||||
|
||||
new ActionB()
|
||||
>new ActionB() : ActionB
|
||||
>ActionB : typeof ActionB
|
||||
|
||||
]
|
||||
|
||||
var z3: { id: number }[] =
|
||||
>z3 : { id: number; }[]
|
||||
>id : number
|
||||
|
||||
[
|
||||
>[ new Action(), new ActionA(), new ActionB() ] : Action[]
|
||||
|
||||
new Action(),
|
||||
>new Action() : Action
|
||||
>Action : typeof Action
|
||||
|
||||
new ActionA(),
|
||||
>new ActionA() : ActionA
|
||||
>ActionA : typeof ActionA
|
||||
|
||||
new ActionB()
|
||||
>new ActionB() : ActionB
|
||||
>ActionB : typeof ActionB
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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; y?: number; } | { x: number; z?: number; })[]
|
||||
>[b, a] : ({ x: number; y?: number; } | { x: number; z?: number; })[]
|
||||
>bs : ({ x: number; z?: number; } | { x: number; y?: number; })[]
|
||||
>[b, a] : ({ x: number; z?: number; } | { x: number; y?: number; })[]
|
||||
>b : { x: number; z?: number; }
|
||||
>a : { x: number; y?: number; }
|
||||
|
||||
@@ -36,8 +36,8 @@ var cs = [a, b, c]; // { x: number; y?: number };[]
|
||||
>c : { x: number; a?: number; }
|
||||
|
||||
var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[]
|
||||
>ds : ((x: Object) => number)[]
|
||||
>[(x: Object) => 1, (x: string) => 2] : ((x: Object) => number)[]
|
||||
>ds : (((x: Object) => number) | ((x: string) => number))[]
|
||||
>[(x: Object) => 1, (x: string) => 2] : (((x: Object) => number) | ((x: string) => number))[]
|
||||
>(x: Object) => 1 : (x: Object) => number
|
||||
>x : Object
|
||||
>Object : Object
|
||||
@@ -47,8 +47,8 @@ var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[]
|
||||
>2 : number
|
||||
|
||||
var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[]
|
||||
>es : ((x: string) => number)[]
|
||||
>[(x: string) => 2, (x: Object) => 1] : ((x: string) => number)[]
|
||||
>es : (((x: string) => number) | ((x: Object) => number))[]
|
||||
>[(x: string) => 2, (x: Object) => 1] : (((x: string) => number) | ((x: Object) => number))[]
|
||||
>(x: string) => 2 : (x: string) => number
|
||||
>x : string
|
||||
>2 : number
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'.
|
||||
Index signatures are incompatible.
|
||||
Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'.
|
||||
Type '{ a: string; b: number; c: string; }' is not assignable to type '{ a: string; b: number; }'.
|
||||
Object literal may only specify known properties, and 'c' does not exist in type '{ a: string; b: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts (1 errors) ====
|
||||
// Empty array literal with no contextual type has type Undefined[]
|
||||
|
||||
var arr1= [[], [1], ['']];
|
||||
|
||||
var arr2 = [[null], [1], ['']];
|
||||
|
||||
|
||||
// Array literal with elements of only EveryType E has type E[]
|
||||
var stringArrArr = [[''], [""]];
|
||||
|
||||
var stringArr = ['', ""];
|
||||
|
||||
var numberArr = [0, 0.0, 0x00, 1e1];
|
||||
|
||||
var boolArr = [false, true, false, true];
|
||||
|
||||
class C { private p; }
|
||||
var classArr = [new C(), new C()];
|
||||
|
||||
var classTypeArray = [C, C, C];
|
||||
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 }];
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'.
|
||||
!!! error TS2322: Index signatures are incompatible.
|
||||
!!! error TS2322: Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'.
|
||||
!!! error TS2322: Type '{ a: string; b: number; c: string; }' is not assignable to type '{ a: string; b: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'c' does not exist in type '{ a: string; b: number; }'.
|
||||
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
|
||||
class Base { private p; }
|
||||
class Derived1 extends Base { private m };
|
||||
class Derived2 extends Base { private n };
|
||||
var context3: Base[] = [new Derived1(), new Derived2()];
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[]
|
||||
var context4: Base[] = [new Derived1(), new Derived1()];
|
||||
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts ===
|
||||
// Empty array literal with no contextual type has type Undefined[]
|
||||
|
||||
var arr1= [[], [1], ['']];
|
||||
>arr1 : Symbol(arr1, Decl(arrayLiterals.ts, 2, 3))
|
||||
|
||||
var arr2 = [[null], [1], ['']];
|
||||
>arr2 : Symbol(arr2, Decl(arrayLiterals.ts, 4, 3))
|
||||
|
||||
|
||||
// Array literal with elements of only EveryType E has type E[]
|
||||
var stringArrArr = [[''], [""]];
|
||||
>stringArrArr : Symbol(stringArrArr, Decl(arrayLiterals.ts, 8, 3))
|
||||
|
||||
var stringArr = ['', ""];
|
||||
>stringArr : Symbol(stringArr, Decl(arrayLiterals.ts, 10, 3))
|
||||
|
||||
var numberArr = [0, 0.0, 0x00, 1e1];
|
||||
>numberArr : Symbol(numberArr, Decl(arrayLiterals.ts, 12, 3))
|
||||
|
||||
var boolArr = [false, true, false, true];
|
||||
>boolArr : Symbol(boolArr, Decl(arrayLiterals.ts, 14, 3))
|
||||
|
||||
class C { private p; }
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
>p : Symbol(p, Decl(arrayLiterals.ts, 16, 9))
|
||||
|
||||
var classArr = [new C(), new C()];
|
||||
>classArr : Symbol(classArr, Decl(arrayLiterals.ts, 17, 3))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
|
||||
var classTypeArray = [C, C, C];
|
||||
>classTypeArray : Symbol(classTypeArray, Decl(arrayLiterals.ts, 19, 3), Decl(arrayLiterals.ts, 20, 3))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
|
||||
var classTypeArray: Array<typeof C>; // Should OK, not be a parse error
|
||||
>classTypeArray : Symbol(classTypeArray, Decl(arrayLiterals.ts, 19, 3), Decl(arrayLiterals.ts, 20, 3))
|
||||
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
|
||||
// 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 }];
|
||||
>context1 : Symbol(context1, Decl(arrayLiterals.ts, 23, 3))
|
||||
>n : Symbol(n, Decl(arrayLiterals.ts, 23, 17))
|
||||
>a : Symbol(a, Decl(arrayLiterals.ts, 23, 30))
|
||||
>b : Symbol(b, Decl(arrayLiterals.ts, 23, 41))
|
||||
>a : Symbol(a, Decl(arrayLiterals.ts, 23, 62))
|
||||
>b : Symbol(b, Decl(arrayLiterals.ts, 23, 69))
|
||||
>c : Symbol(c, Decl(arrayLiterals.ts, 23, 75))
|
||||
>a : Symbol(a, Decl(arrayLiterals.ts, 23, 86))
|
||||
>b : Symbol(b, Decl(arrayLiterals.ts, 23, 93))
|
||||
>c : Symbol(c, Decl(arrayLiterals.ts, 23, 99))
|
||||
|
||||
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
|
||||
>context2 : Symbol(context2, Decl(arrayLiterals.ts, 24, 3))
|
||||
>a : Symbol(a, Decl(arrayLiterals.ts, 24, 17))
|
||||
>b : Symbol(b, Decl(arrayLiterals.ts, 24, 24))
|
||||
>c : Symbol(c, Decl(arrayLiterals.ts, 24, 30))
|
||||
>a : Symbol(a, Decl(arrayLiterals.ts, 24, 41))
|
||||
>b : Symbol(b, Decl(arrayLiterals.ts, 24, 48))
|
||||
>c : Symbol(c, Decl(arrayLiterals.ts, 24, 54))
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
|
||||
class Base { private p; }
|
||||
>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63))
|
||||
>p : Symbol(p, Decl(arrayLiterals.ts, 27, 12))
|
||||
|
||||
class Derived1 extends Base { private m };
|
||||
>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25))
|
||||
>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63))
|
||||
>m : Symbol(m, Decl(arrayLiterals.ts, 28, 29))
|
||||
|
||||
class Derived2 extends Base { private n };
|
||||
>Derived2 : Symbol(Derived2, Decl(arrayLiterals.ts, 28, 42))
|
||||
>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63))
|
||||
>n : Symbol(n, Decl(arrayLiterals.ts, 29, 29))
|
||||
|
||||
var context3: Base[] = [new Derived1(), new Derived2()];
|
||||
>context3 : Symbol(context3, Decl(arrayLiterals.ts, 30, 3))
|
||||
>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63))
|
||||
>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25))
|
||||
>Derived2 : Symbol(Derived2, Decl(arrayLiterals.ts, 28, 42))
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[]
|
||||
var context4: Base[] = [new Derived1(), new Derived1()];
|
||||
>context4 : Symbol(context4, Decl(arrayLiterals.ts, 33, 3))
|
||||
>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63))
|
||||
>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25))
|
||||
>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25))
|
||||
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts ===
|
||||
// Empty array literal with no contextual type has type Undefined[]
|
||||
|
||||
var arr1= [[], [1], ['']];
|
||||
>arr1 : (number[] | string[])[]
|
||||
>[[], [1], ['']] : (number[] | string[])[]
|
||||
>[] : undefined[]
|
||||
>[1] : number[]
|
||||
>1 : number
|
||||
>[''] : string[]
|
||||
>'' : string
|
||||
|
||||
var arr2 = [[null], [1], ['']];
|
||||
>arr2 : (number[] | string[])[]
|
||||
>[[null], [1], ['']] : (number[] | string[])[]
|
||||
>[null] : null[]
|
||||
>null : null
|
||||
>[1] : number[]
|
||||
>1 : number
|
||||
>[''] : string[]
|
||||
>'' : string
|
||||
|
||||
|
||||
// Array literal with elements of only EveryType E has type E[]
|
||||
var stringArrArr = [[''], [""]];
|
||||
>stringArrArr : string[][]
|
||||
>[[''], [""]] : string[][]
|
||||
>[''] : string[]
|
||||
>'' : string
|
||||
>[""] : string[]
|
||||
>"" : string
|
||||
|
||||
var stringArr = ['', ""];
|
||||
>stringArr : string[]
|
||||
>['', ""] : string[]
|
||||
>'' : string
|
||||
>"" : string
|
||||
|
||||
var numberArr = [0, 0.0, 0x00, 1e1];
|
||||
>numberArr : number[]
|
||||
>[0, 0.0, 0x00, 1e1] : number[]
|
||||
>0 : number
|
||||
>0.0 : number
|
||||
>0x00 : number
|
||||
>1e1 : number
|
||||
|
||||
var boolArr = [false, true, false, true];
|
||||
>boolArr : boolean[]
|
||||
>[false, true, false, true] : boolean[]
|
||||
>false : boolean
|
||||
>true : boolean
|
||||
>false : boolean
|
||||
>true : boolean
|
||||
|
||||
class C { private p; }
|
||||
>C : C
|
||||
>p : any
|
||||
|
||||
var classArr = [new C(), new C()];
|
||||
>classArr : C[]
|
||||
>[new C(), new C()] : C[]
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
|
||||
var classTypeArray = [C, C, C];
|
||||
>classTypeArray : typeof C[]
|
||||
>[C, C, C] : typeof C[]
|
||||
>C : typeof C
|
||||
>C : typeof C
|
||||
>C : typeof C
|
||||
|
||||
var classTypeArray: Array<typeof C>; // Should OK, not be a parse error
|
||||
>classTypeArray : typeof C[]
|
||||
>Array : T[]
|
||||
>C : typeof C
|
||||
|
||||
// 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 }];
|
||||
>context1 : { [n: number]: { a: string; b: number; }; }
|
||||
>n : number
|
||||
>a : string
|
||||
>b : number
|
||||
>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]
|
||||
>{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; }
|
||||
>a : string
|
||||
>'' : string
|
||||
>b : number
|
||||
>0 : number
|
||||
>c : string
|
||||
>'' : string
|
||||
>{ a: "", b: 3, c: 0 } : { a: string; b: number; c: number; }
|
||||
>a : string
|
||||
>"" : string
|
||||
>b : number
|
||||
>3 : number
|
||||
>c : number
|
||||
>0 : number
|
||||
|
||||
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
|
||||
>context2 : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]
|
||||
>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]
|
||||
>{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; }
|
||||
>a : string
|
||||
>'' : string
|
||||
>b : number
|
||||
>0 : number
|
||||
>c : string
|
||||
>'' : string
|
||||
>{ a: "", b: 3, c: 0 } : { a: string; b: number; c: number; }
|
||||
>a : string
|
||||
>"" : string
|
||||
>b : number
|
||||
>3 : number
|
||||
>c : number
|
||||
>0 : number
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
|
||||
class Base { private p; }
|
||||
>Base : Base
|
||||
>p : any
|
||||
|
||||
class Derived1 extends Base { private m };
|
||||
>Derived1 : Derived1
|
||||
>Base : Base
|
||||
>m : any
|
||||
|
||||
class Derived2 extends Base { private n };
|
||||
>Derived2 : Derived2
|
||||
>Base : Base
|
||||
>n : any
|
||||
|
||||
var context3: Base[] = [new Derived1(), new Derived2()];
|
||||
>context3 : Base[]
|
||||
>Base : Base
|
||||
>[new Derived1(), new Derived2()] : (Derived1 | Derived2)[]
|
||||
>new Derived1() : Derived1
|
||||
>Derived1 : typeof Derived1
|
||||
>new Derived2() : Derived2
|
||||
>Derived2 : typeof Derived2
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[]
|
||||
var context4: Base[] = [new Derived1(), new Derived1()];
|
||||
>context4 : Base[]
|
||||
>Base : Base
|
||||
>[new Derived1(), new Derived1()] : Derived1[]
|
||||
>new Derived1() : Derived1
|
||||
>Derived1 : typeof Derived1
|
||||
>new Derived1() : Derived1
|
||||
>Derived1 : typeof Derived1
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ var a1 = ["hello", "world"]
|
||||
>"world" : string
|
||||
|
||||
var a2 = [, , , ...a0, "hello"];
|
||||
>a2 : (string | number)[]
|
||||
>[, , , ...a0, "hello"] : (string | number)[]
|
||||
>a2 : (number | string)[]
|
||||
>[, , , ...a0, "hello"] : (number | string)[]
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
@@ -151,8 +151,8 @@ interface myArray2 extends Array<Number|String> { }
|
||||
>String : String
|
||||
|
||||
var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[]
|
||||
>d0 : (string | number | boolean)[]
|
||||
>[1, true, ...temp,] : (string | number | boolean)[]
|
||||
>d0 : (number | boolean | string)[]
|
||||
>[1, true, ...temp,] : (number | boolean | string)[]
|
||||
>1 : number
|
||||
>true : boolean
|
||||
>...temp : string
|
||||
@@ -214,8 +214,8 @@ var d8: number[][] = [[...temp1]]
|
||||
>temp1 : number[]
|
||||
|
||||
var d9 = [[...temp1], ...["hello"]];
|
||||
>d9 : (string | number[])[]
|
||||
>[[...temp1], ...["hello"]] : (string | number[])[]
|
||||
>d9 : (number[] | string)[]
|
||||
>[[...temp1], ...["hello"]] : (number[] | string)[]
|
||||
>[...temp1] : number[]
|
||||
>...temp1 : number
|
||||
>temp1 : number[]
|
||||
|
||||
@@ -24,8 +24,8 @@ var a1 = ["hello", "world"]
|
||||
>"world" : string
|
||||
|
||||
var a2 = [, , , ...a0, "hello"];
|
||||
>a2 : (string | number)[]
|
||||
>[, , , ...a0, "hello"] : (string | number)[]
|
||||
>a2 : (number | string)[]
|
||||
>[, , , ...a0, "hello"] : (number | string)[]
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
@@ -140,8 +140,8 @@ interface myArray2 extends Array<Number|String> { }
|
||||
>String : String
|
||||
|
||||
var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[]
|
||||
>d0 : (string | number | boolean)[]
|
||||
>[1, true, ...temp, ] : (string | number | boolean)[]
|
||||
>d0 : (number | boolean | string)[]
|
||||
>[1, true, ...temp, ] : (number | boolean | string)[]
|
||||
>1 : number
|
||||
>true : boolean
|
||||
>...temp : string
|
||||
@@ -176,10 +176,10 @@ var d4: myArray2 = [...temp, ...temp1];
|
||||
>temp1 : number[]
|
||||
|
||||
var d5 = [...a2];
|
||||
>d5 : (string | number)[]
|
||||
>[...a2] : (string | number)[]
|
||||
>...a2 : string | number
|
||||
>a2 : (string | number)[]
|
||||
>d5 : (number | string)[]
|
||||
>[...a2] : (number | string)[]
|
||||
>...a2 : number | string
|
||||
>a2 : (number | string)[]
|
||||
|
||||
var d6 = [...a3];
|
||||
>d6 : number[]
|
||||
@@ -201,8 +201,8 @@ var d8: number[][] = [[...temp1]]
|
||||
>temp1 : number[]
|
||||
|
||||
var d9 = [[...temp1], ...["hello"]];
|
||||
>d9 : (string | number[])[]
|
||||
>[[...temp1], ...["hello"]] : (string | number[])[]
|
||||
>d9 : (number[] | string)[]
|
||||
>[[...temp1], ...["hello"]] : (number[] | string)[]
|
||||
>[...temp1] : number[]
|
||||
>...temp1 : number
|
||||
>temp1 : number[]
|
||||
|
||||
@@ -5,18 +5,18 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,5): error
|
||||
Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number | boolean' is not assignable to type '() => number'.
|
||||
Type 'string | number | boolean' is not assignable to type 'number'.
|
||||
Type '() => number | string | boolean' is not assignable to type '() => number'.
|
||||
Type 'number | string | boolean' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error TS2322: Type '(number[] | string[])[]' is not assignable to type 'tup'.
|
||||
Property '0' is missing in type '(number[] | string[])[]'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
|
||||
Property '0' is missing in type 'number[]'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(number | string)[]' is not assignable to type 'myArray'.
|
||||
Types of property 'push' are incompatible.
|
||||
Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
Type '(...items: (number | string)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
Types of parameters 'items' and 'items' are incompatible.
|
||||
Type 'string | number' is not assignable to type 'Number'.
|
||||
Type 'number | string' is not assignable to type 'Number'.
|
||||
Type 'string' is not assignable to type 'Number'.
|
||||
Property 'toFixed' is missing in type 'String'.
|
||||
|
||||
@@ -49,8 +49,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => string | number | boolean' is not assignable to type '() => number'.
|
||||
!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '() => number | string | boolean' is not assignable to type '() => number'.
|
||||
!!! error TS2322: Type 'number | string | boolean' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
// The resulting type an array literal expression is determined as follows:
|
||||
@@ -76,11 +76,11 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
|
||||
!!! error TS2322: Property '0' is missing in type 'number[]'.
|
||||
var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[]
|
||||
~~
|
||||
!!! error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
|
||||
!!! error TS2322: Type '(number | string)[]' is not assignable to type 'myArray'.
|
||||
!!! error TS2322: Types of property 'push' are incompatible.
|
||||
!!! error TS2322: Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
!!! error TS2322: Type '(...items: (number | string)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'items' and 'items' are incompatible.
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'Number'.
|
||||
!!! error TS2322: Type 'number | string' is not assignable to type 'Number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
|
||||
!!! error TS2322: Property 'toFixed' is missing in type 'String'.
|
||||
|
||||
@@ -77,8 +77,8 @@ var myDerivedList: DerivedList<number>;
|
||||
>DerivedList : DerivedList<U>
|
||||
|
||||
var as = [list, myDerivedList]; // List<number>[]
|
||||
>as : List<number>[]
|
||||
>[list, myDerivedList] : List<number>[]
|
||||
>as : (List<number> | DerivedList<number>)[]
|
||||
>[list, myDerivedList] : (List<number> | DerivedList<number>)[]
|
||||
>list : List<number>
|
||||
>myDerivedList : DerivedList<number>
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(17,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(26,10): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts (2 errors) ====
|
||||
// valid uses of arrays of function types
|
||||
|
||||
var x = [() => 1, () => { }];
|
||||
var r2 = x[0]();
|
||||
|
||||
class C {
|
||||
foo: string;
|
||||
}
|
||||
var y = [C, C];
|
||||
var r3 = new y[0]();
|
||||
|
||||
var a: { (x: number): number; (x: string): string; };
|
||||
var b: { (x: number): number; (x: string): string; };
|
||||
var c: { (x: number): number; (x: any): any; };
|
||||
var z = [a, b, c];
|
||||
var r4 = z[0];
|
||||
var r5 = r4(''); // any not string
|
||||
~~
|
||||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
var r5b = r4(1);
|
||||
|
||||
var a2: { <T>(x: T): number; (x: string): string;};
|
||||
var b2: { <T>(x: T): number; (x: string): string; };
|
||||
var c2: { (x: number): number; <T>(x: T): any; };
|
||||
|
||||
var z2 = [a2, b2, c2];
|
||||
var r6 = z2[0];
|
||||
var r7 = r6(''); // any not string
|
||||
~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
@@ -1,93 +0,0 @@
|
||||
=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts ===
|
||||
// valid uses of arrays of function types
|
||||
|
||||
var x = [() => 1, () => { }];
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3))
|
||||
|
||||
var r2 = x[0]();
|
||||
>r2 : Symbol(r2, Decl(arrayOfFunctionTypes3.ts, 3, 3))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16))
|
||||
|
||||
foo: string;
|
||||
>foo : Symbol(foo, Decl(arrayOfFunctionTypes3.ts, 5, 9))
|
||||
}
|
||||
var y = [C, C];
|
||||
>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3))
|
||||
>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16))
|
||||
>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16))
|
||||
|
||||
var r3 = new y[0]();
|
||||
>r3 : Symbol(r3, Decl(arrayOfFunctionTypes3.ts, 9, 3))
|
||||
>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3))
|
||||
|
||||
var a: { (x: number): number; (x: string): string; };
|
||||
>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 10))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 31))
|
||||
|
||||
var b: { (x: number): number; (x: string): string; };
|
||||
>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 10))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 31))
|
||||
|
||||
var c: { (x: number): number; (x: any): any; };
|
||||
>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 10))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 31))
|
||||
|
||||
var z = [a, b, c];
|
||||
>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3))
|
||||
>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3))
|
||||
>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3))
|
||||
>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3))
|
||||
|
||||
var r4 = z[0];
|
||||
>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3))
|
||||
>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3))
|
||||
|
||||
var r5 = r4(''); // any not string
|
||||
>r5 : Symbol(r5, Decl(arrayOfFunctionTypes3.ts, 16, 3))
|
||||
>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3))
|
||||
|
||||
var r5b = r4(1);
|
||||
>r5b : Symbol(r5b, Decl(arrayOfFunctionTypes3.ts, 17, 3))
|
||||
>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3))
|
||||
|
||||
var a2: { <T>(x: T): number; (x: string): string;};
|
||||
>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 14))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 30))
|
||||
|
||||
var b2: { <T>(x: T): number; (x: string): string; };
|
||||
>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 14))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 30))
|
||||
|
||||
var c2: { (x: number): number; <T>(x: T): any; };
|
||||
>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 11))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 35))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32))
|
||||
|
||||
var z2 = [a2, b2, c2];
|
||||
>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3))
|
||||
>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3))
|
||||
>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3))
|
||||
>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3))
|
||||
|
||||
var r6 = z2[0];
|
||||
>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3))
|
||||
>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3))
|
||||
|
||||
var r7 = r6(''); // any not string
|
||||
>r7 : Symbol(r7, Decl(arrayOfFunctionTypes3.ts, 25, 3))
|
||||
>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3))
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts ===
|
||||
// valid uses of arrays of function types
|
||||
|
||||
var x = [() => 1, () => { }];
|
||||
>x : (() => void)[]
|
||||
>[() => 1, () => { }] : (() => void)[]
|
||||
>() => 1 : () => number
|
||||
>1 : number
|
||||
>() => { } : () => void
|
||||
|
||||
var r2 = x[0]();
|
||||
>r2 : void
|
||||
>x[0]() : void
|
||||
>x[0] : () => void
|
||||
>x : (() => void)[]
|
||||
>0 : number
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
foo: string;
|
||||
>foo : string
|
||||
}
|
||||
var y = [C, C];
|
||||
>y : typeof C[]
|
||||
>[C, C] : typeof C[]
|
||||
>C : typeof C
|
||||
>C : typeof C
|
||||
|
||||
var r3 = new y[0]();
|
||||
>r3 : C
|
||||
>new y[0]() : C
|
||||
>y[0] : typeof C
|
||||
>y : typeof C[]
|
||||
>0 : number
|
||||
|
||||
var a: { (x: number): number; (x: string): string; };
|
||||
>a : { (x: number): number; (x: string): string; }
|
||||
>x : number
|
||||
>x : string
|
||||
|
||||
var b: { (x: number): number; (x: string): string; };
|
||||
>b : { (x: number): number; (x: string): string; }
|
||||
>x : number
|
||||
>x : string
|
||||
|
||||
var c: { (x: number): number; (x: any): any; };
|
||||
>c : { (x: number): number; (x: any): any; }
|
||||
>x : number
|
||||
>x : any
|
||||
|
||||
var z = [a, b, c];
|
||||
>z : { (x: number): number; (x: any): any; }[]
|
||||
>[a, b, c] : { (x: number): number; (x: any): any; }[]
|
||||
>a : { (x: number): number; (x: string): string; }
|
||||
>b : { (x: number): number; (x: string): string; }
|
||||
>c : { (x: number): number; (x: any): any; }
|
||||
|
||||
var r4 = z[0];
|
||||
>r4 : { (x: number): number; (x: any): any; }
|
||||
>z[0] : { (x: number): number; (x: any): any; }
|
||||
>z : { (x: number): number; (x: any): any; }[]
|
||||
>0 : number
|
||||
|
||||
var r5 = r4(''); // any not string
|
||||
>r5 : any
|
||||
>r4('') : any
|
||||
>r4 : { (x: number): number; (x: any): any; }
|
||||
>'' : string
|
||||
|
||||
var r5b = r4(1);
|
||||
>r5b : number
|
||||
>r4(1) : number
|
||||
>r4 : { (x: number): number; (x: any): any; }
|
||||
>1 : number
|
||||
|
||||
var a2: { <T>(x: T): number; (x: string): string;};
|
||||
>a2 : { <T>(x: T): number; (x: string): string; }
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>x : string
|
||||
|
||||
var b2: { <T>(x: T): number; (x: string): string; };
|
||||
>b2 : { <T>(x: T): number; (x: string): string; }
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>x : string
|
||||
|
||||
var c2: { (x: number): number; <T>(x: T): any; };
|
||||
>c2 : { (x: number): number; <T>(x: T): any; }
|
||||
>x : number
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
|
||||
var z2 = [a2, b2, c2];
|
||||
>z2 : { (x: number): number; <T>(x: T): any; }[]
|
||||
>[a2, b2, c2] : { (x: number): number; <T>(x: T): any; }[]
|
||||
>a2 : { <T>(x: T): number; (x: string): string; }
|
||||
>b2 : { <T>(x: T): number; (x: string): string; }
|
||||
>c2 : { (x: number): number; <T>(x: T): any; }
|
||||
|
||||
var r6 = z2[0];
|
||||
>r6 : { (x: number): number; <T>(x: T): any; }
|
||||
>z2[0] : { (x: number): number; <T>(x: T): any; }
|
||||
>z2 : { (x: number): number; <T>(x: T): any; }[]
|
||||
>0 : number
|
||||
|
||||
var r7 = r6(''); // any not string
|
||||
>r7 : any
|
||||
>r6('') : any
|
||||
>r6 : { (x: number): number; <T>(x: T): any; }
|
||||
>'' : string
|
||||
|
||||
@@ -24,12 +24,12 @@ var z = Date as any as string;
|
||||
|
||||
// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string'
|
||||
var j = 32 as number|string;
|
||||
>j : string | number
|
||||
>32 as number|string : string | number
|
||||
>j : number | string
|
||||
>32 as number|string : number | string
|
||||
>32 : number
|
||||
|
||||
j = '';
|
||||
>j = '' : string
|
||||
>j : string | number
|
||||
>j : number | string
|
||||
>'' : string
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts(17,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number' is not assignable to type '() => number'.
|
||||
Type 'string | number' is not assignable to type 'number'.
|
||||
Type '() => number | string' is not assignable to type '() => number'.
|
||||
Type 'number | string' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts(18,1): error TS2322: Type '{}[]' is not assignable to type '[{}]'.
|
||||
Property '0' is missing in type '{}[]'.
|
||||
@@ -28,8 +28,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '[number, string]' is not assignable to type 'number[]'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! 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 '() => number | string' is not assignable to type '() => number'.
|
||||
!!! error TS2322: Type 'number | string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
emptyObjTuple = emptyObjArray;
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(1,5): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
|
||||
Property 'b' is missing in type '{ a: number; }'.
|
||||
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(3,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
|
||||
Property 'b' is missing in type '{ a: number; }'.
|
||||
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(5,1): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'.
|
||||
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(20,1): error TS2322: Type '{ f: (n: number) => number; m: number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
@@ -10,18 +12,21 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n:
|
||||
Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignmentCompatBug2.ts (5 errors) ====
|
||||
==== tests/cases/compiler/assignmentCompatBug2.ts (6 errors) ====
|
||||
var b2: { b: number;} = { a: 0 }; // error
|
||||
~~
|
||||
!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
|
||||
!!! error TS2322: Property 'b' is missing in type '{ a: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
|
||||
b2 = { a: 0 }; // error
|
||||
~~
|
||||
!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
|
||||
!!! error TS2322: Property 'b' is missing in type '{ a: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
|
||||
b2 = {b: 0, a: 0 };
|
||||
~~
|
||||
!!! error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
|
||||
var b3: { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; };
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/assignmentCompatBug5.ts(2,6): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
|
||||
Property 'a' is missing in type '{ b: number; }'.
|
||||
Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'number[]'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/assignmentCompatBug5.ts(8,6): error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'.
|
||||
@@ -14,7 +14,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of typ
|
||||
foo1({ b: 5 });
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
|
||||
!!! error TS2345: Property 'a' is missing in type '{ b: number; }'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
|
||||
|
||||
function foo2(x: number[]) { }
|
||||
foo2(["s", "t"]);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/async/es6/awaitUnion_es6.ts ===
|
||||
declare let a: number | string;
|
||||
>a : string | number
|
||||
>a : number | string
|
||||
|
||||
declare let b: PromiseLike<number> | PromiseLike<string>;
|
||||
>b : PromiseLike<number> | PromiseLike<string>
|
||||
@@ -8,7 +8,7 @@ declare let b: PromiseLike<number> | PromiseLike<string>;
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
declare let c: PromiseLike<number | string>;
|
||||
>c : PromiseLike<string | number>
|
||||
>c : PromiseLike<number | string>
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
declare let d: number | PromiseLike<string>;
|
||||
@@ -16,29 +16,29 @@ declare let d: number | PromiseLike<string>;
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
declare let e: number | PromiseLike<number | string>;
|
||||
>e : number | PromiseLike<string | number>
|
||||
>e : number | PromiseLike<number | string>
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
async function f() {
|
||||
>f : () => Promise<void>
|
||||
|
||||
let await_a = await a;
|
||||
>await_a : string | number
|
||||
>await_a : number | string
|
||||
>a : any
|
||||
|
||||
let await_b = await b;
|
||||
>await_b : string | number
|
||||
>await_b : number | string
|
||||
>b : any
|
||||
|
||||
let await_c = await c;
|
||||
>await_c : string | number
|
||||
>await_c : number | string
|
||||
>c : any
|
||||
|
||||
let await_d = await d;
|
||||
>await_d : string | number
|
||||
>await_d : number | string
|
||||
>d : any
|
||||
|
||||
let await_e = await e;
|
||||
>await_e : string | number
|
||||
>await_e : number | string
|
||||
>e : any
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ var r = true ? 1 : 2;
|
||||
>2 : number
|
||||
|
||||
var r3 = true ? 1 : {};
|
||||
>r3 : {}
|
||||
>true ? 1 : {} : {}
|
||||
>r3 : number | {}
|
||||
>true ? 1 : {} : number | {}
|
||||
>true : boolean
|
||||
>1 : number
|
||||
>{} : {}
|
||||
@@ -60,15 +60,15 @@ var r4 = true ? a : b; // typeof a
|
||||
>b : { x: number; z?: number; }
|
||||
|
||||
var r5 = true ? b : a; // typeof b
|
||||
>r5 : { x: number; y?: number; } | { x: number; z?: number; }
|
||||
>true ? b : a : { x: number; y?: number; } | { x: number; z?: number; }
|
||||
>r5 : { x: number; z?: number; } | { x: number; y?: number; }
|
||||
>true ? b : a : { x: number; z?: number; } | { x: number; y?: number; }
|
||||
>true : boolean
|
||||
>b : { x: number; z?: number; }
|
||||
>a : { x: number; y?: number; }
|
||||
|
||||
var r6 = true ? (x: number) => { } : (x: Object) => { }; // returns number => void
|
||||
>r6 : (x: number) => void
|
||||
>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void
|
||||
>r6 : ((x: number) => void) | ((x: Object) => void)
|
||||
>true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void)
|
||||
>true : boolean
|
||||
>(x: number) => { } : (x: number) => void
|
||||
>x : number
|
||||
@@ -80,7 +80,7 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { };
|
||||
>r7 : (x: Object) => void
|
||||
>x : Object
|
||||
>Object : Object
|
||||
>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void
|
||||
>true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void)
|
||||
>true : boolean
|
||||
>(x: number) => { } : (x: number) => void
|
||||
>x : number
|
||||
@@ -89,8 +89,8 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { };
|
||||
>Object : Object
|
||||
|
||||
var r8 = true ? (x: Object) => { } : (x: number) => { }; // returns Object => void
|
||||
>r8 : (x: Object) => void
|
||||
>true ? (x: Object) => { } : (x: number) => { } : (x: Object) => void
|
||||
>r8 : ((x: Object) => void) | ((x: number) => void)
|
||||
>true ? (x: Object) => { } : (x: number) => { } : ((x: Object) => void) | ((x: number) => void)
|
||||
>true : boolean
|
||||
>(x: Object) => { } : (x: Object) => void
|
||||
>x : Object
|
||||
@@ -107,8 +107,8 @@ var r10: Base = true ? derived : derived2; // no error since we use the contextu
|
||||
>derived2 : Derived2
|
||||
|
||||
var r11 = true ? base : derived2;
|
||||
>r11 : Base
|
||||
>true ? base : derived2 : Base
|
||||
>r11 : Base | Derived2
|
||||
>true ? base : derived2 : Base | Derived2
|
||||
>true : boolean
|
||||
>base : Base
|
||||
>derived2 : Derived2
|
||||
|
||||
@@ -98,8 +98,8 @@ var e3 = t3[2]; // any
|
||||
>2 : number
|
||||
|
||||
var e4 = t4[3]; // number
|
||||
>e4 : number
|
||||
>t4[3] : number
|
||||
>e4 : E1 | E2 | number
|
||||
>t4[3] : E1 | E2 | number
|
||||
>t4 : [E1, E2, number]
|
||||
>3 : number
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ var t5: [C1, F]
|
||||
>F : F
|
||||
|
||||
var e11 = t1[4]; // base
|
||||
>e11 : base
|
||||
>t1[4] : base
|
||||
>e11 : C | base
|
||||
>t1[4] : C | base
|
||||
>t1 : [C, base]
|
||||
>4 : number
|
||||
|
||||
@@ -78,20 +78,20 @@ var e21 = t2[4]; // {}
|
||||
>4 : number
|
||||
|
||||
var e31 = t3[4]; // C1
|
||||
>e31 : C1
|
||||
>t3[4] : C1
|
||||
>e31 : C1 | D1
|
||||
>t3[4] : C1 | D1
|
||||
>t3 : [C1, D1]
|
||||
>4 : number
|
||||
|
||||
var e41 = t4[2]; // base1
|
||||
>e41 : base1
|
||||
>t4[2] : base1
|
||||
>e41 : base1 | C1
|
||||
>t4[2] : base1 | C1
|
||||
>t4 : [base1, C1]
|
||||
>2 : number
|
||||
|
||||
var e51 = t5[2]; // {}
|
||||
>e51 : F | C1
|
||||
>t5[2] : F | C1
|
||||
>e51 : C1 | F
|
||||
>t5[2] : C1 | F
|
||||
>t5 : [C1, F]
|
||||
>2 : number
|
||||
|
||||
|
||||
@@ -27,43 +27,43 @@ var z: Z;
|
||||
|
||||
// All these arrays should be X[]
|
||||
var b1 = [x, y, z];
|
||||
>b1 : X[]
|
||||
>[x, y, z] : X[]
|
||||
>b1 : (X | Y | Z)[]
|
||||
>[x, y, z] : (X | Y | Z)[]
|
||||
>x : X
|
||||
>y : Y
|
||||
>z : Z
|
||||
|
||||
var b2 = [x, z, y];
|
||||
>b2 : X[]
|
||||
>[x, z, y] : X[]
|
||||
>b2 : (X | Z | Y)[]
|
||||
>[x, z, y] : (X | Z | Y)[]
|
||||
>x : X
|
||||
>z : Z
|
||||
>y : Y
|
||||
|
||||
var b3 = [y, x, z];
|
||||
>b3 : X[]
|
||||
>[y, x, z] : X[]
|
||||
>b3 : (Y | X | Z)[]
|
||||
>[y, x, z] : (Y | X | Z)[]
|
||||
>y : Y
|
||||
>x : X
|
||||
>z : Z
|
||||
|
||||
var b4 = [y, z, x];
|
||||
>b4 : X[]
|
||||
>[y, z, x] : X[]
|
||||
>b4 : (Y | Z | X)[]
|
||||
>[y, z, x] : (Y | Z | X)[]
|
||||
>y : Y
|
||||
>z : Z
|
||||
>x : X
|
||||
|
||||
var b5 = [z, x, y];
|
||||
>b5 : X[]
|
||||
>[z, x, y] : X[]
|
||||
>b5 : (Z | X | Y)[]
|
||||
>[z, x, y] : (Z | X | Y)[]
|
||||
>z : Z
|
||||
>x : X
|
||||
>y : Y
|
||||
|
||||
var b6 = [z, y, x];
|
||||
>b6 : X[]
|
||||
>[z, y, x] : X[]
|
||||
>b6 : (Z | Y | X)[]
|
||||
>[z, y, x] : (Z | Y | X)[]
|
||||
>z : Z
|
||||
>y : Y
|
||||
>x : X
|
||||
|
||||
@@ -163,8 +163,8 @@ xa[1].foo(1, 2, ...a, "abc");
|
||||
>xa : X[]
|
||||
>1 : number
|
||||
>foo : (x: number, y: number, ...z: string[]) => any
|
||||
>...[1, 2, "abc"] : string | number
|
||||
>[1, 2, "abc"] : (string | number)[]
|
||||
>...[1, 2, "abc"] : number | string
|
||||
>[1, 2, "abc"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"abc" : string
|
||||
|
||||
@@ -164,8 +164,8 @@ xa[1].foo(1, 2, ...a, "abc");
|
||||
>xa : X[]
|
||||
>1 : number
|
||||
>foo : (x: number, y: number, ...z: string[]) => any
|
||||
>...[1, 2, "abc"] : string | number
|
||||
>[1, 2, "abc"] : (string | number)[]
|
||||
>...[1, 2, "abc"] : number | string
|
||||
>[1, 2, "abc"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"abc" : string
|
||||
|
||||
@@ -8,11 +8,12 @@ tests/cases/conformance/types/tuple/castingTuple.ts(28,10): error TS2352: Neithe
|
||||
tests/cases/conformance/types/tuple/castingTuple.ts(29,10): error TS2352: Neither type '[C, D]' nor type '[A, I]' is assignable to the other.
|
||||
Types of property '0' are incompatible.
|
||||
Type 'C' is not assignable to type 'A'.
|
||||
Property 'a' is missing in type 'C'.
|
||||
tests/cases/conformance/types/tuple/castingTuple.ts(30,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
|
||||
tests/cases/conformance/types/tuple/castingTuple.ts(30,14): error TS2352: Neither type '[number, string]' nor type 'number[]' is assignable to the other.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number' is not assignable to type '() => number'.
|
||||
Type 'string | number' is not assignable to type 'number'.
|
||||
Type '() => number | string' is not assignable to type '() => number'.
|
||||
Type 'number | string' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot find name 't4'.
|
||||
|
||||
@@ -61,14 +62,15 @@ tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot
|
||||
!!! error TS2352: Neither type '[C, D]' nor type '[A, I]' is assignable to the other.
|
||||
!!! error TS2352: Types of property '0' are incompatible.
|
||||
!!! error TS2352: Type 'C' is not assignable to type 'A'.
|
||||
!!! error TS2352: Property 'a' is missing in type 'C'.
|
||||
var array1 = <number[]>numStrTuple;
|
||||
~~~~~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2352: Neither type '[number, string]' nor type 'number[]' is assignable to the other.
|
||||
!!! error TS2352: Types of property 'pop' are incompatible.
|
||||
!!! error TS2352: Type '() => string | number' is not assignable to type '() => number'.
|
||||
!!! error TS2352: Type 'string | number' is not assignable to type 'number'.
|
||||
!!! error TS2352: Type '() => number | string' is not assignable to type '() => number'.
|
||||
!!! error TS2352: Type 'number | string' is not assignable to type 'number'.
|
||||
!!! error TS2352: Type 'string' is not assignable to type 'number'.
|
||||
t4[2] = 10;
|
||||
~~
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
tests/cases/compiler/classExtendsNull.ts(2,5): error TS17005: A constructor cannot contain a 'super' call when its class extends 'null'
|
||||
|
||||
|
||||
==== tests/cases/compiler/classExtendsNull.ts (1 errors) ====
|
||||
class C extends null {
|
||||
constructor() {
|
||||
~~~~~~~~~~~~~~~
|
||||
super();
|
||||
~~~~~~~~~~~~~~~~
|
||||
return Object.create(null);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~
|
||||
!!! error TS17005: A constructor cannot contain a 'super' call when its class extends 'null'
|
||||
}
|
||||
|
||||
class D extends null {
|
||||
constructor() {
|
||||
return Object.create(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [classExtendsNull.ts]
|
||||
class C extends null {
|
||||
constructor() {
|
||||
super();
|
||||
return Object.create(null);
|
||||
}
|
||||
}
|
||||
|
||||
class D extends null {
|
||||
constructor() {
|
||||
return Object.create(null);
|
||||
}
|
||||
}
|
||||
|
||||
//// [classExtendsNull.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.call(this);
|
||||
return Object.create(null);
|
||||
}
|
||||
return C;
|
||||
})(null);
|
||||
var D = (function (_super) {
|
||||
__extends(D, _super);
|
||||
function D() {
|
||||
return Object.create(null);
|
||||
}
|
||||
return D;
|
||||
})(null);
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[]
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | boolean | number | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[]
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | boolean | number | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | (() => void) | number[]
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | (() => void) | number[]; 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: (() => void) | number | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | (() => void) | number[]
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | (() => void) | number[]; 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: (() => void) | number | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
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(1,5): error TS2322: Type 'number | string' is not assignable to type 'boolean'.
|
||||
Type 'number' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/conditionalExpression1.ts (1 errors) ====
|
||||
var x: boolean = (true ? 1 : ""); // should be an error
|
||||
~
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
!!! error TS2322: Type 'number | string' is not assignable to type 'boolean'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
|
||||
@@ -31,27 +31,27 @@ var b: B;
|
||||
//Cond ? Expr1 : Expr2, Expr1 is supertype
|
||||
//Be Not contextually typed
|
||||
true ? x : a;
|
||||
>true ? x : a : X
|
||||
>true ? x : a : X | A
|
||||
>true : boolean
|
||||
>x : X
|
||||
>a : A
|
||||
|
||||
var result1 = true ? x : a;
|
||||
>result1 : X
|
||||
>true ? x : a : X
|
||||
>result1 : X | A
|
||||
>true ? x : a : X | A
|
||||
>true : boolean
|
||||
>x : X
|
||||
>a : A
|
||||
|
||||
//Expr1 and Expr2 are literals
|
||||
true ? {} : 1;
|
||||
>true ? {} : 1 : {}
|
||||
>true ? {} : 1 : {} | number
|
||||
>true : boolean
|
||||
>{} : {}
|
||||
>1 : number
|
||||
|
||||
true ? { a: 1 } : { a: 2, b: 'string' };
|
||||
>true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; }
|
||||
>true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; } | { a: number; b: string; }
|
||||
>true : boolean
|
||||
>{ a: 1 } : { a: number; }
|
||||
>a : number
|
||||
@@ -63,15 +63,15 @@ true ? { a: 1 } : { a: 2, b: 'string' };
|
||||
>'string' : string
|
||||
|
||||
var result2 = true ? {} : 1;
|
||||
>result2 : {}
|
||||
>true ? {} : 1 : {}
|
||||
>result2 : {} | number
|
||||
>true ? {} : 1 : {} | number
|
||||
>true : boolean
|
||||
>{} : {}
|
||||
>1 : number
|
||||
|
||||
var result3 = true ? { a: 1 } : { a: 2, b: 'string' };
|
||||
>result3 : { a: number; }
|
||||
>true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; }
|
||||
>result3 : { a: number; } | { a: number; b: string; }
|
||||
>true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; } | { a: number; b: string; }
|
||||
>true : boolean
|
||||
>{ a: 1 } : { a: number; }
|
||||
>a : number
|
||||
@@ -86,7 +86,7 @@ var result3 = true ? { a: 1 } : { a: 2, b: 'string' };
|
||||
var resultIsX1: X = true ? x : a;
|
||||
>resultIsX1 : X
|
||||
>X : X
|
||||
>true ? x : a : X
|
||||
>true ? x : a : X | A
|
||||
>true : boolean
|
||||
>x : X
|
||||
>a : A
|
||||
@@ -95,7 +95,7 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA;
|
||||
>result4 : (t: A) => any
|
||||
>t : A
|
||||
>A : A
|
||||
>true ? (m) => m.propertyX : (n) => n.propertyA : (m: A) => any
|
||||
>true ? (m) => m.propertyX : (n) => n.propertyA : ((m: A) => any) | ((n: A) => number)
|
||||
>true : boolean
|
||||
>(m) => m.propertyX : (m: A) => any
|
||||
>m : A
|
||||
@@ -111,27 +111,27 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA;
|
||||
//Cond ? Expr1 : Expr2, Expr2 is supertype
|
||||
//Be Not contextually typed
|
||||
true ? a : x;
|
||||
>true ? a : x : X
|
||||
>true ? a : x : A | X
|
||||
>true : boolean
|
||||
>a : A
|
||||
>x : X
|
||||
|
||||
var result5 = true ? a : x;
|
||||
>result5 : X
|
||||
>true ? a : x : X
|
||||
>result5 : A | X
|
||||
>true ? a : x : A | X
|
||||
>true : boolean
|
||||
>a : A
|
||||
>x : X
|
||||
|
||||
//Expr1 and Expr2 are literals
|
||||
true ? 1 : {};
|
||||
>true ? 1 : {} : {}
|
||||
>true ? 1 : {} : number | {}
|
||||
>true : boolean
|
||||
>1 : number
|
||||
>{} : {}
|
||||
|
||||
true ? { a: 2, b: 'string' } : { a: 1 };
|
||||
>true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; }
|
||||
>true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; b: string; } | { a: number; }
|
||||
>true : boolean
|
||||
>{ a: 2, b: 'string' } : { a: number; b: string; }
|
||||
>a : number
|
||||
@@ -143,15 +143,15 @@ true ? { a: 2, b: 'string' } : { a: 1 };
|
||||
>1 : number
|
||||
|
||||
var result6 = true ? 1 : {};
|
||||
>result6 : {}
|
||||
>true ? 1 : {} : {}
|
||||
>result6 : number | {}
|
||||
>true ? 1 : {} : number | {}
|
||||
>true : boolean
|
||||
>1 : number
|
||||
>{} : {}
|
||||
|
||||
var result7 = true ? { a: 2, b: 'string' } : { a: 1 };
|
||||
>result7 : { a: number; }
|
||||
>true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; }
|
||||
>result7 : { a: number; b: string; } | { a: number; }
|
||||
>true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; b: string; } | { a: number; }
|
||||
>true : boolean
|
||||
>{ a: 2, b: 'string' } : { a: number; b: string; }
|
||||
>a : number
|
||||
@@ -166,7 +166,7 @@ var result7 = true ? { a: 2, b: 'string' } : { a: 1 };
|
||||
var resultIsX2: X = true ? x : a;
|
||||
>resultIsX2 : X
|
||||
>X : X
|
||||
>true ? x : a : X
|
||||
>true ? x : a : X | A
|
||||
>true : boolean
|
||||
>x : X
|
||||
>a : A
|
||||
@@ -175,7 +175,7 @@ var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX;
|
||||
>result8 : (t: A) => any
|
||||
>t : A
|
||||
>A : A
|
||||
>true ? (m) => m.propertyA : (n) => n.propertyX : (n: A) => any
|
||||
>true ? (m) => m.propertyA : (n) => n.propertyX : ((m: A) => number) | ((n: A) => any)
|
||||
>true : boolean
|
||||
>(m) => m.propertyA : (m: A) => number
|
||||
>m : A
|
||||
@@ -218,7 +218,7 @@ var result10: (t: X) => any = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
|
||||
//Expr1 and Expr2 are literals
|
||||
var result11: any = true ? 1 : 'string';
|
||||
>result11 : any
|
||||
>true ? 1 : 'string' : string | number
|
||||
>true ? 1 : 'string' : number | string
|
||||
>true : boolean
|
||||
>1 : number
|
||||
>'string' : string
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'.
|
||||
tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'.
|
||||
tests/cases/compiler/constEnumErrors.ts(12,9): error TS2474: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.
|
||||
tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(22,13): error TS2476: A const enum member can only be accessed using a string literal.
|
||||
@@ -31,7 +31,7 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member
|
||||
// forward reference to the element of the same enum
|
||||
X = Y,
|
||||
~
|
||||
!!! error TS2474: In 'const' enum declarations member initializer must be constant expression.
|
||||
!!! error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.
|
||||
// forward reference to the element of the same enum
|
||||
Y = E1.Z,
|
||||
~~~~
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//// [constEnumMergingWithValues1.ts]
|
||||
|
||||
function foo() {}
|
||||
module foo {
|
||||
const enum E { X }
|
||||
}
|
||||
|
||||
export = foo
|
||||
|
||||
//// [constEnumMergingWithValues1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
function foo() { }
|
||||
return foo;
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues1.ts ===
|
||||
|
||||
function foo() {}
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues1.ts, 0, 0), Decl(constEnumMergingWithValues1.ts, 1, 17))
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues1.ts, 0, 0), Decl(constEnumMergingWithValues1.ts, 1, 17))
|
||||
|
||||
const enum E { X }
|
||||
>E : Symbol(E, Decl(constEnumMergingWithValues1.ts, 2, 12))
|
||||
>X : Symbol(E.X, Decl(constEnumMergingWithValues1.ts, 3, 18))
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues1.ts, 0, 0), Decl(constEnumMergingWithValues1.ts, 1, 17))
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues1.ts ===
|
||||
|
||||
function foo() {}
|
||||
>foo : typeof foo
|
||||
|
||||
module foo {
|
||||
>foo : typeof foo
|
||||
|
||||
const enum E { X }
|
||||
>E : E
|
||||
>X : E
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : typeof foo
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//// [constEnumMergingWithValues2.ts]
|
||||
|
||||
class foo {}
|
||||
module foo {
|
||||
const enum E { X }
|
||||
}
|
||||
|
||||
export = foo
|
||||
|
||||
//// [constEnumMergingWithValues2.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var foo = (function () {
|
||||
function foo() {
|
||||
}
|
||||
return foo;
|
||||
})();
|
||||
return foo;
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues2.ts ===
|
||||
|
||||
class foo {}
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues2.ts, 0, 0), Decl(constEnumMergingWithValues2.ts, 1, 12))
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues2.ts, 0, 0), Decl(constEnumMergingWithValues2.ts, 1, 12))
|
||||
|
||||
const enum E { X }
|
||||
>E : Symbol(E, Decl(constEnumMergingWithValues2.ts, 2, 12))
|
||||
>X : Symbol(E.X, Decl(constEnumMergingWithValues2.ts, 3, 18))
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues2.ts, 0, 0), Decl(constEnumMergingWithValues2.ts, 1, 12))
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues2.ts ===
|
||||
|
||||
class foo {}
|
||||
>foo : foo
|
||||
|
||||
module foo {
|
||||
>foo : typeof foo
|
||||
|
||||
const enum E { X }
|
||||
>E : E
|
||||
>X : E
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : foo
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [constEnumMergingWithValues3.ts]
|
||||
|
||||
enum foo { A }
|
||||
module foo {
|
||||
const enum E { X }
|
||||
}
|
||||
|
||||
export = foo
|
||||
|
||||
//// [constEnumMergingWithValues3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var foo;
|
||||
(function (foo) {
|
||||
foo[foo["A"] = 0] = "A";
|
||||
})(foo || (foo = {}));
|
||||
return foo;
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues3.ts ===
|
||||
|
||||
enum foo { A }
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues3.ts, 0, 0), Decl(constEnumMergingWithValues3.ts, 1, 14))
|
||||
>A : Symbol(foo.A, Decl(constEnumMergingWithValues3.ts, 1, 10))
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues3.ts, 0, 0), Decl(constEnumMergingWithValues3.ts, 1, 14))
|
||||
|
||||
const enum E { X }
|
||||
>E : Symbol(E, Decl(constEnumMergingWithValues3.ts, 2, 12))
|
||||
>X : Symbol(E.X, Decl(constEnumMergingWithValues3.ts, 3, 18))
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues3.ts, 0, 0), Decl(constEnumMergingWithValues3.ts, 1, 14))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues3.ts ===
|
||||
|
||||
enum foo { A }
|
||||
>foo : foo
|
||||
>A : foo
|
||||
|
||||
module foo {
|
||||
>foo : typeof foo
|
||||
|
||||
const enum E { X }
|
||||
>E : E
|
||||
>X : E
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : foo
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [constEnumMergingWithValues4.ts]
|
||||
|
||||
module foo {
|
||||
const enum E { X }
|
||||
}
|
||||
|
||||
module foo {
|
||||
var x = 1;
|
||||
}
|
||||
|
||||
|
||||
export = foo
|
||||
|
||||
//// [constEnumMergingWithValues4.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var foo;
|
||||
(function (foo) {
|
||||
var x = 1;
|
||||
})(foo || (foo = {}));
|
||||
return foo;
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues4.ts ===
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues4.ts, 0, 0), Decl(constEnumMergingWithValues4.ts, 3, 1))
|
||||
|
||||
const enum E { X }
|
||||
>E : Symbol(E, Decl(constEnumMergingWithValues4.ts, 1, 12))
|
||||
>X : Symbol(E.X, Decl(constEnumMergingWithValues4.ts, 2, 18))
|
||||
}
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues4.ts, 0, 0), Decl(constEnumMergingWithValues4.ts, 3, 1))
|
||||
|
||||
var x = 1;
|
||||
>x : Symbol(x, Decl(constEnumMergingWithValues4.ts, 6, 7))
|
||||
}
|
||||
|
||||
|
||||
export = foo
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues4.ts, 0, 0), Decl(constEnumMergingWithValues4.ts, 3, 1))
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues4.ts ===
|
||||
|
||||
module foo {
|
||||
>foo : typeof foo
|
||||
|
||||
const enum E { X }
|
||||
>E : E
|
||||
>X : E
|
||||
}
|
||||
|
||||
module foo {
|
||||
>foo : typeof foo
|
||||
|
||||
var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
}
|
||||
|
||||
|
||||
export = foo
|
||||
>foo : typeof foo
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [constEnumMergingWithValues5.ts]
|
||||
|
||||
module foo {
|
||||
const enum E { X }
|
||||
}
|
||||
|
||||
export = foo
|
||||
|
||||
//// [constEnumMergingWithValues5.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var foo;
|
||||
(function (foo) {
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["X"] = 0] = "X";
|
||||
})(E || (E = {}));
|
||||
})(foo || (foo = {}));
|
||||
return foo;
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues5.ts ===
|
||||
|
||||
module foo {
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues5.ts, 0, 0))
|
||||
|
||||
const enum E { X }
|
||||
>E : Symbol(E, Decl(constEnumMergingWithValues5.ts, 1, 12))
|
||||
>X : Symbol(E.X, Decl(constEnumMergingWithValues5.ts, 2, 18))
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : Symbol(foo, Decl(constEnumMergingWithValues5.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/constEnumMergingWithValues5.ts ===
|
||||
|
||||
module foo {
|
||||
>foo : typeof foo
|
||||
|
||||
const enum E { X }
|
||||
>E : E
|
||||
>X : E
|
||||
}
|
||||
|
||||
export = foo
|
||||
>foo : typeof foo
|
||||
|
||||
@@ -87,24 +87,24 @@ var a = baz(1, 1, g); // Should be number
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var b: number | string;
|
||||
>b : string | number
|
||||
>b : number | string
|
||||
|
||||
var b = foo(g); // Should be number | string
|
||||
>b : string | number
|
||||
>foo(g) : string | number
|
||||
>b : number | string
|
||||
>foo(g) : number | string
|
||||
>foo : <T>(cb: (x: number, y: string) => T) => T
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var b = bar(1, "one", g); // Should be number | string
|
||||
>b : string | number
|
||||
>bar(1, "one", g) : string | number
|
||||
>b : number | string
|
||||
>bar(1, "one", g) : number | string
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>1 : number
|
||||
>"one" : string
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var b = bar("one", 1, g); // Should be number | string
|
||||
>b : string | number
|
||||
>b : number | string
|
||||
>bar("one", 1, g) : string | number
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>"one" : string
|
||||
@@ -112,11 +112,11 @@ var b = bar("one", 1, g); // Should be number | string
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var b = baz(b, b, g); // Should be number | string
|
||||
>b : string | number
|
||||
>baz(b, b, g) : string | number
|
||||
>b : number | string
|
||||
>baz(b, b, g) : number | string
|
||||
>baz : <T, U>(x: T, y: T, cb: (x: T, y: T) => U) => U
|
||||
>b : string | number
|
||||
>b : string | number
|
||||
>b : number | string
|
||||
>b : number | string
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var d: number[] | string[];
|
||||
@@ -138,7 +138,7 @@ var d = bar(1, "one", h); // Should be number[] | string[]
|
||||
|
||||
var d = bar("one", 1, h); // Should be number[] | string[]
|
||||
>d : number[] | string[]
|
||||
>bar("one", 1, h) : number[] | string[]
|
||||
>bar("one", 1, h) : string[] | number[]
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>"one" : string
|
||||
>1 : number
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number | boolean' is not assignable to type '() => string | number'.
|
||||
Type 'string | number | boolean' is not assignable to type 'string | number'.
|
||||
Type 'boolean' is not assignable to type 'string | number'.
|
||||
Type 'boolean' is not assignable to type 'number'.
|
||||
Type '() => number | string | boolean' is not assignable to type '() => number | string'.
|
||||
Type 'number | string | boolean' is not assignable to type 'number | string'.
|
||||
Type 'boolean' is not assignable to type 'number | string'.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(15,1): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
|
||||
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(18,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'.
|
||||
Types of property '0' are incompatible.
|
||||
@@ -31,10 +31,10 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS23
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => string | number | boolean' is not assignable to type '() => string | number'.
|
||||
!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'string | number'.
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'.
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '() => number | string | boolean' is not assignable to type '() => number | string'.
|
||||
!!! error TS2322: Type 'number | string | boolean' is not assignable to type 'number | string'.
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'number | string'.
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'string'.
|
||||
var numStrBoolTuple: [number, string, boolean] = [5, "foo", true];
|
||||
var objNumTuple: [{ a: string }, number] = [{ a: "world" }, 5];
|
||||
var strTupleTuple: [string, [number, {}]] = ["bar", [5, { x: 1, y: 1 }]];
|
||||
|
||||
@@ -82,7 +82,5 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any
|
||||
>IWithCallSignatures : Symbol(IWithCallSignatures, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 9, 1))
|
||||
>IWithCallSignatures4 : Symbol(IWithCallSignatures4, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 18, 1))
|
||||
>a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52))
|
||||
>a.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
|
||||
>a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
|
||||
|
||||
|
||||
@@ -90,10 +90,10 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any
|
||||
>x4 : IWithCallSignatures | IWithCallSignatures4
|
||||
>IWithCallSignatures : IWithCallSignatures
|
||||
>IWithCallSignatures4 : IWithCallSignatures4
|
||||
>a => /*here a should be any*/ a.toString() : (a: number) => string
|
||||
>a : number
|
||||
>a.toString() : string
|
||||
>a.toString : (radix?: number) => string
|
||||
>a : number
|
||||
>toString : (radix?: number) => string
|
||||
>a => /*here a should be any*/ a.toString() : (a: any) => any
|
||||
>a : any
|
||||
>a.toString() : any
|
||||
>a.toString : any
|
||||
>a : any
|
||||
>toString : any
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ var arrayI1OrI2: Array<I1<number> | I2<number>> = [i1, i2, { // Like i1
|
||||
>Array : T[]
|
||||
>I1 : I1<T>
|
||||
>I2 : I2<T>
|
||||
>[i1, i2, { // Like i1 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", }, { // Like i2 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }, { // Like i1 and i2 both commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }] : (I1<number> | I2<number>)[]
|
||||
>[i1, i2, { // Like i1 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", }, { // Like i2 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }, { // Like i1 and i2 both commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }] : (I1<number> | I2<number> | { commonPropertyType: string; commonMethodType: (a: string) => string; commonMethodWithTypeParameter: (a: number) => number; methodOnlyInI1: (a: string) => string; propertyOnlyInI1: string; methodOnlyInI2: (a: string) => string; propertyOnlyInI2: string; })[]
|
||||
>i1 : I1<number>
|
||||
>i2 : I2<number>
|
||||
>{ // Like i1 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", } : { commonPropertyType: string; commonMethodType: (a: string) => string; commonMethodWithTypeParameter: (a: number) => number; methodOnlyInI1: (a: string) => string; propertyOnlyInI1: string; }
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping12.ts (1 errors) ====
|
||||
class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,9 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping12.ts ===
|
||||
class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; }
|
||||
>foo : Symbol(foo, Decl(contextualTyping12.ts, 0, 0))
|
||||
>bar : Symbol(bar, Decl(contextualTyping12.ts, 0, 11))
|
||||
>id : Symbol(id, Decl(contextualTyping12.ts, 0, 24))
|
||||
>id : Symbol(id, Decl(contextualTyping12.ts, 0, 42))
|
||||
>id : Symbol(id, Decl(contextualTyping12.ts, 0, 50))
|
||||
>name : Symbol(name, Decl(contextualTyping12.ts, 0, 55))
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping12.ts ===
|
||||
class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; }
|
||||
>foo : foo
|
||||
>bar : { id: number; }[]
|
||||
>id : number
|
||||
>[{id:1}, {id:2, name:"foo"}] : { id: number; }[]
|
||||
>{id:1} : { id: number; }
|
||||
>id : number
|
||||
>1 : number
|
||||
>{id:2, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>2 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/contextualTyping17.ts(1,33): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping17.ts (1 errors) ====
|
||||
var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"};
|
||||
~~~
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,9 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping17.ts ===
|
||||
var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"};
|
||||
>foo : Symbol(foo, Decl(contextualTyping17.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping17.ts, 0, 10))
|
||||
>id : Symbol(id, Decl(contextualTyping17.ts, 0, 25))
|
||||
>foo : Symbol(foo, Decl(contextualTyping17.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping17.ts, 0, 39))
|
||||
>name : Symbol(name, Decl(contextualTyping17.ts, 0, 45))
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping17.ts ===
|
||||
var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"};
|
||||
>foo : { id: number; }
|
||||
>id : number
|
||||
>{id:4} : { id: number; }
|
||||
>id : number
|
||||
>4 : number
|
||||
>foo = {id: 5, name:"foo"} : { id: number; name: string; }
|
||||
>foo : { id: number; }
|
||||
>{id: 5, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>5 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/contextualTyping2.ts(1,5): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping2.ts (1 errors) ====
|
||||
var foo: {id:number;} = {id:4, name:"foo"};
|
||||
~~~
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,7 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping2.ts ===
|
||||
var foo: {id:number;} = {id:4, name:"foo"};
|
||||
>foo : Symbol(foo, Decl(contextualTyping2.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping2.ts, 0, 10))
|
||||
>id : Symbol(id, Decl(contextualTyping2.ts, 0, 25))
|
||||
>name : Symbol(name, Decl(contextualTyping2.ts, 0, 30))
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping2.ts ===
|
||||
var foo: {id:number;} = {id:4, name:"foo"};
|
||||
>foo : { id: number; }
|
||||
>id : number
|
||||
>{id:4, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>4 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping20.ts (1 errors) ====
|
||||
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}];
|
||||
~~~
|
||||
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,10 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping20.ts ===
|
||||
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}];
|
||||
>foo : Symbol(foo, Decl(contextualTyping20.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping20.ts, 0, 9))
|
||||
>id : Symbol(id, Decl(contextualTyping20.ts, 0, 27))
|
||||
>foo : Symbol(foo, Decl(contextualTyping20.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping20.ts, 0, 43))
|
||||
>id : Symbol(id, Decl(contextualTyping20.ts, 0, 51))
|
||||
>name : Symbol(name, Decl(contextualTyping20.ts, 0, 56))
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping20.ts ===
|
||||
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}];
|
||||
>foo : { id: number; }[]
|
||||
>id : number
|
||||
>[{id:1}] : { id: number; }[]
|
||||
>{id:1} : { id: number; }
|
||||
>id : number
|
||||
>1 : number
|
||||
>foo = [{id:1}, {id:2, name:"foo"}] : { id: number; }[]
|
||||
>foo : { id: number; }[]
|
||||
>[{id:1}, {id:2, name:"foo"}] : { id: number; }[]
|
||||
>{id:1} : { id: number; }
|
||||
>id : number
|
||||
>1 : number
|
||||
>{id:2, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>2 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '(number | { id: number; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type 'number | { id: number; }' is not assignable to type '{ id: number; }'.
|
||||
tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type '{ id: number; } | number' is not assignable to type '{ id: number; }'.
|
||||
Type 'number' is not assignable to type '{ id: number; }'.
|
||||
Property 'id' is missing in type 'Number'.
|
||||
|
||||
@@ -7,7 +7,7 @@ tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '(number |
|
||||
==== tests/cases/compiler/contextualTyping21.ts (1 errors) ====
|
||||
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, 1];
|
||||
~~~
|
||||
!!! error TS2322: Type '(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 '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'.
|
||||
!!! error TS2322: Type '{ id: number; } | 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,11 +1,11 @@
|
||||
tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
|
||||
Type 'string | number' is not assignable to type 'number'.
|
||||
tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'.
|
||||
Type 'number | string' 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 '(string | number)[]' is not assignable to parameter of type 'number[]'.
|
||||
!!! error TS2345: Type 'string | number' is not assignable to type 'number'.
|
||||
!!! error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'.
|
||||
!!! error TS2345: Type 'number | string' is not assignable to type 'number'.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
@@ -3,7 +3,7 @@ var foo = <{ id: number; }[]>[{ foo: "s" }, { }];
|
||||
>foo : { id: number; }[]
|
||||
><{ id: number; }[]>[{ foo: "s" }, { }] : { id: number; }[]
|
||||
>id : number
|
||||
>[{ foo: "s" }, { }] : {}[]
|
||||
>[{ foo: "s" }, { }] : ({ foo: string; } | {})[]
|
||||
>{ foo: "s" } : { foo: string; }
|
||||
>foo : string
|
||||
>"s" : string
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/contextualTyping4.ts(1,13): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping4.ts (1 errors) ====
|
||||
class foo { public bar:{id:number;} = {id:5, name:"foo"}; }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,8 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping4.ts ===
|
||||
class foo { public bar:{id:number;} = {id:5, name:"foo"}; }
|
||||
>foo : Symbol(foo, Decl(contextualTyping4.ts, 0, 0))
|
||||
>bar : Symbol(bar, Decl(contextualTyping4.ts, 0, 11))
|
||||
>id : Symbol(id, Decl(contextualTyping4.ts, 0, 24))
|
||||
>id : Symbol(id, Decl(contextualTyping4.ts, 0, 39))
|
||||
>name : Symbol(name, Decl(contextualTyping4.ts, 0, 44))
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping4.ts ===
|
||||
class foo { public bar:{id:number;} = {id:5, name:"foo"}; }
|
||||
>foo : foo
|
||||
>bar : { id: number; }
|
||||
>id : number
|
||||
>{id:5, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>5 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping9.ts (1 errors) ====
|
||||
var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}];
|
||||
~~~
|
||||
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,8 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping9.ts ===
|
||||
var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}];
|
||||
>foo : Symbol(foo, Decl(contextualTyping9.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping9.ts, 0, 9))
|
||||
>id : Symbol(id, Decl(contextualTyping9.ts, 0, 27))
|
||||
>id : Symbol(id, Decl(contextualTyping9.ts, 0, 35))
|
||||
>name : Symbol(name, Decl(contextualTyping9.ts, 0, 40))
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping9.ts ===
|
||||
var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}];
|
||||
>foo : { id: number; }[]
|
||||
>id : number
|
||||
>[{id:1}, {id:2, name:"foo"}] : { id: number; }[]
|
||||
>{id:1} : { id: number; }
|
||||
>id : number
|
||||
>1 : number
|
||||
>{id:2, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>2 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -23,8 +23,8 @@ class C extends A {
|
||||
}
|
||||
|
||||
var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }];
|
||||
>xs : ((x: A) => void)[]
|
||||
>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : ((x: A) => void)[]
|
||||
>xs : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[]
|
||||
>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[]
|
||||
>(x: A) => { } : (x: A) => void
|
||||
>x : A
|
||||
>A : A
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type '(number | Date)[]' is not assignable to type 'I'.
|
||||
tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type '(Date | number)[]' is not assignable to type 'I'.
|
||||
Index signatures are incompatible.
|
||||
Type 'number | Date' is not assignable to type 'Date'.
|
||||
Type 'Date | number' is not assignable to type 'Date'.
|
||||
Type 'number' is not assignable to type 'Date'.
|
||||
Property 'toDateString' is missing in type 'Number'.
|
||||
|
||||
@@ -12,9 +12,9 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ
|
||||
|
||||
var x3: I = [new Date(), 1];
|
||||
~~
|
||||
!!! error TS2322: Type '(number | Date)[]' is not assignable to type 'I'.
|
||||
!!! error TS2322: Type '(Date | number)[]' is not assignable to type 'I'.
|
||||
!!! error TS2322: Index signatures are incompatible.
|
||||
!!! error TS2322: Type 'number | Date' is not assignable to type 'Date'.
|
||||
!!! error TS2322: Type 'Date | number' 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];
|
||||
|
||||
@@ -29,4 +29,4 @@ declare class c {
|
||||
declare var x: (() => c)[];
|
||||
declare var y: (() => c)[];
|
||||
declare var k: (() => c) | string;
|
||||
declare var l: string | (() => c);
|
||||
declare var l: (() => c) | string;
|
||||
|
||||
@@ -23,9 +23,9 @@ var y = [() => new c()];
|
||||
>c : typeof c
|
||||
|
||||
var k: (() => c) | string = (() => new c()) || "";
|
||||
>k : string | (() => c)
|
||||
>k : (() => c) | string
|
||||
>c : c
|
||||
>(() => new c()) || "" : string | (() => c)
|
||||
>(() => new c()) || "" : (() => c) | string
|
||||
>(() => new c()) : () => c
|
||||
>() => new c() : () => c
|
||||
>new c() : c
|
||||
@@ -33,8 +33,8 @@ var k: (() => c) | string = (() => new c()) || "";
|
||||
>"" : string
|
||||
|
||||
var l = (() => new c()) || "";
|
||||
>l : string | (() => c)
|
||||
>(() => new c()) || "" : string | (() => c)
|
||||
>l : (() => c) | string
|
||||
>(() => new c()) || "" : (() => c) | string
|
||||
>(() => new c()) : () => c
|
||||
>() => new c() : () => c
|
||||
>new c() : c
|
||||
|
||||
@@ -47,7 +47,7 @@ module M {
|
||||
>M : typeof M
|
||||
|
||||
export type W = Window | string;
|
||||
>W : string | Window
|
||||
>W : Window | string
|
||||
>Window : Window
|
||||
|
||||
export module N {
|
||||
@@ -57,7 +57,7 @@ module M {
|
||||
>Window : Window
|
||||
|
||||
export var p: W;
|
||||
>p : string | Window
|
||||
>W : string | Window
|
||||
>p : Window | string
|
||||
>W : Window | string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,4 +15,4 @@ function foo(_a) {
|
||||
|
||||
//// [declarationEmitDestructuring3.d.ts]
|
||||
declare function bar([x, z, ...w]: any[]): void;
|
||||
declare function foo([x, ...y]?: (string | number | boolean)[]): void;
|
||||
declare function foo([x, ...y]?: (number | string | boolean)[]): void;
|
||||
|
||||
@@ -6,10 +6,10 @@ function bar([x, z, ...w]) { }
|
||||
>w : any[]
|
||||
|
||||
function foo([x, ...y] = [1, "string", true]) { }
|
||||
>foo : ([x, ...y]?: (string | number | boolean)[]) => void
|
||||
>x : string | number | boolean
|
||||
>y : (string | number | boolean)[]
|
||||
>[1, "string", true] : (string | number | boolean)[]
|
||||
>foo : ([x, ...y]?: (number | string | boolean)[]) => void
|
||||
>x : number | string | boolean
|
||||
>y : (number | string | boolean)[]
|
||||
>[1, "string", true] : (number | string | boolean)[]
|
||||
>1 : number
|
||||
>"string" : string
|
||||
>true : boolean
|
||||
|
||||
@@ -23,6 +23,6 @@ var x3 = a[0], y3 = a[1], z3 = a[2]; // emit x3, y3, z3
|
||||
declare var x: number;
|
||||
declare var x1: number, y1: string;
|
||||
declare var z1: number;
|
||||
declare var a: (string | number)[];
|
||||
declare var x2: string | number;
|
||||
declare var x3: string | number, y3: string | number, z3: string | number;
|
||||
declare var a: (number | string)[];
|
||||
declare var x2: number | string;
|
||||
declare var x3: number | string, y3: number | string, z3: number | string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
=== tests/cases/compiler/declarationEmitDestructuringArrayPattern1.ts ===
|
||||
|
||||
var [] = [1, "hello"]; // Dont emit anything
|
||||
>[1, "hello"] : (string | number)[]
|
||||
>[1, "hello"] : (number | string)[]
|
||||
>1 : number
|
||||
>"hello" : string
|
||||
|
||||
@@ -28,18 +28,18 @@ var [, , z1] = [0, 1, 2]; // emit z1: number
|
||||
>2 : number
|
||||
|
||||
var a = [1, "hello"];
|
||||
>a : (string | number)[]
|
||||
>[1, "hello"] : (string | number)[]
|
||||
>a : (number | string)[]
|
||||
>[1, "hello"] : (number | string)[]
|
||||
>1 : number
|
||||
>"hello" : string
|
||||
|
||||
var [x2] = a; // emit x2: number | string
|
||||
>x2 : string | number
|
||||
>a : (string | number)[]
|
||||
>x2 : number | string
|
||||
>a : (number | string)[]
|
||||
|
||||
var [x3, y3, z3] = a; // emit x3, y3, z3
|
||||
>x3 : string | number
|
||||
>y3 : string | number
|
||||
>z3 : string | number
|
||||
>a : (string | number)[]
|
||||
>x3 : number | string
|
||||
>y3 : number | string
|
||||
>z3 : number | string
|
||||
>a : (number | string)[]
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ declare var x11: number, y11: string;
|
||||
declare var a11: any, b11: any, c11: any;
|
||||
declare var a2: number, b2: string, x12: number, c2: boolean;
|
||||
declare var x13: number, y13: string;
|
||||
declare var a3: (string | number)[], b3: {
|
||||
declare var a3: (number | string)[], b3: {
|
||||
x: number;
|
||||
y: string;
|
||||
};
|
||||
|
||||
@@ -56,10 +56,10 @@ var [x13, y13] = [1, "hello"];
|
||||
>"hello" : string
|
||||
|
||||
var [a3, b3] = [[x13, y13], { x: x13, y: y13 }];
|
||||
>a3 : (string | number)[]
|
||||
>a3 : (number | string)[]
|
||||
>b3 : { x: number; y: string; }
|
||||
>[[x13, y13], { x: x13, y: y13 }] : [(string | number)[], { x: number; y: string; }]
|
||||
>[x13, y13] : (string | number)[]
|
||||
>[[x13, y13], { x: x13, y: y13 }] : [(number | string)[], { x: number; y: string; }]
|
||||
>[x13, y13] : (number | string)[]
|
||||
>x13 : number
|
||||
>y13 : string
|
||||
>{ x: x13, y: y13 } : { x: number; y: string; }
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user