Merge branch 'master' into fixTypeResolutionInTypeSerialization

This commit is contained in:
Ron Buckton
2015-08-06 15:45:24 -07:00
694 changed files with 15788 additions and 8909 deletions
+11 -11
View File
@@ -75,28 +75,28 @@ function delint(sourceFile) {
delintNode(sourceFile);
function delintNode(node) {
switch (node.kind) {
case 196 /* ForStatement */:
case 197 /* ForInStatement */:
case 195 /* WhileStatement */:
case 194 /* DoStatement */:
if (node.statement.kind !== 189 /* Block */) {
case 197 /* ForStatement */:
case 198 /* ForInStatement */:
case 196 /* WhileStatement */:
case 195 /* DoStatement */:
if (node.statement.kind !== 190 /* Block */) {
report(node, "A looping statement's contents should be wrapped in a block body.");
}
break;
case 193 /* IfStatement */:
case 194 /* IfStatement */:
var ifStatement = node;
if (ifStatement.thenStatement.kind !== 189 /* Block */) {
if (ifStatement.thenStatement.kind !== 190 /* Block */) {
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
}
if (ifStatement.elseStatement &&
ifStatement.elseStatement.kind !== 189 /* Block */ &&
ifStatement.elseStatement.kind !== 193 /* IfStatement */) {
ifStatement.elseStatement.kind !== 190 /* Block */ &&
ifStatement.elseStatement.kind !== 194 /* IfStatement */) {
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
}
break;
case 178 /* BinaryExpression */:
case 179 /* BinaryExpression */:
var op = node.operatorToken.kind;
if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) {
if (op === 30 /* EqualsEqualsToken */ || op == 31 /* ExclamationEqualsToken */) {
report(node, "Use '===' and '!=='.");
}
break;
@@ -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 = {}));
}
}
});
@@ -1,6 +1,7 @@
tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts(9,7): error TS2415: Class 'Derived<U>' incorrectly extends base class 'Base'.
Types of property 'x' are incompatible.
Type 'U' is not assignable to type 'string'.
Type 'String' is not assignable to type 'string'.
==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (1 errors) ====
@@ -17,5 +18,6 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty
!!! error TS2415: Class 'Derived<U>' incorrectly extends base class 'Base'.
!!! error TS2415: Types of property 'x' are incompatible.
!!! error TS2415: Type 'U' is not assignable to type 'string'.
!!! error TS2415: Type 'String' is not assignable to type 'string'.
x: U;
}
@@ -1,6 +1,7 @@
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(13,12): error TS2493: Tuple type '[string, number]' with length '2' cannot be assigned to tuple with length '3'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(14,12): error TS2460: Type 'StrNum' has no property '2'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(15,5): error TS2461: Type '{ 0: string; 1: number; }' is not an array type.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(15,12): error TS2460: Type '{ 0: string; 1: number; }' has no property '2'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(16,5): error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'.
Types of property '0' are incompatible.
Type 'string' is not assignable to type 'number'.
@@ -46,7 +47,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (18 errors) ====
==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (19 errors) ====
interface StrNum extends Array<string|number> {
0: string;
1: number;
@@ -68,6 +69,8 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error
var [g, h, i] = z;
~~~~~~~~~
!!! error TS2461: Type '{ 0: string; 1: number; }' is not an array type.
~
!!! error TS2460: Type '{ 0: string; 1: number; }' has no property '2'.
var j1: [number, number, number] = x;
~~
!!! error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'.
@@ -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
@@ -70,6 +70,7 @@ var p6 = ({ a }) => { };
var p7 = ({ a: { b } }) => { };
>p7 : Symbol(p7, Decl(arrowFunctionExpressions.ts, 21, 3))
>a : Symbol(a)
>b : Symbol(b, Decl(arrowFunctionExpressions.ts, 21, 16))
var p8 = ({ a = 1 }) => { };
@@ -78,6 +79,7 @@ var p8 = ({ a = 1 }) => { };
var p9 = ({ a: { b = 1 } = { b: 1 } }) => { };
>p9 : Symbol(p9, Decl(arrowFunctionExpressions.ts, 23, 3))
>a : Symbol(a)
>b : Symbol(b, Decl(arrowFunctionExpressions.ts, 23, 16))
>b : Symbol(b, Decl(arrowFunctionExpressions.ts, 23, 28))
+3 -3
View File
@@ -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,18 +1,21 @@
tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: string]: any; }' is not assignable to type '{ one: number; }'.
Property 'one' is missing in type '{ [index: string]: any; }'.
tests/cases/compiler/assignmentCompat1.ts(5,1): error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'.
Index signature is missing in type '{ one: number; }'.
tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'.
Property 'one' is missing in type '{ [index: number]: any; }'.
==== tests/cases/compiler/assignmentCompat1.ts (2 errors) ====
var x = {one: 1};
var y: {[index:string]: any};
x = y;
var x = { one: 1 };
var y: { [index: string]: any };
var z: { [index: number]: any };
x = y; // Error
~
!!! error TS2322: Type '{ [index: string]: any; }' is not assignable to type '{ one: number; }'.
!!! error TS2322: Property 'one' is missing in type '{ [index: string]: any; }'.
y = x;
y = x; // Ok because index signature type is any
x = z; // Error
~
!!! error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'.
!!! error TS2322: Index signature is missing in type '{ one: number; }'.
!!! error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'.
!!! error TS2322: Property 'one' is missing in type '{ [index: number]: any; }'.
z = x; // Ok because index signature type is any
+13 -7
View File
@@ -1,12 +1,18 @@
//// [assignmentCompat1.ts]
var x = {one: 1};
var y: {[index:string]: any};
x = y;
y = x;
var x = { one: 1 };
var y: { [index: string]: any };
var z: { [index: number]: any };
x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
//// [assignmentCompat1.js]
var x = { one: 1 };
var y;
x = y;
y = x;
var z;
x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
@@ -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"]);
@@ -12,12 +12,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(33,9): error TS2322: Type 'A<T>' is not assignable to type '{ [x: number]: Derived; }'.
Index signatures are incompatible.
Type 'T' is not assignable to type 'Derived'.
Type 'Base' is not assignable to type 'Derived'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(36,9): error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A<T>'.
Index signatures are incompatible.
Type 'Derived2' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts(37,9): error TS2322: Type 'A<T>' is not assignable to type '{ [x: number]: Derived2; }'.
Index signatures are incompatible.
Type 'T' is not assignable to type 'Derived2'.
Type 'Base' is not assignable to type 'Derived2'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts (6 errors) ====
@@ -72,6 +74,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'A<T>' is not assignable to type '{ [x: number]: Derived; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'Derived'.
!!! error TS2322: Type 'Base' is not assignable to type 'Derived'.
var b2: { [x: number]: Derived2; }
a = b2; // error
@@ -84,6 +87,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'A<T>' is not assignable to type '{ [x: number]: Derived2; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'Derived2'.
!!! error TS2322: Type 'Base' is not assignable to type 'Derived2'.
var b3: { [x: number]: T; }
a = b3; // ok
@@ -12,12 +12,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(33,9): error TS2322: Type 'A<T>' is not assignable to type '{ [x: number]: Derived; }'.
Index signatures are incompatible.
Type 'T' is not assignable to type 'Derived'.
Type 'Base' is not assignable to type 'Derived'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(36,9): error TS2322: Type '{ [x: number]: Derived2; }' is not assignable to type 'A<T>'.
Index signatures are incompatible.
Type 'Derived2' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts(37,9): error TS2322: Type 'A<T>' is not assignable to type '{ [x: number]: Derived2; }'.
Index signatures are incompatible.
Type 'T' is not assignable to type 'Derived2'.
Type 'Base' is not assignable to type 'Derived2'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts (6 errors) ====
@@ -72,6 +74,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'A<T>' is not assignable to type '{ [x: number]: Derived; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'Derived'.
!!! error TS2322: Type 'Base' is not assignable to type 'Derived'.
var b2: { [x: number]: Derived2; }
a = b2; // error
@@ -84,6 +87,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'A<T>' is not assignable to type '{ [x: number]: Derived2; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'Derived2'.
!!! error TS2322: Type 'Base' is not assignable to type 'Derived2'.
var b3: { [x: number]: T; }
a = b3; // ok
@@ -18,12 +18,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(47,9): error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: Derived; }'.
Index signatures are incompatible.
Type 'T' is not assignable to type 'Derived'.
Type 'Base' is not assignable to type 'Derived'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(50,9): error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A<T>'.
Index signatures are incompatible.
Type 'Derived2' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts(51,9): error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: Derived2; }'.
Index signatures are incompatible.
Type 'T' is not assignable to type 'Derived2'.
Type 'Base' is not assignable to type 'Derived2'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts (8 errors) ====
@@ -100,6 +102,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: Derived; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'Derived'.
!!! error TS2322: Type 'Base' is not assignable to type 'Derived'.
var b4: { [x: string]: Derived2; };
a3 = b4; // error
@@ -112,5 +115,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: Derived2; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'Derived2'.
!!! error TS2322: Type 'Base' is not assignable to type 'Derived2'.
}
}
@@ -18,12 +18,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(47,9): error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: Derived; }'.
Index signatures are incompatible.
Type 'T' is not assignable to type 'Derived'.
Type 'Base' is not assignable to type 'Derived'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(50,9): error TS2322: Type '{ [x: string]: Derived2; }' is not assignable to type 'A<T>'.
Index signatures are incompatible.
Type 'Derived2' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts(51,9): error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: Derived2; }'.
Index signatures are incompatible.
Type 'T' is not assignable to type 'Derived2'.
Type 'Base' is not assignable to type 'Derived2'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts (8 errors) ====
@@ -100,6 +102,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: Derived; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'Derived'.
!!! error TS2322: Type 'Base' is not assignable to type 'Derived'.
var b4: { [x: string]: Derived2; };
a3 = b4; // error
@@ -112,5 +115,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: Derived2; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'Derived2'.
!!! error TS2322: Type 'Base' is not assignable to type 'Derived2'.
}
}
@@ -5,6 +5,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts(21,9): error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: string; }'.
Index signatures are incompatible.
Type 'T' is not assignable to type 'string'.
Type 'Derived' is not assignable to type 'string'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts (3 errors) ====
@@ -39,5 +40,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'A<T>' is not assignable to type '{ [x: string]: string; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'T' is not assignable to type 'string'.
!!! error TS2322: Type 'Derived' is not assignable to type 'string'.
}
}
@@ -1,17 +0,0 @@
tests/cases/compiler/assignmentCompatability36.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [index: string]: any; }'.
Index signature is missing in type 'interfaceWithPublicAndOptional<number, string>'.
==== tests/cases/compiler/assignmentCompatability36.ts (1 errors) ====
module __test1__ {
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
export var __val__obj4 = obj4;
}
module __test2__ {
export var aa:{[index:string]:any;};;
export var __val__aa = aa;
}
__test2__.__val__aa = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [index: string]: any; }'.
!!! error TS2322: Index signature is missing in type 'interfaceWithPublicAndOptional<number, string>'.
@@ -0,0 +1,39 @@
=== tests/cases/compiler/assignmentCompatability36.ts ===
module __test1__ {
>__test1__ : Symbol(__test1__, Decl(assignmentCompatability36.ts, 0, 0))
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability36.ts, 0, 18))
>T : Symbol(T, Decl(assignmentCompatability36.ts, 1, 52))
>U : Symbol(U, Decl(assignmentCompatability36.ts, 1, 54))
>one : Symbol(one, Decl(assignmentCompatability36.ts, 1, 58))
>T : Symbol(T, Decl(assignmentCompatability36.ts, 1, 52))
>two : Symbol(two, Decl(assignmentCompatability36.ts, 1, 66))
>U : Symbol(U, Decl(assignmentCompatability36.ts, 1, 54))
>obj4 : Symbol(obj4, Decl(assignmentCompatability36.ts, 1, 83))
>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability36.ts, 0, 18))
>one : Symbol(one, Decl(assignmentCompatability36.ts, 1, 139))
export var __val__obj4 = obj4;
>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability36.ts, 2, 14))
>obj4 : Symbol(obj4, Decl(assignmentCompatability36.ts, 1, 83))
}
module __test2__ {
>__test2__ : Symbol(__test2__, Decl(assignmentCompatability36.ts, 3, 1))
export var aa:{[index:string]:any;};;
>aa : Symbol(aa, Decl(assignmentCompatability36.ts, 5, 14))
>index : Symbol(index, Decl(assignmentCompatability36.ts, 5, 20))
export var __val__aa = aa;
>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability36.ts, 6, 14))
>aa : Symbol(aa, Decl(assignmentCompatability36.ts, 5, 14))
}
__test2__.__val__aa = __test1__.__val__obj4
>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability36.ts, 6, 14))
>__test2__ : Symbol(__test2__, Decl(assignmentCompatability36.ts, 3, 1))
>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability36.ts, 6, 14))
>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability36.ts, 2, 14))
>__test1__ : Symbol(__test1__, Decl(assignmentCompatability36.ts, 0, 0))
>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability36.ts, 2, 14))
@@ -0,0 +1,42 @@
=== tests/cases/compiler/assignmentCompatability36.ts ===
module __test1__ {
>__test1__ : typeof __test1__
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
>T : T
>U : U
>one : T
>T : T
>two : U
>U : U
>obj4 : interfaceWithPublicAndOptional<number, string>
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
>{ one: 1 } : { one: number; }
>one : number
>1 : number
export var __val__obj4 = obj4;
>__val__obj4 : interfaceWithPublicAndOptional<number, string>
>obj4 : interfaceWithPublicAndOptional<number, string>
}
module __test2__ {
>__test2__ : typeof __test2__
export var aa:{[index:string]:any;};;
>aa : { [index: string]: any; }
>index : string
export var __val__aa = aa;
>__val__aa : { [index: string]: any; }
>aa : { [index: string]: any; }
}
__test2__.__val__aa = __test1__.__val__obj4
>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional<number, string>
>__test2__.__val__aa : { [index: string]: any; }
>__test2__ : typeof __test2__
>__val__aa : { [index: string]: any; }
>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional<number, string>
>__test1__ : typeof __test1__
>__val__obj4 : __test1__.interfaceWithPublicAndOptional<number, string>
@@ -0,0 +1,42 @@
//// [assignmentNonObjectTypeConstraints.ts]
const enum E { A, B, C }
function foo<T extends number>(x: T) {
var y: number = x; // Ok
}
foo(5);
foo(E.A);
class A { a }
class B { b }
function bar<T extends A | B>(x: T) {
var y: A | B = x; // Ok
}
bar(new A);
bar(new B);
//// [assignmentNonObjectTypeConstraints.js]
function foo(x) {
var y = x; // Ok
}
foo(5);
foo(0 /* A */);
var A = (function () {
function A() {
}
return A;
})();
var B = (function () {
function B() {
}
return B;
})();
function bar(x) {
var y = x; // Ok
}
bar(new A);
bar(new B);
@@ -0,0 +1,58 @@
=== tests/cases/compiler/assignmentNonObjectTypeConstraints.ts ===
const enum E { A, B, C }
>E : Symbol(E, Decl(assignmentNonObjectTypeConstraints.ts, 0, 0))
>A : Symbol(E.A, Decl(assignmentNonObjectTypeConstraints.ts, 0, 14))
>B : Symbol(E.B, Decl(assignmentNonObjectTypeConstraints.ts, 0, 17))
>C : Symbol(E.C, Decl(assignmentNonObjectTypeConstraints.ts, 0, 20))
function foo<T extends number>(x: T) {
>foo : Symbol(foo, Decl(assignmentNonObjectTypeConstraints.ts, 0, 24))
>T : Symbol(T, Decl(assignmentNonObjectTypeConstraints.ts, 2, 13))
>x : Symbol(x, Decl(assignmentNonObjectTypeConstraints.ts, 2, 31))
>T : Symbol(T, Decl(assignmentNonObjectTypeConstraints.ts, 2, 13))
var y: number = x; // Ok
>y : Symbol(y, Decl(assignmentNonObjectTypeConstraints.ts, 3, 7))
>x : Symbol(x, Decl(assignmentNonObjectTypeConstraints.ts, 2, 31))
}
foo(5);
>foo : Symbol(foo, Decl(assignmentNonObjectTypeConstraints.ts, 0, 24))
foo(E.A);
>foo : Symbol(foo, Decl(assignmentNonObjectTypeConstraints.ts, 0, 24))
>E.A : Symbol(E.A, Decl(assignmentNonObjectTypeConstraints.ts, 0, 14))
>E : Symbol(E, Decl(assignmentNonObjectTypeConstraints.ts, 0, 0))
>A : Symbol(E.A, Decl(assignmentNonObjectTypeConstraints.ts, 0, 14))
class A { a }
>A : Symbol(A, Decl(assignmentNonObjectTypeConstraints.ts, 7, 9))
>a : Symbol(a, Decl(assignmentNonObjectTypeConstraints.ts, 9, 9))
class B { b }
>B : Symbol(B, Decl(assignmentNonObjectTypeConstraints.ts, 9, 13))
>b : Symbol(b, Decl(assignmentNonObjectTypeConstraints.ts, 10, 9))
function bar<T extends A | B>(x: T) {
>bar : Symbol(bar, Decl(assignmentNonObjectTypeConstraints.ts, 10, 13))
>T : Symbol(T, Decl(assignmentNonObjectTypeConstraints.ts, 12, 13))
>A : Symbol(A, Decl(assignmentNonObjectTypeConstraints.ts, 7, 9))
>B : Symbol(B, Decl(assignmentNonObjectTypeConstraints.ts, 9, 13))
>x : Symbol(x, Decl(assignmentNonObjectTypeConstraints.ts, 12, 30))
>T : Symbol(T, Decl(assignmentNonObjectTypeConstraints.ts, 12, 13))
var y: A | B = x; // Ok
>y : Symbol(y, Decl(assignmentNonObjectTypeConstraints.ts, 13, 7))
>A : Symbol(A, Decl(assignmentNonObjectTypeConstraints.ts, 7, 9))
>B : Symbol(B, Decl(assignmentNonObjectTypeConstraints.ts, 9, 13))
>x : Symbol(x, Decl(assignmentNonObjectTypeConstraints.ts, 12, 30))
}
bar(new A);
>bar : Symbol(bar, Decl(assignmentNonObjectTypeConstraints.ts, 10, 13))
>A : Symbol(A, Decl(assignmentNonObjectTypeConstraints.ts, 7, 9))
bar(new B);
>bar : Symbol(bar, Decl(assignmentNonObjectTypeConstraints.ts, 10, 13))
>B : Symbol(B, Decl(assignmentNonObjectTypeConstraints.ts, 9, 13))
@@ -0,0 +1,65 @@
=== tests/cases/compiler/assignmentNonObjectTypeConstraints.ts ===
const enum E { A, B, C }
>E : E
>A : E
>B : E
>C : E
function foo<T extends number>(x: T) {
>foo : <T extends number>(x: T) => void
>T : T
>x : T
>T : T
var y: number = x; // Ok
>y : number
>x : T
}
foo(5);
>foo(5) : void
>foo : <T extends number>(x: T) => void
>5 : number
foo(E.A);
>foo(E.A) : void
>foo : <T extends number>(x: T) => void
>E.A : E
>E : typeof E
>A : E
class A { a }
>A : A
>a : any
class B { b }
>B : B
>b : any
function bar<T extends A | B>(x: T) {
>bar : <T extends A | B>(x: T) => void
>T : T
>A : A
>B : B
>x : T
>T : T
var y: A | B = x; // Ok
>y : A | B
>A : A
>B : B
>x : T
}
bar(new A);
>bar(new A) : void
>bar : <T extends A | B>(x: T) => void
>new A : A
>A : typeof A
bar(new B);
>bar(new B) : void
>bar : <T extends A | B>(x: T) => void
>new B : B
>B : typeof B
@@ -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
@@ -0,0 +1,37 @@
//// [constEnumToStringNoComments.ts]
const enum Foo {
X = 100,
Y = 0.5,
Z = 2.,
A = -1,
B = -1.5,
C = -1.
}
let x0 = Foo.X.toString();
let x1 = Foo["X"].toString();
let y0 = Foo.Y.toString();
let y1 = Foo["Y"].toString();
let z0 = Foo.Z.toString();
let z1 = Foo["Z"].toString();
let a0 = Foo.A.toString();
let a1 = Foo["A"].toString();
let b0 = Foo.B.toString();
let b1 = Foo["B"].toString();
let c0 = Foo.C.toString();
let c1 = Foo["C"].toString();
//// [constEnumToStringNoComments.js]
var x0 = 100 .toString();
var x1 = 100 .toString();
var y0 = 0.5.toString();
var y1 = 0.5.toString();
var z0 = 2 .toString();
var z1 = 2 .toString();
var a0 = -1 .toString();
var a1 = -1 .toString();
var b0 = -1.5.toString();
var b1 = -1.5.toString();
var c0 = -1 .toString();
var c1 = -1 .toString();
@@ -0,0 +1,113 @@
=== tests/cases/compiler/constEnumToStringNoComments.ts ===
const enum Foo {
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
X = 100,
>X : Symbol(Foo.X, Decl(constEnumToStringNoComments.ts, 0, 16))
Y = 0.5,
>Y : Symbol(Foo.Y, Decl(constEnumToStringNoComments.ts, 1, 12))
Z = 2.,
>Z : Symbol(Foo.Z, Decl(constEnumToStringNoComments.ts, 2, 12))
A = -1,
>A : Symbol(Foo.A, Decl(constEnumToStringNoComments.ts, 3, 11))
B = -1.5,
>B : Symbol(Foo.B, Decl(constEnumToStringNoComments.ts, 4, 11))
C = -1.
>C : Symbol(Foo.C, Decl(constEnumToStringNoComments.ts, 5, 13))
}
let x0 = Foo.X.toString();
>x0 : Symbol(x0, Decl(constEnumToStringNoComments.ts, 9, 3))
>Foo.X.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.X : Symbol(Foo.X, Decl(constEnumToStringNoComments.ts, 0, 16))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>X : Symbol(Foo.X, Decl(constEnumToStringNoComments.ts, 0, 16))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let x1 = Foo["X"].toString();
>x1 : Symbol(x1, Decl(constEnumToStringNoComments.ts, 10, 3))
>Foo["X"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>"X" : Symbol(Foo.X, Decl(constEnumToStringNoComments.ts, 0, 16))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let y0 = Foo.Y.toString();
>y0 : Symbol(y0, Decl(constEnumToStringNoComments.ts, 11, 3))
>Foo.Y.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.Y : Symbol(Foo.Y, Decl(constEnumToStringNoComments.ts, 1, 12))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>Y : Symbol(Foo.Y, Decl(constEnumToStringNoComments.ts, 1, 12))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let y1 = Foo["Y"].toString();
>y1 : Symbol(y1, Decl(constEnumToStringNoComments.ts, 12, 3))
>Foo["Y"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>"Y" : Symbol(Foo.Y, Decl(constEnumToStringNoComments.ts, 1, 12))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let z0 = Foo.Z.toString();
>z0 : Symbol(z0, Decl(constEnumToStringNoComments.ts, 13, 3))
>Foo.Z.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.Z : Symbol(Foo.Z, Decl(constEnumToStringNoComments.ts, 2, 12))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>Z : Symbol(Foo.Z, Decl(constEnumToStringNoComments.ts, 2, 12))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let z1 = Foo["Z"].toString();
>z1 : Symbol(z1, Decl(constEnumToStringNoComments.ts, 14, 3))
>Foo["Z"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>"Z" : Symbol(Foo.Z, Decl(constEnumToStringNoComments.ts, 2, 12))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let a0 = Foo.A.toString();
>a0 : Symbol(a0, Decl(constEnumToStringNoComments.ts, 15, 3))
>Foo.A.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.A : Symbol(Foo.A, Decl(constEnumToStringNoComments.ts, 3, 11))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>A : Symbol(Foo.A, Decl(constEnumToStringNoComments.ts, 3, 11))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let a1 = Foo["A"].toString();
>a1 : Symbol(a1, Decl(constEnumToStringNoComments.ts, 16, 3))
>Foo["A"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>"A" : Symbol(Foo.A, Decl(constEnumToStringNoComments.ts, 3, 11))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let b0 = Foo.B.toString();
>b0 : Symbol(b0, Decl(constEnumToStringNoComments.ts, 17, 3))
>Foo.B.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.B : Symbol(Foo.B, Decl(constEnumToStringNoComments.ts, 4, 11))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>B : Symbol(Foo.B, Decl(constEnumToStringNoComments.ts, 4, 11))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let b1 = Foo["B"].toString();
>b1 : Symbol(b1, Decl(constEnumToStringNoComments.ts, 18, 3))
>Foo["B"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>"B" : Symbol(Foo.B, Decl(constEnumToStringNoComments.ts, 4, 11))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let c0 = Foo.C.toString();
>c0 : Symbol(c0, Decl(constEnumToStringNoComments.ts, 19, 3))
>Foo.C.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.C : Symbol(Foo.C, Decl(constEnumToStringNoComments.ts, 5, 13))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>C : Symbol(Foo.C, Decl(constEnumToStringNoComments.ts, 5, 13))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let c1 = Foo["C"].toString();
>c1 : Symbol(c1, Decl(constEnumToStringNoComments.ts, 20, 3))
>Foo["C"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringNoComments.ts, 0, 0))
>"C" : Symbol(Foo.C, Decl(constEnumToStringNoComments.ts, 5, 13))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
@@ -0,0 +1,140 @@
=== tests/cases/compiler/constEnumToStringNoComments.ts ===
const enum Foo {
>Foo : Foo
X = 100,
>X : Foo
>100 : number
Y = 0.5,
>Y : Foo
>0.5 : number
Z = 2.,
>Z : Foo
>2. : number
A = -1,
>A : Foo
>-1 : number
>1 : number
B = -1.5,
>B : Foo
>-1.5 : number
>1.5 : number
C = -1.
>C : Foo
>-1. : number
>1. : number
}
let x0 = Foo.X.toString();
>x0 : string
>Foo.X.toString() : string
>Foo.X.toString : (radix?: number) => string
>Foo.X : Foo
>Foo : typeof Foo
>X : Foo
>toString : (radix?: number) => string
let x1 = Foo["X"].toString();
>x1 : string
>Foo["X"].toString() : string
>Foo["X"].toString : (radix?: number) => string
>Foo["X"] : Foo
>Foo : typeof Foo
>"X" : string
>toString : (radix?: number) => string
let y0 = Foo.Y.toString();
>y0 : string
>Foo.Y.toString() : string
>Foo.Y.toString : (radix?: number) => string
>Foo.Y : Foo
>Foo : typeof Foo
>Y : Foo
>toString : (radix?: number) => string
let y1 = Foo["Y"].toString();
>y1 : string
>Foo["Y"].toString() : string
>Foo["Y"].toString : (radix?: number) => string
>Foo["Y"] : Foo
>Foo : typeof Foo
>"Y" : string
>toString : (radix?: number) => string
let z0 = Foo.Z.toString();
>z0 : string
>Foo.Z.toString() : string
>Foo.Z.toString : (radix?: number) => string
>Foo.Z : Foo
>Foo : typeof Foo
>Z : Foo
>toString : (radix?: number) => string
let z1 = Foo["Z"].toString();
>z1 : string
>Foo["Z"].toString() : string
>Foo["Z"].toString : (radix?: number) => string
>Foo["Z"] : Foo
>Foo : typeof Foo
>"Z" : string
>toString : (radix?: number) => string
let a0 = Foo.A.toString();
>a0 : string
>Foo.A.toString() : string
>Foo.A.toString : (radix?: number) => string
>Foo.A : Foo
>Foo : typeof Foo
>A : Foo
>toString : (radix?: number) => string
let a1 = Foo["A"].toString();
>a1 : string
>Foo["A"].toString() : string
>Foo["A"].toString : (radix?: number) => string
>Foo["A"] : Foo
>Foo : typeof Foo
>"A" : string
>toString : (radix?: number) => string
let b0 = Foo.B.toString();
>b0 : string
>Foo.B.toString() : string
>Foo.B.toString : (radix?: number) => string
>Foo.B : Foo
>Foo : typeof Foo
>B : Foo
>toString : (radix?: number) => string
let b1 = Foo["B"].toString();
>b1 : string
>Foo["B"].toString() : string
>Foo["B"].toString : (radix?: number) => string
>Foo["B"] : Foo
>Foo : typeof Foo
>"B" : string
>toString : (radix?: number) => string
let c0 = Foo.C.toString();
>c0 : string
>Foo.C.toString() : string
>Foo.C.toString : (radix?: number) => string
>Foo.C : Foo
>Foo : typeof Foo
>C : Foo
>toString : (radix?: number) => string
let c1 = Foo["C"].toString();
>c1 : string
>Foo["C"].toString() : string
>Foo["C"].toString : (radix?: number) => string
>Foo["C"] : Foo
>Foo : typeof Foo
>"C" : string
>toString : (radix?: number) => string
@@ -0,0 +1,37 @@
//// [constEnumToStringWithComments.ts]
const enum Foo {
X = 100,
Y = 0.5,
Z = 2.,
A = -1,
B = -1.5,
C = -1.
}
let x0 = Foo.X.toString();
let x1 = Foo["X"].toString();
let y0 = Foo.Y.toString();
let y1 = Foo["Y"].toString();
let z0 = Foo.Z.toString();
let z1 = Foo["Z"].toString();
let a0 = Foo.A.toString();
let a1 = Foo["A"].toString();
let b0 = Foo.B.toString();
let b1 = Foo["B"].toString();
let c0 = Foo.C.toString();
let c1 = Foo["C"].toString();
//// [constEnumToStringWithComments.js]
var x0 = 100 /* X */ .toString();
var x1 = 100 /* "X" */ .toString();
var y0 = 0.5 /* Y */.toString();
var y1 = 0.5 /* "Y" */.toString();
var z0 = 2 /* Z */ .toString();
var z1 = 2 /* "Z" */ .toString();
var a0 = -1 /* A */ .toString();
var a1 = -1 /* "A" */ .toString();
var b0 = -1.5 /* B */.toString();
var b1 = -1.5 /* "B" */.toString();
var c0 = -1 /* C */ .toString();
var c1 = -1 /* "C" */ .toString();
@@ -0,0 +1,113 @@
=== tests/cases/compiler/constEnumToStringWithComments.ts ===
const enum Foo {
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
X = 100,
>X : Symbol(Foo.X, Decl(constEnumToStringWithComments.ts, 0, 16))
Y = 0.5,
>Y : Symbol(Foo.Y, Decl(constEnumToStringWithComments.ts, 1, 12))
Z = 2.,
>Z : Symbol(Foo.Z, Decl(constEnumToStringWithComments.ts, 2, 12))
A = -1,
>A : Symbol(Foo.A, Decl(constEnumToStringWithComments.ts, 3, 11))
B = -1.5,
>B : Symbol(Foo.B, Decl(constEnumToStringWithComments.ts, 4, 11))
C = -1.
>C : Symbol(Foo.C, Decl(constEnumToStringWithComments.ts, 5, 13))
}
let x0 = Foo.X.toString();
>x0 : Symbol(x0, Decl(constEnumToStringWithComments.ts, 9, 3))
>Foo.X.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.X : Symbol(Foo.X, Decl(constEnumToStringWithComments.ts, 0, 16))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>X : Symbol(Foo.X, Decl(constEnumToStringWithComments.ts, 0, 16))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let x1 = Foo["X"].toString();
>x1 : Symbol(x1, Decl(constEnumToStringWithComments.ts, 10, 3))
>Foo["X"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>"X" : Symbol(Foo.X, Decl(constEnumToStringWithComments.ts, 0, 16))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let y0 = Foo.Y.toString();
>y0 : Symbol(y0, Decl(constEnumToStringWithComments.ts, 11, 3))
>Foo.Y.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.Y : Symbol(Foo.Y, Decl(constEnumToStringWithComments.ts, 1, 12))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>Y : Symbol(Foo.Y, Decl(constEnumToStringWithComments.ts, 1, 12))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let y1 = Foo["Y"].toString();
>y1 : Symbol(y1, Decl(constEnumToStringWithComments.ts, 12, 3))
>Foo["Y"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>"Y" : Symbol(Foo.Y, Decl(constEnumToStringWithComments.ts, 1, 12))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let z0 = Foo.Z.toString();
>z0 : Symbol(z0, Decl(constEnumToStringWithComments.ts, 13, 3))
>Foo.Z.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.Z : Symbol(Foo.Z, Decl(constEnumToStringWithComments.ts, 2, 12))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>Z : Symbol(Foo.Z, Decl(constEnumToStringWithComments.ts, 2, 12))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let z1 = Foo["Z"].toString();
>z1 : Symbol(z1, Decl(constEnumToStringWithComments.ts, 14, 3))
>Foo["Z"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>"Z" : Symbol(Foo.Z, Decl(constEnumToStringWithComments.ts, 2, 12))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let a0 = Foo.A.toString();
>a0 : Symbol(a0, Decl(constEnumToStringWithComments.ts, 15, 3))
>Foo.A.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.A : Symbol(Foo.A, Decl(constEnumToStringWithComments.ts, 3, 11))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>A : Symbol(Foo.A, Decl(constEnumToStringWithComments.ts, 3, 11))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let a1 = Foo["A"].toString();
>a1 : Symbol(a1, Decl(constEnumToStringWithComments.ts, 16, 3))
>Foo["A"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>"A" : Symbol(Foo.A, Decl(constEnumToStringWithComments.ts, 3, 11))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let b0 = Foo.B.toString();
>b0 : Symbol(b0, Decl(constEnumToStringWithComments.ts, 17, 3))
>Foo.B.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.B : Symbol(Foo.B, Decl(constEnumToStringWithComments.ts, 4, 11))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>B : Symbol(Foo.B, Decl(constEnumToStringWithComments.ts, 4, 11))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let b1 = Foo["B"].toString();
>b1 : Symbol(b1, Decl(constEnumToStringWithComments.ts, 18, 3))
>Foo["B"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>"B" : Symbol(Foo.B, Decl(constEnumToStringWithComments.ts, 4, 11))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let c0 = Foo.C.toString();
>c0 : Symbol(c0, Decl(constEnumToStringWithComments.ts, 19, 3))
>Foo.C.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo.C : Symbol(Foo.C, Decl(constEnumToStringWithComments.ts, 5, 13))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>C : Symbol(Foo.C, Decl(constEnumToStringWithComments.ts, 5, 13))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
let c1 = Foo["C"].toString();
>c1 : Symbol(c1, Decl(constEnumToStringWithComments.ts, 20, 3))
>Foo["C"].toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
>Foo : Symbol(Foo, Decl(constEnumToStringWithComments.ts, 0, 0))
>"C" : Symbol(Foo.C, Decl(constEnumToStringWithComments.ts, 5, 13))
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
@@ -0,0 +1,140 @@
=== tests/cases/compiler/constEnumToStringWithComments.ts ===
const enum Foo {
>Foo : Foo
X = 100,
>X : Foo
>100 : number
Y = 0.5,
>Y : Foo
>0.5 : number
Z = 2.,
>Z : Foo
>2. : number
A = -1,
>A : Foo
>-1 : number
>1 : number
B = -1.5,
>B : Foo
>-1.5 : number
>1.5 : number
C = -1.
>C : Foo
>-1. : number
>1. : number
}
let x0 = Foo.X.toString();
>x0 : string
>Foo.X.toString() : string
>Foo.X.toString : (radix?: number) => string
>Foo.X : Foo
>Foo : typeof Foo
>X : Foo
>toString : (radix?: number) => string
let x1 = Foo["X"].toString();
>x1 : string
>Foo["X"].toString() : string
>Foo["X"].toString : (radix?: number) => string
>Foo["X"] : Foo
>Foo : typeof Foo
>"X" : string
>toString : (radix?: number) => string
let y0 = Foo.Y.toString();
>y0 : string
>Foo.Y.toString() : string
>Foo.Y.toString : (radix?: number) => string
>Foo.Y : Foo
>Foo : typeof Foo
>Y : Foo
>toString : (radix?: number) => string
let y1 = Foo["Y"].toString();
>y1 : string
>Foo["Y"].toString() : string
>Foo["Y"].toString : (radix?: number) => string
>Foo["Y"] : Foo
>Foo : typeof Foo
>"Y" : string
>toString : (radix?: number) => string
let z0 = Foo.Z.toString();
>z0 : string
>Foo.Z.toString() : string
>Foo.Z.toString : (radix?: number) => string
>Foo.Z : Foo
>Foo : typeof Foo
>Z : Foo
>toString : (radix?: number) => string
let z1 = Foo["Z"].toString();
>z1 : string
>Foo["Z"].toString() : string
>Foo["Z"].toString : (radix?: number) => string
>Foo["Z"] : Foo
>Foo : typeof Foo
>"Z" : string
>toString : (radix?: number) => string
let a0 = Foo.A.toString();
>a0 : string
>Foo.A.toString() : string
>Foo.A.toString : (radix?: number) => string
>Foo.A : Foo
>Foo : typeof Foo
>A : Foo
>toString : (radix?: number) => string
let a1 = Foo["A"].toString();
>a1 : string
>Foo["A"].toString() : string
>Foo["A"].toString : (radix?: number) => string
>Foo["A"] : Foo
>Foo : typeof Foo
>"A" : string
>toString : (radix?: number) => string
let b0 = Foo.B.toString();
>b0 : string
>Foo.B.toString() : string
>Foo.B.toString : (radix?: number) => string
>Foo.B : Foo
>Foo : typeof Foo
>B : Foo
>toString : (radix?: number) => string
let b1 = Foo["B"].toString();
>b1 : string
>Foo["B"].toString() : string
>Foo["B"].toString : (radix?: number) => string
>Foo["B"] : Foo
>Foo : typeof Foo
>"B" : string
>toString : (radix?: number) => string
let c0 = Foo.C.toString();
>c0 : string
>Foo.C.toString() : string
>Foo.C.toString : (radix?: number) => string
>Foo.C : Foo
>Foo : typeof Foo
>C : Foo
>toString : (radix?: number) => string
let c1 = Foo["C"].toString();
>c1 : string
>Foo["C"].toString() : string
>Foo["C"].toString : (radix?: number) => string
>Foo["C"] : Foo
>Foo : typeof Foo
>"C" : string
>toString : (radix?: number) => string
@@ -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

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