Merge branch 'master' into tscJsFiles

This commit is contained in:
Sheetal Nandi
2015-10-12 12:51:24 -07:00
51 changed files with 2218 additions and 64 deletions

View File

@@ -0,0 +1,47 @@
//// [constIndexedAccess.ts]
const enum numbers {
zero,
one
}
interface indexAccess {
0: string;
1: number;
}
let test: indexAccess;
let s = test[0];
let n = test[1];
let s1 = test[numbers.zero];
let n1 = test[numbers.one];
let s2 = test[numbers["zero"]];
let n2 = test[numbers["one"]];
enum numbersNotConst {
zero,
one
}
let s3 = test[numbersNotConst.zero];
let n3 = test[numbersNotConst.one];
//// [constIndexedAccess.js]
var test;
var s = test[0];
var n = test[1];
var s1 = test[0 /* zero */];
var n1 = test[1 /* one */];
var s2 = test[0 /* "zero" */];
var n2 = test[1 /* "one" */];
var numbersNotConst;
(function (numbersNotConst) {
numbersNotConst[numbersNotConst["zero"] = 0] = "zero";
numbersNotConst[numbersNotConst["one"] = 1] = "one";
})(numbersNotConst || (numbersNotConst = {}));
var s3 = test[numbersNotConst.zero];
var n3 = test[numbersNotConst.one];

View File

@@ -0,0 +1,83 @@
=== tests/cases/compiler/constIndexedAccess.ts ===
const enum numbers {
>numbers : Symbol(numbers, Decl(constIndexedAccess.ts, 0, 0))
zero,
>zero : Symbol(numbers.zero, Decl(constIndexedAccess.ts, 1, 20))
one
>one : Symbol(numbers.one, Decl(constIndexedAccess.ts, 2, 9))
}
interface indexAccess {
>indexAccess : Symbol(indexAccess, Decl(constIndexedAccess.ts, 4, 1))
0: string;
1: number;
}
let test: indexAccess;
>test : Symbol(test, Decl(constIndexedAccess.ts, 11, 3))
>indexAccess : Symbol(indexAccess, Decl(constIndexedAccess.ts, 4, 1))
let s = test[0];
>s : Symbol(s, Decl(constIndexedAccess.ts, 13, 3))
>test : Symbol(test, Decl(constIndexedAccess.ts, 11, 3))
>0 : Symbol(indexAccess.0, Decl(constIndexedAccess.ts, 6, 23))
let n = test[1];
>n : Symbol(n, Decl(constIndexedAccess.ts, 14, 3))
>test : Symbol(test, Decl(constIndexedAccess.ts, 11, 3))
>1 : Symbol(indexAccess.1, Decl(constIndexedAccess.ts, 7, 14))
let s1 = test[numbers.zero];
>s1 : Symbol(s1, Decl(constIndexedAccess.ts, 16, 3))
>test : Symbol(test, Decl(constIndexedAccess.ts, 11, 3))
>numbers.zero : Symbol(numbers.zero, Decl(constIndexedAccess.ts, 1, 20))
>numbers : Symbol(numbers, Decl(constIndexedAccess.ts, 0, 0))
>zero : Symbol(numbers.zero, Decl(constIndexedAccess.ts, 1, 20))
let n1 = test[numbers.one];
>n1 : Symbol(n1, Decl(constIndexedAccess.ts, 17, 3))
>test : Symbol(test, Decl(constIndexedAccess.ts, 11, 3))
>numbers.one : Symbol(numbers.one, Decl(constIndexedAccess.ts, 2, 9))
>numbers : Symbol(numbers, Decl(constIndexedAccess.ts, 0, 0))
>one : Symbol(numbers.one, Decl(constIndexedAccess.ts, 2, 9))
let s2 = test[numbers["zero"]];
>s2 : Symbol(s2, Decl(constIndexedAccess.ts, 19, 3))
>test : Symbol(test, Decl(constIndexedAccess.ts, 11, 3))
>numbers : Symbol(numbers, Decl(constIndexedAccess.ts, 0, 0))
>"zero" : Symbol(numbers.zero, Decl(constIndexedAccess.ts, 1, 20))
let n2 = test[numbers["one"]];
>n2 : Symbol(n2, Decl(constIndexedAccess.ts, 20, 3))
>test : Symbol(test, Decl(constIndexedAccess.ts, 11, 3))
>numbers : Symbol(numbers, Decl(constIndexedAccess.ts, 0, 0))
>"one" : Symbol(numbers.one, Decl(constIndexedAccess.ts, 2, 9))
enum numbersNotConst {
>numbersNotConst : Symbol(numbersNotConst, Decl(constIndexedAccess.ts, 20, 30))
zero,
>zero : Symbol(numbersNotConst.zero, Decl(constIndexedAccess.ts, 22, 22))
one
>one : Symbol(numbersNotConst.one, Decl(constIndexedAccess.ts, 23, 9))
}
let s3 = test[numbersNotConst.zero];
>s3 : Symbol(s3, Decl(constIndexedAccess.ts, 27, 3))
>test : Symbol(test, Decl(constIndexedAccess.ts, 11, 3))
>numbersNotConst.zero : Symbol(numbersNotConst.zero, Decl(constIndexedAccess.ts, 22, 22))
>numbersNotConst : Symbol(numbersNotConst, Decl(constIndexedAccess.ts, 20, 30))
>zero : Symbol(numbersNotConst.zero, Decl(constIndexedAccess.ts, 22, 22))
let n3 = test[numbersNotConst.one];
>n3 : Symbol(n3, Decl(constIndexedAccess.ts, 28, 3))
>test : Symbol(test, Decl(constIndexedAccess.ts, 11, 3))
>numbersNotConst.one : Symbol(numbersNotConst.one, Decl(constIndexedAccess.ts, 23, 9))
>numbersNotConst : Symbol(numbersNotConst, Decl(constIndexedAccess.ts, 20, 30))
>one : Symbol(numbersNotConst.one, Decl(constIndexedAccess.ts, 23, 9))

View File

@@ -0,0 +1,93 @@
=== tests/cases/compiler/constIndexedAccess.ts ===
const enum numbers {
>numbers : numbers
zero,
>zero : numbers
one
>one : numbers
}
interface indexAccess {
>indexAccess : indexAccess
0: string;
1: number;
}
let test: indexAccess;
>test : indexAccess
>indexAccess : indexAccess
let s = test[0];
>s : string
>test[0] : string
>test : indexAccess
>0 : number
let n = test[1];
>n : number
>test[1] : number
>test : indexAccess
>1 : number
let s1 = test[numbers.zero];
>s1 : string
>test[numbers.zero] : string
>test : indexAccess
>numbers.zero : numbers
>numbers : typeof numbers
>zero : numbers
let n1 = test[numbers.one];
>n1 : number
>test[numbers.one] : number
>test : indexAccess
>numbers.one : numbers
>numbers : typeof numbers
>one : numbers
let s2 = test[numbers["zero"]];
>s2 : string
>test[numbers["zero"]] : string
>test : indexAccess
>numbers["zero"] : numbers
>numbers : typeof numbers
>"zero" : string
let n2 = test[numbers["one"]];
>n2 : number
>test[numbers["one"]] : number
>test : indexAccess
>numbers["one"] : numbers
>numbers : typeof numbers
>"one" : string
enum numbersNotConst {
>numbersNotConst : numbersNotConst
zero,
>zero : numbersNotConst
one
>one : numbersNotConst
}
let s3 = test[numbersNotConst.zero];
>s3 : any
>test[numbersNotConst.zero] : any
>test : indexAccess
>numbersNotConst.zero : numbersNotConst
>numbersNotConst : typeof numbersNotConst
>zero : numbersNotConst
let n3 = test[numbersNotConst.one];
>n3 : any
>test[numbersNotConst.one] : any
>test : indexAccess
>numbersNotConst.one : numbersNotConst
>numbersNotConst : typeof numbersNotConst
>one : numbersNotConst

View File

@@ -0,0 +1,16 @@
//// [defaultExportWithOverloads01.ts]
export default function f();
export default function f(x: string);
export default function f(...args: any[]) {
}
//// [defaultExportWithOverloads01.js]
function f() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = f;

View File

@@ -0,0 +1,13 @@
=== tests/cases/conformance/es6/modules/defaultExportWithOverloads01.ts ===
export default function f();
>f : Symbol(f, Decl(defaultExportWithOverloads01.ts, 0, 0), Decl(defaultExportWithOverloads01.ts, 1, 28), Decl(defaultExportWithOverloads01.ts, 2, 37))
export default function f(x: string);
>f : Symbol(f, Decl(defaultExportWithOverloads01.ts, 0, 0), Decl(defaultExportWithOverloads01.ts, 1, 28), Decl(defaultExportWithOverloads01.ts, 2, 37))
>x : Symbol(x, Decl(defaultExportWithOverloads01.ts, 2, 26))
export default function f(...args: any[]) {
>f : Symbol(f, Decl(defaultExportWithOverloads01.ts, 0, 0), Decl(defaultExportWithOverloads01.ts, 1, 28), Decl(defaultExportWithOverloads01.ts, 2, 37))
>args : Symbol(args, Decl(defaultExportWithOverloads01.ts, 3, 26))
}

View File

@@ -0,0 +1,13 @@
=== tests/cases/conformance/es6/modules/defaultExportWithOverloads01.ts ===
export default function f();
>f : { (): any; (x: string): any; }
export default function f(x: string);
>f : { (): any; (x: string): any; }
>x : string
export default function f(...args: any[]) {
>f : { (): any; (x: string): any; }
>args : any[]
}

View File

@@ -0,0 +1,44 @@
tests/cases/compiler/exportedBlockScopedDeclarations.ts(1,13): error TS2448: Block-scoped variable 'foo' used before its declaration.
tests/cases/compiler/exportedBlockScopedDeclarations.ts(2,20): error TS2448: Block-scoped variable 'bar' used before its declaration.
tests/cases/compiler/exportedBlockScopedDeclarations.ts(4,15): error TS2448: Block-scoped variable 'bar' used before its declaration.
tests/cases/compiler/exportedBlockScopedDeclarations.ts(7,22): error TS2448: Block-scoped variable 'bar' used before its declaration.
tests/cases/compiler/exportedBlockScopedDeclarations.ts(10,12): error TS2448: Block-scoped variable 'foo1' used before its declaration.
tests/cases/compiler/exportedBlockScopedDeclarations.ts(11,19): error TS2448: Block-scoped variable 'bar1' used before its declaration.
tests/cases/compiler/exportedBlockScopedDeclarations.ts(13,14): error TS2448: Block-scoped variable 'bar1' used before its declaration.
tests/cases/compiler/exportedBlockScopedDeclarations.ts(16,21): error TS2448: Block-scoped variable 'bar1' used before its declaration.
==== tests/cases/compiler/exportedBlockScopedDeclarations.ts (8 errors) ====
const foo = foo; // compile error
~~~
!!! error TS2448: Block-scoped variable 'foo' used before its declaration.
export const bar = bar; // should be compile error
~~~
!!! error TS2448: Block-scoped variable 'bar' used before its declaration.
function f() {
const bar = bar; // compile error
~~~
!!! error TS2448: Block-scoped variable 'bar' used before its declaration.
}
namespace NS {
export const bar = bar; // should be compile error
~~~
!!! error TS2448: Block-scoped variable 'bar' used before its declaration.
}
let foo1 = foo1; // compile error
~~~~
!!! error TS2448: Block-scoped variable 'foo1' used before its declaration.
export let bar1 = bar1; // should be compile error
~~~~
!!! error TS2448: Block-scoped variable 'bar1' used before its declaration.
function f1() {
let bar1 = bar1; // compile error
~~~~
!!! error TS2448: Block-scoped variable 'bar1' used before its declaration.
}
namespace NS1 {
export let bar1 = bar1; // should be compile error
~~~~
!!! error TS2448: Block-scoped variable 'bar1' used before its declaration.
}

View File

@@ -0,0 +1,40 @@
//// [exportedBlockScopedDeclarations.ts]
const foo = foo; // compile error
export const bar = bar; // should be compile error
function f() {
const bar = bar; // compile error
}
namespace NS {
export const bar = bar; // should be compile error
}
let foo1 = foo1; // compile error
export let bar1 = bar1; // should be compile error
function f1() {
let bar1 = bar1; // compile error
}
namespace NS1 {
export let bar1 = bar1; // should be compile error
}
//// [exportedBlockScopedDeclarations.js]
define(["require", "exports"], function (require, exports) {
var foo = foo; // compile error
exports.bar = exports.bar; // should be compile error
function f() {
var bar = bar; // compile error
}
var NS;
(function (NS) {
NS.bar = NS.bar; // should be compile error
})(NS || (NS = {}));
var foo1 = foo1; // compile error
exports.bar1 = exports.bar1; // should be compile error
function f1() {
var bar1 = bar1; // compile error
}
var NS1;
(function (NS1) {
NS1.bar1 = NS1.bar1; // should be compile error
})(NS1 || (NS1 = {}));
});

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/es6/for-ofStatements/for-of48.ts(4,12): error TS1005: ':' expected.
tests/cases/conformance/es6/for-ofStatements/for-of48.ts(4,10): error TS2322: Type 'boolean' is not assignable to type 'number'.
==== tests/cases/conformance/es6/for-ofStatements/for-of48.ts (1 errors) ====
@@ -6,8 +6,8 @@ tests/cases/conformance/es6/for-ofStatements/for-of48.ts(4,12): error TS1005: ':
var array = [{ x: "", y: true }]
enum E { x }
for ({x, y = E.x} of array) {
~
!!! error TS1005: ':' expected.
~
!!! error TS2322: Type 'boolean' is not assignable to type 'number'.
x;
y;
}

View File

@@ -14,7 +14,7 @@ var E;
(function (E) {
E[E["x"] = 0] = "x";
})(E || (E = {}));
for ({ x, y: = E.x } of array) {
for ({ x, y = E.x } of array) {
x;
y;
}

View File

@@ -0,0 +1,25 @@
//// [functionsInClassExpressions.ts]
let Foo = class {
constructor() {
this.bar++;
}
bar = 0;
inc = () => {
this.bar++;
}
m() { return this.bar; }
}
//// [functionsInClassExpressions.js]
var Foo = (function () {
function class_1() {
var _this = this;
this.bar = 0;
this.inc = function () {
_this.bar++;
};
this.bar++;
}
class_1.prototype.m = function () { return this.bar; };
return class_1;
})();

View File

@@ -0,0 +1,27 @@
=== tests/cases/compiler/functionsInClassExpressions.ts ===
let Foo = class {
>Foo : Symbol(Foo, Decl(functionsInClassExpressions.ts, 0, 3))
constructor() {
this.bar++;
>this.bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
>this : Symbol((Anonymous class), Decl(functionsInClassExpressions.ts, 0, 9))
>bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
}
bar = 0;
>bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
inc = () => {
>inc : Symbol((Anonymous class).inc, Decl(functionsInClassExpressions.ts, 4, 12))
this.bar++;
>this.bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
>this : Symbol((Anonymous class), Decl(functionsInClassExpressions.ts, 0, 9))
>bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
}
m() { return this.bar; }
>m : Symbol((Anonymous class).m, Decl(functionsInClassExpressions.ts, 7, 5))
>this.bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
>this : Symbol((Anonymous class), Decl(functionsInClassExpressions.ts, 0, 9))
>bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
}

View File

@@ -0,0 +1,32 @@
=== tests/cases/compiler/functionsInClassExpressions.ts ===
let Foo = class {
>Foo : typeof (Anonymous class)
>class { constructor() { this.bar++; } bar = 0; inc = () => { this.bar++; } m() { return this.bar; }} : typeof (Anonymous class)
constructor() {
this.bar++;
>this.bar++ : number
>this.bar : number
>this : this
>bar : number
}
bar = 0;
>bar : number
>0 : number
inc = () => {
>inc : () => void
>() => { this.bar++; } : () => void
this.bar++;
>this.bar++ : number
>this.bar : number
>this : this
>bar : number
}
m() { return this.bar; }
>m : () => number
>this.bar : number
>this : this
>bar : number
}

View File

@@ -1,6 +1,6 @@
tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2300: Duplicate identifier 'foo'.
tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2300: Duplicate identifier 'bar'.
tests/cases/conformance/es6/modules/m1.ts(11,1): error TS2300: Duplicate identifier 'default'.
tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2528: A module cannot have multiple default exports.
tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2528: A module cannot have multiple default exports.
tests/cases/conformance/es6/modules/m1.ts(11,1): error TS2528: A module cannot have multiple default exports.
tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof foo' is not callable. Did you mean to include 'new'?
@@ -8,20 +8,20 @@ tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typ
export default class foo {
~~~
!!! error TS2300: Duplicate identifier 'foo'.
!!! error TS2528: A module cannot have multiple default exports.
}
export default function bar() {
~~~
!!! error TS2300: Duplicate identifier 'bar'.
!!! error TS2528: A module cannot have multiple default exports.
}
var x = 10;
export default x;
~~~~~~~~~~~~~~~~~
!!! error TS2300: Duplicate identifier 'default'.
!!! error TS2528: A module cannot have multiple default exports.
==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ====
import Entity from "./m1"

View File

@@ -0,0 +1,15 @@
tests/cases/conformance/es6/modules/multipleDefaultExports03.ts(2,22): error TS2528: A module cannot have multiple default exports.
tests/cases/conformance/es6/modules/multipleDefaultExports03.ts(5,22): error TS2528: A module cannot have multiple default exports.
==== tests/cases/conformance/es6/modules/multipleDefaultExports03.ts (2 errors) ====
export default class C {
~
!!! error TS2528: A module cannot have multiple default exports.
}
export default class C {
~
!!! error TS2528: A module cannot have multiple default exports.
}

View File

@@ -0,0 +1,23 @@
//// [multipleDefaultExports03.ts]
export default class C {
}
export default class C {
}
//// [multipleDefaultExports03.js]
var C = (function () {
function C() {
}
return C;
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = C;
var C = (function () {
function C() {
}
return C;
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = C;

View File

@@ -0,0 +1,15 @@
tests/cases/conformance/es6/modules/multipleDefaultExports04.ts(2,25): error TS2393: Duplicate function implementation.
tests/cases/conformance/es6/modules/multipleDefaultExports04.ts(5,25): error TS2393: Duplicate function implementation.
==== tests/cases/conformance/es6/modules/multipleDefaultExports04.ts (2 errors) ====
export default function f() {
~
!!! error TS2393: Duplicate function implementation.
}
export default function f() {
~
!!! error TS2393: Duplicate function implementation.
}

View File

@@ -0,0 +1,17 @@
//// [multipleDefaultExports04.ts]
export default function f() {
}
export default function f() {
}
//// [multipleDefaultExports04.js]
function f() {
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = f;
function f() {
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = f;

View File

@@ -0,0 +1,164 @@
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(16,9): error TS2459: Type '{}' has no property 's1' and no string index signature.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(22,9): error TS2459: Type '{}' has no property 's1' and no string index signature.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(40,9): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(46,12): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(72,5): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(77,8): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(82,5): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(82,13): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
Types of property 'x' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(87,8): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(87,19): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
Types of property 'x' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(113,12): error TS2304: Cannot find name 's'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(113,14): error TS1312: '=' can only be used in an object literal property inside a destructuring assignment.
==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts (12 errors) ====
(function() {
var s0;
for ({ s0 = 5 } of [{ s0: 1 }]) {
}
});
(function() {
var s0;
for ({ s0:s0 = 5 } of [{ s0: 1 }]) {
}
});
(function() {
var s1;
for ({ s1 = 5 } of [{}]) {
~~
!!! error TS2459: Type '{}' has no property 's1' and no string index signature.
}
});
(function() {
var s1;
for ({ s1:s1 = 5 } of [{}]) {
~~
!!! error TS2459: Type '{}' has no property 's1' and no string index signature.
}
});
(function() {
var s2;
for ({ s2 = 5 } of [{ s2: "" }]) {
}
});
(function() {
var s2;
for ({ s2:s2 = 5 } of [{ s2: "" }]) {
}
});
(function() {
var s3: string;
for ({ s3 = 5 } of [{ s3: "" }]) {
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
}
});
(function() {
var s3: string;
for ({ s3:s3 = 5 } of [{ s3: "" }]) {
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
}
});
(function() {
let y;
({ y = 5 } = { y: 1 })
});
(function() {
let y;
({ y:y = 5 } = { y: 1 })
});
(function() {
let y0: number;
({ y0 = 5 } = { y0: 1 })
});
(function() {
let y0: number;
({ y0:y0 = 5 } = { y0: 1 })
});
(function() {
let y1: string;
({ y1 = 5 } = {})
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
});
(function() {
let y1: string;
({ y1:y1 = 5 } = {})
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
});
(function() {
let y2: string, y3: { x: string };
({ y2 = 5, y3 = { x: 1 } } = {})
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
~~
!!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
!!! error TS2322: Types of property 'x' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
});
(function() {
let y2: string, y3: { x: string };
({ y2:y2 = 5, y3:y3 = { x: 1 } } = {})
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
~~
!!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
!!! error TS2322: Types of property 'x' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
});
(function() {
let y4: number, y5: { x: number };
({ y4 = 5, y5 = { x: 1 } } = {})
});
(function() {
let y4: number, y5: { x: number };
({ y4:y4 = 5, y5:y5 = { x: 1 } } = {})
});
(function() {
let z;
({ z = { x: 5 } } = { z: { x: 1 } });
});
(function() {
let z;
({ z:z = { x: 5 } } = { z: { x: 1 } });
});
(function() {
let a = { s = 5 };
~
!!! error TS2304: Cannot find name 's'.
~
!!! error TS1312: '=' can only be used in an object literal property inside a destructuring assignment.
});
function foo({a = 4, b = { x: 5 }}) {
}

View File

@@ -0,0 +1,242 @@
//// [shorthandPropertyAssignmentsInDestructuring.ts]
(function() {
var s0;
for ({ s0 = 5 } of [{ s0: 1 }]) {
}
});
(function() {
var s0;
for ({ s0:s0 = 5 } of [{ s0: 1 }]) {
}
});
(function() {
var s1;
for ({ s1 = 5 } of [{}]) {
}
});
(function() {
var s1;
for ({ s1:s1 = 5 } of [{}]) {
}
});
(function() {
var s2;
for ({ s2 = 5 } of [{ s2: "" }]) {
}
});
(function() {
var s2;
for ({ s2:s2 = 5 } of [{ s2: "" }]) {
}
});
(function() {
var s3: string;
for ({ s3 = 5 } of [{ s3: "" }]) {
}
});
(function() {
var s3: string;
for ({ s3:s3 = 5 } of [{ s3: "" }]) {
}
});
(function() {
let y;
({ y = 5 } = { y: 1 })
});
(function() {
let y;
({ y:y = 5 } = { y: 1 })
});
(function() {
let y0: number;
({ y0 = 5 } = { y0: 1 })
});
(function() {
let y0: number;
({ y0:y0 = 5 } = { y0: 1 })
});
(function() {
let y1: string;
({ y1 = 5 } = {})
});
(function() {
let y1: string;
({ y1:y1 = 5 } = {})
});
(function() {
let y2: string, y3: { x: string };
({ y2 = 5, y3 = { x: 1 } } = {})
});
(function() {
let y2: string, y3: { x: string };
({ y2:y2 = 5, y3:y3 = { x: 1 } } = {})
});
(function() {
let y4: number, y5: { x: number };
({ y4 = 5, y5 = { x: 1 } } = {})
});
(function() {
let y4: number, y5: { x: number };
({ y4:y4 = 5, y5:y5 = { x: 1 } } = {})
});
(function() {
let z;
({ z = { x: 5 } } = { z: { x: 1 } });
});
(function() {
let z;
({ z:z = { x: 5 } } = { z: { x: 1 } });
});
(function() {
let a = { s = 5 };
});
function foo({a = 4, b = { x: 5 }}) {
}
//// [shorthandPropertyAssignmentsInDestructuring.js]
(function () {
var s0;
for (var _i = 0, _a = [{ s0: 1 }]; _i < _a.length; _i++) {
_b = _a[_i].s0, s0 = _b === void 0 ? 5 : _b;
}
var _b;
});
(function () {
var s0;
for (var _i = 0, _a = [{ s0: 1 }]; _i < _a.length; _i++) {
_b = _a[_i].s0, s0 = _b === void 0 ? 5 : _b;
}
var _b;
});
(function () {
var s1;
for (var _i = 0, _a = [{}]; _i < _a.length; _i++) {
_b = _a[_i].s1, s1 = _b === void 0 ? 5 : _b;
}
var _b;
});
(function () {
var s1;
for (var _i = 0, _a = [{}]; _i < _a.length; _i++) {
_b = _a[_i].s1, s1 = _b === void 0 ? 5 : _b;
}
var _b;
});
(function () {
var s2;
for (var _i = 0, _a = [{ s2: "" }]; _i < _a.length; _i++) {
_b = _a[_i].s2, s2 = _b === void 0 ? 5 : _b;
}
var _b;
});
(function () {
var s2;
for (var _i = 0, _a = [{ s2: "" }]; _i < _a.length; _i++) {
_b = _a[_i].s2, s2 = _b === void 0 ? 5 : _b;
}
var _b;
});
(function () {
var s3;
for (var _i = 0, _a = [{ s3: "" }]; _i < _a.length; _i++) {
_b = _a[_i].s3, s3 = _b === void 0 ? 5 : _b;
}
var _b;
});
(function () {
var s3;
for (var _i = 0, _a = [{ s3: "" }]; _i < _a.length; _i++) {
_b = _a[_i].s3, s3 = _b === void 0 ? 5 : _b;
}
var _b;
});
(function () {
var y;
(_a = { y: 1 }, _b = _a.y, y = _b === void 0 ? 5 : _b, _a);
var _a, _b;
});
(function () {
var y;
(_a = { y: 1 }, _b = _a.y, y = _b === void 0 ? 5 : _b, _a);
var _a, _b;
});
(function () {
var y0;
(_a = { y0: 1 }, _b = _a.y0, y0 = _b === void 0 ? 5 : _b, _a);
var _a, _b;
});
(function () {
var y0;
(_a = { y0: 1 }, _b = _a.y0, y0 = _b === void 0 ? 5 : _b, _a);
var _a, _b;
});
(function () {
var y1;
(_a = {}, _b = _a.y1, y1 = _b === void 0 ? 5 : _b, _a);
var _a, _b;
});
(function () {
var y1;
(_a = {}, _b = _a.y1, y1 = _b === void 0 ? 5 : _b, _a);
var _a, _b;
});
(function () {
var y2, y3;
(_a = {}, _b = _a.y2, y2 = _b === void 0 ? 5 : _b, _c = _a.y3, y3 = _c === void 0 ? { x: 1 } : _c, _a);
var _a, _b, _c;
});
(function () {
var y2, y3;
(_a = {}, _b = _a.y2, y2 = _b === void 0 ? 5 : _b, _c = _a.y3, y3 = _c === void 0 ? { x: 1 } : _c, _a);
var _a, _b, _c;
});
(function () {
var y4, y5;
(_a = {}, _b = _a.y4, y4 = _b === void 0 ? 5 : _b, _c = _a.y5, y5 = _c === void 0 ? { x: 1 } : _c, _a);
var _a, _b, _c;
});
(function () {
var y4, y5;
(_a = {}, _b = _a.y4, y4 = _b === void 0 ? 5 : _b, _c = _a.y5, y5 = _c === void 0 ? { x: 1 } : _c, _a);
var _a, _b, _c;
});
(function () {
var z;
(_a = { z: { x: 1 } }, _b = _a.z, z = _b === void 0 ? { x: 5 } : _b, _a);
var _a, _b;
});
(function () {
var z;
(_a = { z: { x: 1 } }, _b = _a.z, z = _b === void 0 ? { x: 5 } : _b, _a);
var _a, _b;
});
(function () {
var a = { s: s };
});
function foo(_a) {
var _b = _a.a, a = _b === void 0 ? 4 : _b, _c = _a.b, b = _c === void 0 ? { x: 5 } : _c;
}

View File

@@ -0,0 +1,164 @@
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(16,9): error TS2459: Type '{}' has no property 's1' and no string index signature.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(22,9): error TS2459: Type '{}' has no property 's1' and no string index signature.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(40,9): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(46,12): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(72,5): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(77,8): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(82,5): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(82,13): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
Types of property 'x' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(87,8): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(87,19): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
Types of property 'x' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(113,12): error TS2304: Cannot find name 's'.
tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(113,14): error TS1312: '=' can only be used in an object literal property inside a destructuring assignment.
==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts (12 errors) ====
(function() {
var s0;
for ({ s0 = 5 } of [{ s0: 1 }]) {
}
});
(function() {
var s0;
for ({ s0:s0 = 5 } of [{ s0: 1 }]) {
}
});
(function() {
var s1;
for ({ s1 = 5 } of [{}]) {
~~
!!! error TS2459: Type '{}' has no property 's1' and no string index signature.
}
});
(function() {
var s1;
for ({ s1:s1 = 5 } of [{}]) {
~~
!!! error TS2459: Type '{}' has no property 's1' and no string index signature.
}
});
(function() {
var s2;
for ({ s2 = 5 } of [{ s2: "" }]) {
}
});
(function() {
var s2;
for ({ s2:s2 = 5 } of [{ s2: "" }]) {
}
});
(function() {
var s3: string;
for ({ s3 = 5 } of [{ s3: "" }]) {
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
}
});
(function() {
var s3: string;
for ({ s3:s3 = 5 } of [{ s3: "" }]) {
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
}
});
(function() {
let y;
({ y = 5 } = { y: 1 })
});
(function() {
let y;
({ y:y = 5 } = { y: 1 })
});
(function() {
let y0: number;
({ y0 = 5 } = { y0: 1 })
});
(function() {
let y0: number;
({ y0:y0 = 5 } = { y0: 1 })
});
(function() {
let y1: string;
({ y1 = 5 } = {})
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
});
(function() {
let y1: string;
({ y1:y1 = 5 } = {})
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
});
(function() {
let y2: string, y3: { x: string };
({ y2 = 5, y3 = { x: 1 } } = {})
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
~~
!!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
!!! error TS2322: Types of property 'x' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
});
(function() {
let y2: string, y3: { x: string };
({ y2:y2 = 5, y3:y3 = { x: 1 } } = {})
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
~~
!!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
!!! error TS2322: Types of property 'x' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
});
(function() {
let y4: number, y5: { x: number };
({ y4 = 5, y5 = { x: 1 } } = {})
});
(function() {
let y4: number, y5: { x: number };
({ y4:y4 = 5, y5:y5 = { x: 1 } } = {})
});
(function() {
let z;
({ z = { x: 5 } } = { z: { x: 1 } });
});
(function() {
let z;
({ z:z = { x: 5 } } = { z: { x: 1 } });
});
(function() {
let a = { s = 5 };
~
!!! error TS2304: Cannot find name 's'.
~
!!! error TS1312: '=' can only be used in an object literal property inside a destructuring assignment.
});
function foo({a = 4, b = { x: 5 }}) {
}

View File

@@ -0,0 +1,213 @@
//// [shorthandPropertyAssignmentsInDestructuring_ES6.ts]
(function() {
var s0;
for ({ s0 = 5 } of [{ s0: 1 }]) {
}
});
(function() {
var s0;
for ({ s0:s0 = 5 } of [{ s0: 1 }]) {
}
});
(function() {
var s1;
for ({ s1 = 5 } of [{}]) {
}
});
(function() {
var s1;
for ({ s1:s1 = 5 } of [{}]) {
}
});
(function() {
var s2;
for ({ s2 = 5 } of [{ s2: "" }]) {
}
});
(function() {
var s2;
for ({ s2:s2 = 5 } of [{ s2: "" }]) {
}
});
(function() {
var s3: string;
for ({ s3 = 5 } of [{ s3: "" }]) {
}
});
(function() {
var s3: string;
for ({ s3:s3 = 5 } of [{ s3: "" }]) {
}
});
(function() {
let y;
({ y = 5 } = { y: 1 })
});
(function() {
let y;
({ y:y = 5 } = { y: 1 })
});
(function() {
let y0: number;
({ y0 = 5 } = { y0: 1 })
});
(function() {
let y0: number;
({ y0:y0 = 5 } = { y0: 1 })
});
(function() {
let y1: string;
({ y1 = 5 } = {})
});
(function() {
let y1: string;
({ y1:y1 = 5 } = {})
});
(function() {
let y2: string, y3: { x: string };
({ y2 = 5, y3 = { x: 1 } } = {})
});
(function() {
let y2: string, y3: { x: string };
({ y2:y2 = 5, y3:y3 = { x: 1 } } = {})
});
(function() {
let y4: number, y5: { x: number };
({ y4 = 5, y5 = { x: 1 } } = {})
});
(function() {
let y4: number, y5: { x: number };
({ y4:y4 = 5, y5:y5 = { x: 1 } } = {})
});
(function() {
let z;
({ z = { x: 5 } } = { z: { x: 1 } });
});
(function() {
let z;
({ z:z = { x: 5 } } = { z: { x: 1 } });
});
(function() {
let a = { s = 5 };
});
function foo({a = 4, b = { x: 5 }}) {
}
//// [shorthandPropertyAssignmentsInDestructuring_ES6.js]
(function () {
var s0;
for ({ s0 = 5 } of [{ s0: 1 }]) {
}
});
(function () {
var s0;
for ({ s0: s0 = 5 } of [{ s0: 1 }]) {
}
});
(function () {
var s1;
for ({ s1 = 5 } of [{}]) {
}
});
(function () {
var s1;
for ({ s1: s1 = 5 } of [{}]) {
}
});
(function () {
var s2;
for ({ s2 = 5 } of [{ s2: "" }]) {
}
});
(function () {
var s2;
for ({ s2: s2 = 5 } of [{ s2: "" }]) {
}
});
(function () {
var s3;
for ({ s3 = 5 } of [{ s3: "" }]) {
}
});
(function () {
var s3;
for ({ s3: s3 = 5 } of [{ s3: "" }]) {
}
});
(function () {
let y;
({ y = 5 } = { y: 1 });
});
(function () {
let y;
({ y: y = 5 } = { y: 1 });
});
(function () {
let y0;
({ y0 = 5 } = { y0: 1 });
});
(function () {
let y0;
({ y0: y0 = 5 } = { y0: 1 });
});
(function () {
let y1;
({ y1 = 5 } = {});
});
(function () {
let y1;
({ y1: y1 = 5 } = {});
});
(function () {
let y2, y3;
({ y2 = 5, y3 = { x: 1 } } = {});
});
(function () {
let y2, y3;
({ y2: y2 = 5, y3: y3 = { x: 1 } } = {});
});
(function () {
let y4, y5;
({ y4 = 5, y5 = { x: 1 } } = {});
});
(function () {
let y4, y5;
({ y4: y4 = 5, y5: y5 = { x: 1 } } = {});
});
(function () {
let z;
({ z = { x: 5 } } = { z: { x: 1 } });
});
(function () {
let z;
({ z: z = { x: 5 } } = { z: { x: 1 } });
});
(function () {
let a = { s = 5 };
});
function foo({ a = 4, b = { x: 5 } }) {
}

View File

@@ -19,7 +19,11 @@ namespace M {
// and M.React.__spread
var foo;
var spread1 = <div x='' {...foo} y='' />;
// Quotes
var x = <div>This "quote" thing</div>;
}
//// [file.js]
@@ -33,4 +37,6 @@ var M;
// and M.React.__spread
var foo;
var spread1 = M.React.createElement("div", M.React.__spread({x: ''}, foo, {y: ''}));
// Quotes
var x = M.React.createElement("div", null, "This \"quote\" thing");
})(M || (M = {}));

View File

@@ -36,5 +36,12 @@ namespace M {
>x : Symbol(unknown)
>foo : Symbol(foo, Decl(react-consumer.tsx, 7, 4))
>y : Symbol(unknown)
// Quotes
var x = <div>This "quote" thing</div>;
>x : Symbol(x, Decl(react-consumer.tsx, 11, 4))
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22))
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22))
}

View File

@@ -37,5 +37,13 @@ namespace M {
>x : any
>foo : any
>y : any
// Quotes
var x = <div>This "quote" thing</div>;
>x : JSX.Element
><div>This "quote" thing</div> : JSX.Element
>div : any
>div : any
}