mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add tests and baselines
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts(3,17): error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'.
|
||||
tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts(3,29): error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts (2 errors) ====
|
||||
declare function wrapper(x: any);
|
||||
wrapper((array: [any]) => {
|
||||
[this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this"
|
||||
~~~~~~~~~~
|
||||
!!! error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'.
|
||||
~~~~~~~~~~
|
||||
!!! error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'.
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [emitCapturingThisInTupleDestructuring1.ts]
|
||||
declare function wrapper(x: any);
|
||||
wrapper((array: [any]) => {
|
||||
[this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this"
|
||||
});
|
||||
|
||||
//// [emitCapturingThisInTupleDestructuring1.js]
|
||||
var _this = this;
|
||||
wrapper(function (array) {
|
||||
_this.test = array[0], _this.test1 = array[1], _this.test2 = array[2]; // even though there is a compiler error, we should still emit lexical capture for "this"
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts(8,39): error TS2493: Tuple type '[number, number]' with length '2' cannot be assigned to tuple with length '3'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts (1 errors) ====
|
||||
var array1: [number, number] = [1, 2];
|
||||
|
||||
class B {
|
||||
test: number;
|
||||
test1: any;
|
||||
test2: any;
|
||||
method() {
|
||||
() => [this.test, this.test1, this.test2] = array1; // even though there is a compiler error, we should still emit lexical capture for "this"
|
||||
~~~~~~~~~~
|
||||
!!! error TS2493: Tuple type '[number, number]' with length '2' cannot be assigned to tuple with length '3'.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [emitCapturingThisInTupleDestructuring2.ts]
|
||||
var array1: [number, number] = [1, 2];
|
||||
|
||||
class B {
|
||||
test: number;
|
||||
test1: any;
|
||||
test2: any;
|
||||
method() {
|
||||
() => [this.test, this.test1, this.test2] = array1; // even though there is a compiler error, we should still emit lexical capture for "this"
|
||||
}
|
||||
}
|
||||
|
||||
//// [emitCapturingThisInTupleDestructuring2.js]
|
||||
var array1 = [1, 2];
|
||||
var B = (function () {
|
||||
function B() {
|
||||
}
|
||||
B.prototype.method = function () {
|
||||
var _this = this;
|
||||
(function () { return (_this.test = array1[0], _this.test1 = array1[1], _this.test2 = array1[2], array1); }); // even though there is a compiler error, we should still emit lexical capture for "this"
|
||||
};
|
||||
return B;
|
||||
}());
|
||||
@@ -0,0 +1,4 @@
|
||||
declare function wrapper(x: any);
|
||||
wrapper((array: [any]) => {
|
||||
[this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this"
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
var array1: [number, number] = [1, 2];
|
||||
|
||||
class B {
|
||||
test: number;
|
||||
test1: any;
|
||||
test2: any;
|
||||
method() {
|
||||
() => [this.test, this.test1, this.test2] = array1; // even though there is a compiler error, we should still emit lexical capture for "this"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user