Added es5 conformance tests for async arrow functions, add error for referencing 'arguments' in a generator.
This commit is contained in:
parent
203dab4412
commit
644e4dacaf
|
@ -8162,10 +8162,13 @@ namespace ts {
|
|||
// can explicitly bound arguments objects
|
||||
if (symbol === argumentsSymbol) {
|
||||
const container = getContainingFunction(node);
|
||||
if (container.kind === SyntaxKind.ArrowFunction) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (container.kind === SyntaxKind.ArrowFunction) {
|
||||
error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
|
||||
}
|
||||
else if (hasModifier(container, ModifierFlags.Async)) {
|
||||
error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.flags & NodeFlags.AwaitContext) {
|
||||
|
|
|
@ -1695,7 +1695,7 @@
|
|||
"category": "Error",
|
||||
"code": 2521
|
||||
},
|
||||
"The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression.": {
|
||||
"The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method.": {
|
||||
"category": "Error",
|
||||
"code": 2522
|
||||
},
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
//// [arrowFunctionWithParameterNameAsync_es5.ts]
|
||||
|
||||
const x = async => async;
|
||||
|
||||
//// [arrowFunctionWithParameterNameAsync_es5.js]
|
||||
var x = function (async) { return async; };
|
|
@ -0,0 +1,7 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es5.ts ===
|
||||
|
||||
const x = async => async;
|
||||
>x : Symbol(x, Decl(arrowFunctionWithParameterNameAsync_es5.ts, 1, 5))
|
||||
>async : Symbol(async, Decl(arrowFunctionWithParameterNameAsync_es5.ts, 1, 9))
|
||||
>async : Symbol(async, Decl(arrowFunctionWithParameterNameAsync_es5.ts, 1, 9))
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es5.ts ===
|
||||
|
||||
const x = async => async;
|
||||
>x : (async: any) => any
|
||||
>async => async : (async: any) => any
|
||||
>async : any
|
||||
>async : any
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction10_es5.ts(4,11): error TS2304: Cannot find name 'await'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction10_es5.ts (1 errors) ====
|
||||
|
||||
var foo = async (): Promise<void> => {
|
||||
// Legal to use 'await' in a type context.
|
||||
var v: await;
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'await'.
|
||||
}
|
||||
|
16
tests/baselines/reference/asyncArrowFunction10_es5.js
Normal file
16
tests/baselines/reference/asyncArrowFunction10_es5.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
//// [asyncArrowFunction10_es5.ts]
|
||||
|
||||
var foo = async (): Promise<void> => {
|
||||
// Legal to use 'await' in a type context.
|
||||
var v: await;
|
||||
}
|
||||
|
||||
|
||||
//// [asyncArrowFunction10_es5.js]
|
||||
var _this = this;
|
||||
var foo = function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var v;
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); };
|
12
tests/baselines/reference/asyncArrowFunction1_es5.js
Normal file
12
tests/baselines/reference/asyncArrowFunction1_es5.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
//// [asyncArrowFunction1_es5.ts]
|
||||
|
||||
var foo = async (): Promise<void> => {
|
||||
};
|
||||
|
||||
//// [asyncArrowFunction1_es5.js]
|
||||
var _this = this;
|
||||
var foo = function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); };
|
|
@ -0,0 +1,7 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction1_es5.ts ===
|
||||
|
||||
var foo = async (): Promise<void> => {
|
||||
>foo : Symbol(foo, Decl(asyncArrowFunction1_es5.ts, 1, 3))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
|
||||
};
|
8
tests/baselines/reference/asyncArrowFunction1_es5.types
Normal file
8
tests/baselines/reference/asyncArrowFunction1_es5.types
Normal file
|
@ -0,0 +1,8 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction1_es5.ts ===
|
||||
|
||||
var foo = async (): Promise<void> => {
|
||||
>foo : () => Promise<void>
|
||||
>async (): Promise<void> => {} : () => Promise<void>
|
||||
>Promise : Promise<T>
|
||||
|
||||
};
|
7
tests/baselines/reference/asyncArrowFunction2_es5.js
Normal file
7
tests/baselines/reference/asyncArrowFunction2_es5.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
//// [asyncArrowFunction2_es5.ts]
|
||||
var f = (await) => {
|
||||
}
|
||||
|
||||
//// [asyncArrowFunction2_es5.js]
|
||||
var f = function (await) {
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction2_es5.ts ===
|
||||
var f = (await) => {
|
||||
>f : Symbol(f, Decl(asyncArrowFunction2_es5.ts, 0, 3))
|
||||
>await : Symbol(await, Decl(asyncArrowFunction2_es5.ts, 0, 9))
|
||||
}
|
6
tests/baselines/reference/asyncArrowFunction2_es5.types
Normal file
6
tests/baselines/reference/asyncArrowFunction2_es5.types
Normal file
|
@ -0,0 +1,6 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction2_es5.ts ===
|
||||
var f = (await) => {
|
||||
>f : (await: any) => void
|
||||
>(await) => {} : (await: any) => void
|
||||
>await : any
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction3_es5.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction3_es5.ts (1 errors) ====
|
||||
function f(await = await) {
|
||||
~~~~~
|
||||
!!! error TS2372: Parameter 'await' cannot be referenced in its initializer.
|
||||
}
|
8
tests/baselines/reference/asyncArrowFunction3_es5.js
Normal file
8
tests/baselines/reference/asyncArrowFunction3_es5.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [asyncArrowFunction3_es5.ts]
|
||||
function f(await = await) {
|
||||
}
|
||||
|
||||
//// [asyncArrowFunction3_es5.js]
|
||||
function f(await) {
|
||||
if (await === void 0) { await = await; }
|
||||
}
|
7
tests/baselines/reference/asyncArrowFunction4_es5.js
Normal file
7
tests/baselines/reference/asyncArrowFunction4_es5.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
//// [asyncArrowFunction4_es5.ts]
|
||||
var await = () => {
|
||||
}
|
||||
|
||||
//// [asyncArrowFunction4_es5.js]
|
||||
var await = function () {
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction4_es5.ts ===
|
||||
var await = () => {
|
||||
>await : Symbol(await, Decl(asyncArrowFunction4_es5.ts, 0, 3))
|
||||
}
|
5
tests/baselines/reference/asyncArrowFunction4_es5.types
Normal file
5
tests/baselines/reference/asyncArrowFunction4_es5.types
Normal file
|
@ -0,0 +1,5 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction4_es5.ts ===
|
||||
var await = () => {
|
||||
>await : () => void
|
||||
>() => {} : () => void
|
||||
}
|
24
tests/baselines/reference/asyncArrowFunction5_es5.errors.txt
Normal file
24
tests/baselines/reference/asyncArrowFunction5_es5.errors.txt
Normal file
|
@ -0,0 +1,24 @@
|
|||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(2,11): error TS2304: Cannot find name 'async'.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(2,18): error TS2304: Cannot find name 'await'.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(2,24): error TS1005: ',' expected.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(2,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(2,33): error TS1005: '=' expected.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(2,40): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts (6 errors) ====
|
||||
|
||||
var foo = async (await): Promise<void> => {
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'async'.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'await'.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~~~~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'.
|
||||
~
|
||||
!!! error TS1005: '=' expected.
|
||||
~~
|
||||
!!! error TS1109: Expression expected.
|
||||
}
|
9
tests/baselines/reference/asyncArrowFunction5_es5.js
Normal file
9
tests/baselines/reference/asyncArrowFunction5_es5.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
//// [asyncArrowFunction5_es5.ts]
|
||||
|
||||
var foo = async (await): Promise<void> => {
|
||||
}
|
||||
|
||||
//// [asyncArrowFunction5_es5.js]
|
||||
var foo = async(await), Promise = ;
|
||||
{
|
||||
}
|
12
tests/baselines/reference/asyncArrowFunction6_es5.errors.txt
Normal file
12
tests/baselines/reference/asyncArrowFunction6_es5.errors.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction6_es5.ts(2,22): error TS2524: 'await' expressions cannot be used in a parameter initializer.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction6_es5.ts(2,27): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction6_es5.ts (2 errors) ====
|
||||
|
||||
var foo = async (a = await): Promise<void> => {
|
||||
~~~~~
|
||||
!!! error TS2524: 'await' expressions cannot be used in a parameter initializer.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
}
|
15
tests/baselines/reference/asyncArrowFunction6_es5.js
Normal file
15
tests/baselines/reference/asyncArrowFunction6_es5.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
//// [asyncArrowFunction6_es5.ts]
|
||||
|
||||
var foo = async (a = await): Promise<void> => {
|
||||
}
|
||||
|
||||
//// [asyncArrowFunction6_es5.js]
|
||||
var _this = this;
|
||||
var foo = function (a) {
|
||||
if (a === void 0) { a = yield ; }
|
||||
return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
15
tests/baselines/reference/asyncArrowFunction7_es5.errors.txt
Normal file
15
tests/baselines/reference/asyncArrowFunction7_es5.errors.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction7_es5.ts(4,24): error TS2524: 'await' expressions cannot be used in a parameter initializer.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction7_es5.ts(4,29): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction7_es5.ts (2 errors) ====
|
||||
|
||||
var bar = async (): Promise<void> => {
|
||||
// 'await' here is an identifier, and not an await expression.
|
||||
var foo = async (a = await): Promise<void> => {
|
||||
~~~~~
|
||||
!!! error TS2524: 'await' expressions cannot be used in a parameter initializer.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
}
|
||||
}
|
25
tests/baselines/reference/asyncArrowFunction7_es5.js
Normal file
25
tests/baselines/reference/asyncArrowFunction7_es5.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
//// [asyncArrowFunction7_es5.ts]
|
||||
|
||||
var bar = async (): Promise<void> => {
|
||||
// 'await' here is an identifier, and not an await expression.
|
||||
var foo = async (a = await): Promise<void> => {
|
||||
}
|
||||
}
|
||||
|
||||
//// [asyncArrowFunction7_es5.js]
|
||||
var _this = this;
|
||||
var bar = function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
_this = this;
|
||||
var foo;
|
||||
return __generator(this, function (_a) {
|
||||
foo = function (a) {
|
||||
if (a === void 0) { a = yield ; }
|
||||
return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); var _this; };
|
10
tests/baselines/reference/asyncArrowFunction8_es5.errors.txt
Normal file
10
tests/baselines/reference/asyncArrowFunction8_es5.errors.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction8_es5.ts(3,19): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction8_es5.ts (1 errors) ====
|
||||
|
||||
var foo = async (): Promise<void> => {
|
||||
var v = { [await]: foo }
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
}
|
21
tests/baselines/reference/asyncArrowFunction8_es5.js
Normal file
21
tests/baselines/reference/asyncArrowFunction8_es5.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
//// [asyncArrowFunction8_es5.ts]
|
||||
|
||||
var foo = async (): Promise<void> => {
|
||||
var v = { [await]: foo }
|
||||
}
|
||||
|
||||
//// [asyncArrowFunction8_es5.js]
|
||||
var _this = this;
|
||||
var foo = function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var v, _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_a = {};
|
||||
return [4 /*yield*/, ];
|
||||
case 1:
|
||||
v = (_a[_b.sent()] = foo, _a);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
23
tests/baselines/reference/asyncArrowFunction9_es5.errors.txt
Normal file
23
tests/baselines/reference/asyncArrowFunction9_es5.errors.txt
Normal file
|
@ -0,0 +1,23 @@
|
|||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,11): error TS2304: Cannot find name 'async'.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,18): error TS2304: Cannot find name 'a'.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,37): error TS1005: ',' expected.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,46): error TS1005: '=' expected.
|
||||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,53): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts (6 errors) ====
|
||||
var foo = async (a = await => await): Promise<void> => {
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'async'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~~~~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'.
|
||||
~
|
||||
!!! error TS1005: '=' expected.
|
||||
~~
|
||||
!!! error TS1109: Expression expected.
|
||||
}
|
8
tests/baselines/reference/asyncArrowFunction9_es5.js
Normal file
8
tests/baselines/reference/asyncArrowFunction9_es5.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [asyncArrowFunction9_es5.ts]
|
||||
var foo = async (a = await => await): Promise<void> => {
|
||||
}
|
||||
|
||||
//// [asyncArrowFunction9_es5.js]
|
||||
var foo = async(a = function (await) { return await; }), Promise = ;
|
||||
{
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es5.ts(4,52): error TS2496: The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es5.ts (1 errors) ====
|
||||
class C {
|
||||
method() {
|
||||
function other() {}
|
||||
var fn = async () => await other.apply(this, arguments);
|
||||
~~~~~~~~~
|
||||
!!! error TS2496: The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression.
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
//// [asyncArrowFunctionCapturesArguments_es5.ts]
|
||||
class C {
|
||||
method() {
|
||||
function other() {}
|
||||
var fn = async () => await other.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [asyncArrowFunctionCapturesArguments_es5.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () {
|
||||
var _this = this;
|
||||
function other() { }
|
||||
var fn = function () { return __awaiter(_this, arguments, void 0, function () { return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, other.apply(this, arguments)];
|
||||
case 1: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
}); }); };
|
||||
};
|
||||
return C;
|
||||
}());
|
|
@ -0,0 +1,23 @@
|
|||
//// [asyncArrowFunctionCapturesThis_es5.ts]
|
||||
class C {
|
||||
method() {
|
||||
var fn = async () => await this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [asyncArrowFunctionCapturesThis_es5.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () {
|
||||
var _this = this;
|
||||
var fn = function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, this];
|
||||
case 1: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
}); }); };
|
||||
};
|
||||
return C;
|
||||
}());
|
|
@ -0,0 +1,13 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunctionCapturesThis_es5.ts ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es5.ts, 0, 0))
|
||||
|
||||
method() {
|
||||
>method : Symbol(C.method, Decl(asyncArrowFunctionCapturesThis_es5.ts, 0, 9))
|
||||
|
||||
var fn = async () => await this;
|
||||
>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesThis_es5.ts, 2, 9))
|
||||
>this : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es5.ts, 0, 0))
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunctionCapturesThis_es5.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
method() {
|
||||
>method : () => void
|
||||
|
||||
var fn = async () => await this;
|
||||
>fn : () => Promise<this>
|
||||
>async () => await this : () => Promise<this>
|
||||
>await this : this
|
||||
>this : this
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclarationCapturesArguments_es5.ts(5,36): error TS2522: The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclarationCapturesArguments_es5.ts (1 errors) ====
|
||||
class C {
|
||||
method() {
|
||||
function other() {}
|
||||
async function fn () {
|
||||
await other.apply(this, arguments);
|
||||
~~~~~~~~~
|
||||
!!! error TS2522: The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
//// [asyncFunctionDeclarationCapturesArguments_es5.ts]
|
||||
class C {
|
||||
method() {
|
||||
function other() {}
|
||||
async function fn () {
|
||||
await other.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [asyncFunctionDeclarationCapturesArguments_es5.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () {
|
||||
function other() { }
|
||||
function fn() {
|
||||
return __awaiter(this, arguments, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, other.apply(this, arguments)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
return C;
|
||||
}());
|
|
@ -0,0 +1,20 @@
|
|||
//// [asyncUnParenthesizedArrowFunction_es5.ts]
|
||||
|
||||
declare function someOtherFunction(i: any): Promise<void>;
|
||||
const x = async i => await someOtherFunction(i)
|
||||
const x1 = async (i) => await someOtherFunction(i);
|
||||
|
||||
//// [asyncUnParenthesizedArrowFunction_es5.js]
|
||||
var _this = this;
|
||||
var x = function (i) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, someOtherFunction(i)];
|
||||
case 1: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
}); }); };
|
||||
var x1 = function (i) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, someOtherFunction(i)];
|
||||
case 1: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
}); }); };
|
|
@ -0,0 +1,19 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es5.ts ===
|
||||
|
||||
declare function someOtherFunction(i: any): Promise<void>;
|
||||
>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 0, 0))
|
||||
>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 1, 35))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
|
||||
const x = async i => await someOtherFunction(i)
|
||||
>x : Symbol(x, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 2, 5))
|
||||
>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 2, 15))
|
||||
>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 0, 0))
|
||||
>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 2, 15))
|
||||
|
||||
const x1 = async (i) => await someOtherFunction(i);
|
||||
>x1 : Symbol(x1, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 3, 5))
|
||||
>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 3, 18))
|
||||
>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 0, 0))
|
||||
>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es5.ts, 3, 18))
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es5.ts ===
|
||||
|
||||
declare function someOtherFunction(i: any): Promise<void>;
|
||||
>someOtherFunction : (i: any) => Promise<void>
|
||||
>i : any
|
||||
>Promise : Promise<T>
|
||||
|
||||
const x = async i => await someOtherFunction(i)
|
||||
>x : (i: any) => Promise<void>
|
||||
>async i => await someOtherFunction(i) : (i: any) => Promise<void>
|
||||
>i : any
|
||||
>await someOtherFunction(i) : void
|
||||
>someOtherFunction(i) : Promise<void>
|
||||
>someOtherFunction : (i: any) => Promise<void>
|
||||
>i : any
|
||||
|
||||
const x1 = async (i) => await someOtherFunction(i);
|
||||
>x1 : (i: any) => Promise<void>
|
||||
>async (i) => await someOtherFunction(i) : (i: any) => Promise<void>
|
||||
>i : any
|
||||
>await someOtherFunction(i) : void
|
||||
>someOtherFunction(i) : Promise<void>
|
||||
>someOtherFunction : (i: any) => Promise<void>
|
||||
>i : any
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
|
||||
const x = async => async;
|
|
@ -0,0 +1,8 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
|
||||
var foo = async (): Promise<void> => {
|
||||
// Legal to use 'await' in a type context.
|
||||
var v: await;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
|
||||
var foo = async (): Promise<void> => {
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
var f = (await) => {
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
function f(await = await) {
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
var await = () => {
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
|
||||
var foo = async (await): Promise<void> => {
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
|
||||
var foo = async (a = await): Promise<void> => {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
|
||||
var bar = async (): Promise<void> => {
|
||||
// 'await' here is an identifier, and not an await expression.
|
||||
var foo = async (a = await): Promise<void> => {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
|
||||
var foo = async (): Promise<void> => {
|
||||
var v = { [await]: foo }
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
var foo = async (a = await => await): Promise<void> => {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
class C {
|
||||
method() {
|
||||
function other() {}
|
||||
var fn = async () => await other.apply(this, arguments);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
class C {
|
||||
method() {
|
||||
var fn = async () => await this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
|
||||
declare function someOtherFunction(i: any): Promise<void>;
|
||||
const x = async i => await someOtherFunction(i)
|
||||
const x1 = async (i) => await someOtherFunction(i);
|
|
@ -0,0 +1,11 @@
|
|||
// @target: ES5
|
||||
// @lib: es5,es2015.promise
|
||||
// @noEmitHelpers: true
|
||||
class C {
|
||||
method() {
|
||||
function other() {}
|
||||
async function fn () {
|
||||
await other.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue