From 2c46f9b6870348bd14973c1e5abb2f3ba893c084 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Wed, 5 Oct 2016 17:09:58 +0200 Subject: [PATCH 01/13] Add ES8/ES2017 target (#10768) --- src/compiler/commandLineParser.ts | 2 ++ src/compiler/core.ts | 2 +- src/compiler/emitter.ts | 5 +++- src/compiler/transformer.ts | 6 +++-- src/compiler/transformers/ts.ts | 41 +++++++++++++++++++++++++------ src/compiler/types.ts | 4 ++- 6 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 648447ac26ac4..16d338cac6a55 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -262,7 +262,9 @@ namespace ts { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6, + "es8": ScriptTarget.ES8, "es2015": ScriptTarget.ES2015, + "es2017": ScriptTarget.ES2017, }), description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, paramType: Diagnostics.VERSION, diff --git a/src/compiler/core.ts b/src/compiler/core.ts index e63bcbf8474b4..3f2cc619cb383 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1191,7 +1191,7 @@ namespace ts { export function getEmitModuleKind(compilerOptions: CompilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.CommonJS; } /* @internal */ diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b3242e211de92..b0e31278ff08e 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2192,7 +2192,10 @@ const _super = (function (geti, seti) { helpersEmitted = true; } - if (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions) { + // Only emit __awaiter function when target ES5/ES6. + // Only emit __generator function when target ES5. + // For target ES8 and above, we can emit async/await as is. + if ((languageVersion < ScriptTarget.ES8) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) { writeLines(awaiterHelper); if (languageVersion < ScriptTarget.ES6) { writeLines(generatorHelper); diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 92407af2bb9fe..415a9ecd1d7c4 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -115,7 +115,9 @@ namespace ts { transformers.push(transformJsx); } - transformers.push(transformES7); + if (languageVersion < ScriptTarget.ES8) { + transformers.push(transformES7); + } if (languageVersion < ScriptTarget.ES6) { transformers.push(transformES6); @@ -339,4 +341,4 @@ namespace ts { return statements; } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index f6e8074cb07e7..40b9e7f64e106 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -240,11 +240,14 @@ namespace ts { // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; + case SyntaxKind.AsyncKeyword: + // Async keyword is not elided for target ES8 + return languageVersion < ScriptTarget.ES8 ? undefined : node; + case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.AbstractKeyword: - case SyntaxKind.AsyncKeyword: case SyntaxKind.ConstKeyword: case SyntaxKind.DeclareKeyword: case SyntaxKind.ReadonlyKeyword: @@ -2223,6 +2226,14 @@ namespace ts { /*location*/ node ); + // Add ES8 async function expression modifier + // Not sure this is the right place? Might be better to move this + // into createFunctionExpression itself. + if ((languageVersion >= ScriptTarget.ES8) && isAsyncFunctionLike(node)) { + const funcModifiers = visitNodes(node.modifiers, visitor, isModifier); + func.modifiers = createNodeArray(funcModifiers); + } + setOriginalNode(func, node); return func; @@ -2235,7 +2246,7 @@ namespace ts { */ function visitArrowFunction(node: ArrowFunction) { const func = createArrowFunction( - /*modifiers*/ undefined, + visitNodes(node.modifiers, visitor, isModifier), /*typeParameters*/ undefined, visitNodes(node.parameters, visitor, isParameter), /*type*/ undefined, @@ -2250,7 +2261,7 @@ namespace ts { } function transformFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody { - if (isAsyncFunctionLike(node)) { + if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES8) { return transformAsyncFunctionBody(node); } @@ -2270,7 +2281,7 @@ namespace ts { } function transformConciseBody(node: ArrowFunction): ConciseBody { - if (isAsyncFunctionLike(node)) { + if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES8) { return transformAsyncFunctionBody(node); } @@ -2453,14 +2464,28 @@ namespace ts { * @param node The await expression node. */ function visitAwaitExpression(node: AwaitExpression): Expression { + const targetAtLeastES8 = languageVersion >= ScriptTarget.ES8; return setOriginalNode( - createYield( + targetAtLeastES8 ? createAwaitExpression() : createYieldExpression(), + node + ); + + function createAwaitExpression() { + const awaitExpression = createAwait( + visitNode(node.expression, visitor, isExpression), + /*location*/ node + ); + return awaitExpression; + } + + function createYieldExpression() { + const yieldExpression = createYield( /*asteriskToken*/ undefined, visitNode(node.expression, visitor, isExpression), /*location*/ node - ), - node - ); + ); + return yieldExpression; + } } /** diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4a4a25fd62755..5b193beb155ff 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2831,8 +2831,10 @@ namespace ts { ES3 = 0, ES5 = 1, ES6 = 2, + ES8 = 3, ES2015 = ES6, - Latest = ES6, + ES2017 = ES8, + Latest = ES8, } export const enum LanguageVariant { From d16e846ab42e1da1558b8bbc6a28bb76ddae207f Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 6 Oct 2016 00:41:22 +0200 Subject: [PATCH 02/13] ES8/ES2017 target tests --- src/harness/unittests/commandLineParsing.ts | 2 +- .../convertCompilerOptionsFromJson.ts | 2 +- tests/baselines/reference/es8-async.js | 87 +++++++++++++ tests/baselines/reference/es8-async.symbols | 79 ++++++++++++ tests/baselines/reference/es8-async.types | 121 ++++++++++++++++++ tests/cases/compiler/es8-async.ts | 49 +++++++ 6 files changed, 338 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/es8-async.js create mode 100644 tests/baselines/reference/es8-async.symbols create mode 100644 tests/baselines/reference/es8-async.types create mode 100644 tests/cases/compiler/es8-async.ts diff --git a/src/harness/unittests/commandLineParsing.ts b/src/harness/unittests/commandLineParsing.ts index 028786eef24c4..42fc242f08e06 100644 --- a/src/harness/unittests/commandLineParsing.ts +++ b/src/harness/unittests/commandLineParsing.ts @@ -165,7 +165,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015'", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es8', 'es2015', 'es2017'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/harness/unittests/convertCompilerOptionsFromJson.ts b/src/harness/unittests/convertCompilerOptionsFromJson.ts index ba25409a9b4af..db3d6cfc1025c 100644 --- a/src/harness/unittests/convertCompilerOptionsFromJson.ts +++ b/src/harness/unittests/convertCompilerOptionsFromJson.ts @@ -176,7 +176,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015'", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es8', 'es2015', 'es2017'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] diff --git a/tests/baselines/reference/es8-async.js b/tests/baselines/reference/es8-async.js new file mode 100644 index 0000000000000..3338b1f88a62c --- /dev/null +++ b/tests/baselines/reference/es8-async.js @@ -0,0 +1,87 @@ +//// [es8-async.ts] + +async (): Promise => { + await 0; +} + +async function asyncFunc() { + await 0; +} + +const asycnArrowFunc = async (): Promise => { + await 0; +} + +async function asyncIIFE() { + await 0; + + await (async function(): Promise { + await 1; + })(); + + await (async function asyncNamedFunc(): Promise { + await 1; + })(); + + await (async (): Promise => { + await 1; + })(); +} + +class AsyncClass { + asyncPropFunc = async function(): Promise { + await 2; + } + + asyncPropNamedFunc = async function namedFunc(): Promise { + await 2; + } + + asyncPropArrowFunc = async (): Promise => { + await 2; + } + + async asyncMethod(): Promise { + await 2; + } +} + + +//// [es8-async.js] +async () => { + await 0; +}; +async function asyncFunc() { + await 0; +} +const asycnArrowFunc = async () => { + await 0; +}; +async function asyncIIFE() { + await 0; + await (async function () { + await 1; + })(); + await (async function asyncNamedFunc() { + await 1; + })(); + await (async () => { + await 1; + })(); +} +class AsyncClass { + constructor() { + this.asyncPropFunc = async function () { + await 2; + }; + this.asyncPropNamedFunc = async function namedFunc() { + await 2; + }; + this.asyncPropArrowFunc = async () => { + await 2; + }; + } + async asyncMethod() { + await 2; + } +} diff --git a/tests/baselines/reference/es8-async.symbols b/tests/baselines/reference/es8-async.symbols new file mode 100644 index 0000000000000..25a77351aef6c --- /dev/null +++ b/tests/baselines/reference/es8-async.symbols @@ -0,0 +1,79 @@ +=== tests/cases/compiler/es8-async.ts === + +async (): Promise => { +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 0; +} + +async function asyncFunc() { +>asyncFunc : Symbol(asyncFunc, Decl(es8-async.ts, 3, 1)) + + await 0; +} + +const asycnArrowFunc = async (): Promise => { +>asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es8-async.ts, 9, 5)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 0; +} + +async function asyncIIFE() { +>asyncIIFE : Symbol(asyncIIFE, Decl(es8-async.ts, 11, 1)) + + await 0; + + await (async function(): Promise { +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 1; + })(); + + await (async function asyncNamedFunc(): Promise { +>asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es8-async.ts, 20, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 1; + })(); + + await (async (): Promise => { +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 1; + })(); +} + +class AsyncClass { +>AsyncClass : Symbol(AsyncClass, Decl(es8-async.ts, 27, 1)) + + asyncPropFunc = async function(): Promise { +>asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es8-async.ts, 29, 18)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 2; + } + + asyncPropNamedFunc = async function namedFunc(): Promise { +>asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es8-async.ts, 32, 5)) +>namedFunc : Symbol(namedFunc, Decl(es8-async.ts, 34, 24)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 2; + } + + asyncPropArrowFunc = async (): Promise => { +>asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es8-async.ts, 36, 5)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 2; + } + + async asyncMethod(): Promise { +>asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es8-async.ts, 40, 5)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 2; + } +} + diff --git a/tests/baselines/reference/es8-async.types b/tests/baselines/reference/es8-async.types new file mode 100644 index 0000000000000..da0ca0637777b --- /dev/null +++ b/tests/baselines/reference/es8-async.types @@ -0,0 +1,121 @@ +=== tests/cases/compiler/es8-async.ts === + +async (): Promise => { +>async (): Promise => { await 0;} : () => Promise +>Promise : Promise + + await 0; +>await 0 : 0 +>0 : 0 +} + +async function asyncFunc() { +>asyncFunc : () => Promise + + await 0; +>await 0 : 0 +>0 : 0 +} + +const asycnArrowFunc = async (): Promise => { +>asycnArrowFunc : () => Promise +>async (): Promise => { await 0;} : () => Promise +>Promise : Promise + + await 0; +>await 0 : 0 +>0 : 0 +} + +async function asyncIIFE() { +>asyncIIFE : () => Promise + + await 0; +>await 0 : 0 +>0 : 0 + + await (async function(): Promise { +>await (async function(): Promise { await 1; })() : void +>(async function(): Promise { await 1; })() : Promise +>(async function(): Promise { await 1; }) : () => Promise +>async function(): Promise { await 1; } : () => Promise +>Promise : Promise + + await 1; +>await 1 : 1 +>1 : 1 + + })(); + + await (async function asyncNamedFunc(): Promise { +>await (async function asyncNamedFunc(): Promise { await 1; })() : void +>(async function asyncNamedFunc(): Promise { await 1; })() : Promise +>(async function asyncNamedFunc(): Promise { await 1; }) : () => Promise +>async function asyncNamedFunc(): Promise { await 1; } : () => Promise +>asyncNamedFunc : () => Promise +>Promise : Promise + + await 1; +>await 1 : 1 +>1 : 1 + + })(); + + await (async (): Promise => { +>await (async (): Promise => { await 1; })() : void +>(async (): Promise => { await 1; })() : Promise +>(async (): Promise => { await 1; }) : () => Promise +>async (): Promise => { await 1; } : () => Promise +>Promise : Promise + + await 1; +>await 1 : 1 +>1 : 1 + + })(); +} + +class AsyncClass { +>AsyncClass : AsyncClass + + asyncPropFunc = async function(): Promise { +>asyncPropFunc : () => Promise +>async function(): Promise { await 2; } : () => Promise +>Promise : Promise + + await 2; +>await 2 : 2 +>2 : 2 + } + + asyncPropNamedFunc = async function namedFunc(): Promise { +>asyncPropNamedFunc : () => Promise +>async function namedFunc(): Promise { await 2; } : () => Promise +>namedFunc : () => Promise +>Promise : Promise + + await 2; +>await 2 : 2 +>2 : 2 + } + + asyncPropArrowFunc = async (): Promise => { +>asyncPropArrowFunc : () => Promise +>async (): Promise => { await 2; } : () => Promise +>Promise : Promise + + await 2; +>await 2 : 2 +>2 : 2 + } + + async asyncMethod(): Promise { +>asyncMethod : () => Promise +>Promise : Promise + + await 2; +>await 2 : 2 +>2 : 2 + } +} + diff --git a/tests/cases/compiler/es8-async.ts b/tests/cases/compiler/es8-async.ts new file mode 100644 index 0000000000000..0ceb6e397e551 --- /dev/null +++ b/tests/cases/compiler/es8-async.ts @@ -0,0 +1,49 @@ +// @target: es8 +// @lib: es2017 +// @noEmitHelpers: true + +async (): Promise => { + await 0; +} + +async function asyncFunc() { + await 0; +} + +const asycnArrowFunc = async (): Promise => { + await 0; +} + +async function asyncIIFE() { + await 0; + + await (async function(): Promise { + await 1; + })(); + + await (async function asyncNamedFunc(): Promise { + await 1; + })(); + + await (async (): Promise => { + await 1; + })(); +} + +class AsyncClass { + asyncPropFunc = async function(): Promise { + await 2; + } + + asyncPropNamedFunc = async function namedFunc(): Promise { + await 2; + } + + asyncPropArrowFunc = async (): Promise => { + await 2; + } + + async asyncMethod(): Promise { + await 2; + } +} From f42c79150253b003f6f7e38011d57cf0af77df10 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Wed, 12 Oct 2016 21:28:11 +0200 Subject: [PATCH 03/13] Don't use es8. Add es2016 target. Rename es7 to es2016. Update getDefaultLibFileName for new targets. --- Jakefile.js | 4 +- src/compiler/binder.ts | 4 +- src/compiler/commandLineParser.ts | 2 +- src/compiler/emitter.ts | 4 +- src/compiler/transformer.ts | 7 +-- .../transformers/{es7.ts => es2016.ts} | 10 ++-- src/compiler/transformers/ts.ts | 3 +- src/compiler/tsconfig.json | 2 +- src/compiler/types.ts | 53 ++++++++++--------- src/compiler/utilities.ts | 10 +++- src/harness/harness.ts | 10 +++- src/harness/tsconfig.json | 2 +- src/harness/unittests/commandLineParsing.ts | 2 +- .../convertCompilerOptionsFromJson.ts | 2 +- src/services/tsconfig.json | 2 +- .../{es8-async.ts => es2017basicAsync.ts} | 2 +- 16 files changed, 69 insertions(+), 50 deletions(-) rename src/compiler/transformers/{es7.ts => es2016.ts} (91%) rename tests/cases/compiler/{es8-async.ts => es2017basicAsync.ts} (97%) diff --git a/Jakefile.js b/Jakefile.js index 64a8553ef39dc..ecbd0ae2be2ee 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -74,7 +74,7 @@ var compilerSources = [ "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", - "transformers/es7.ts", + "transformers/es2016.ts", "transformers/generators.ts", "transformers/es6.ts", "transformer.ts", @@ -108,7 +108,7 @@ var servicesSources = [ "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", - "transformers/es7.ts", + "transformers/es2016.ts", "transformers/generators.ts", "transformers/es6.ts", "transformer.ts", diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 2fe7d30ab56af..ce482dcdfd9b0 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2411,8 +2411,8 @@ namespace ts { } else if (operatorTokenKind === SyntaxKind.AsteriskAsteriskToken || operatorTokenKind === SyntaxKind.AsteriskAsteriskEqualsToken) { - // Exponentiation is ES7 syntax. - transformFlags |= TransformFlags.AssertES7; + // Exponentiation is ES2016 syntax. + transformFlags |= TransformFlags.AssertES2016; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 16d338cac6a55..b77f6898b3c0a 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -262,8 +262,8 @@ namespace ts { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6, - "es8": ScriptTarget.ES8, "es2015": ScriptTarget.ES2015, + "es2016": ScriptTarget.ES2016, "es2017": ScriptTarget.ES2017, }), description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b0e31278ff08e..a3f69e2fd4bd1 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2194,8 +2194,8 @@ const _super = (function (geti, seti) { // Only emit __awaiter function when target ES5/ES6. // Only emit __generator function when target ES5. - // For target ES8 and above, we can emit async/await as is. - if ((languageVersion < ScriptTarget.ES8) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) { + // For target ES2017 and above, we can emit async/await as is. + if ((languageVersion < ScriptTarget.ES2017) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) { writeLines(awaiterHelper); if (languageVersion < ScriptTarget.ES6) { writeLines(generatorHelper); diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 415a9ecd1d7c4..9e548268052ca 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -1,7 +1,7 @@ /// /// /// -/// +/// /// /// /// @@ -115,8 +115,9 @@ namespace ts { transformers.push(transformJsx); } - if (languageVersion < ScriptTarget.ES8) { - transformers.push(transformES7); + + if (languageVersion < ScriptTarget.ES2016) { + transformers.push(transformES2016); } if (languageVersion < ScriptTarget.ES6) { diff --git a/src/compiler/transformers/es7.ts b/src/compiler/transformers/es2016.ts similarity index 91% rename from src/compiler/transformers/es7.ts rename to src/compiler/transformers/es2016.ts index 4d5e96134c40d..fba1d3009037b 100644 --- a/src/compiler/transformers/es7.ts +++ b/src/compiler/transformers/es2016.ts @@ -3,7 +3,7 @@ /*@internal*/ namespace ts { - export function transformES7(context: TransformationContext) { + export function transformES2016(context: TransformationContext) { const { hoistVariableDeclaration } = context; return transformSourceFile; @@ -17,10 +17,10 @@ namespace ts { } function visitor(node: Node): VisitResult { - if (node.transformFlags & TransformFlags.ES7) { + if (node.transformFlags & TransformFlags.ES2016) { return visitorWorker(node); } - else if (node.transformFlags & TransformFlags.ContainsES7) { + else if (node.transformFlags & TransformFlags.ContainsES2016) { return visitEachChild(node, visitor, context); } else { @@ -40,7 +40,7 @@ namespace ts { } function visitBinaryExpression(node: BinaryExpression): Expression { - // We are here because ES7 adds support for the exponentiation operator. + // We are here because ES2016 adds support for the exponentiation operator. const left = visitNode(node.left, visitor, isExpression); const right = visitNode(node.right, visitor, isExpression); if (node.operatorToken.kind === SyntaxKind.AsteriskAsteriskEqualsToken) { @@ -98,4 +98,4 @@ namespace ts { } } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 40b9e7f64e106..c98fbfc26ccec 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -241,8 +241,7 @@ namespace ts { return currentNamespace ? undefined : node; case SyntaxKind.AsyncKeyword: - // Async keyword is not elided for target ES8 - return languageVersion < ScriptTarget.ES8 ? undefined : node; + return node; case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index f128c994af12b..fc0f016f66453 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -24,7 +24,7 @@ "visitor.ts", "transformers/ts.ts", "transformers/jsx.ts", - "transformers/es7.ts", + "transformers/es2016.ts", "transformers/es6.ts", "transformers/generators.ts", "transformers/destructuring.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5b193beb155ff..b89887cafa080 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2831,10 +2831,10 @@ namespace ts { ES3 = 0, ES5 = 1, ES6 = 2, - ES8 = 3, ES2015 = ES6, - ES2017 = ES8, - Latest = ES8, + ES2016 = 3, + ES2017 = 4, + Latest = ES2017, } export const enum LanguageVariant { @@ -3119,29 +3119,31 @@ namespace ts { ContainsTypeScript = 1 << 1, Jsx = 1 << 2, ContainsJsx = 1 << 3, - ES7 = 1 << 4, - ContainsES7 = 1 << 5, - ES6 = 1 << 6, - ContainsES6 = 1 << 7, - DestructuringAssignment = 1 << 8, - Generator = 1 << 9, - ContainsGenerator = 1 << 10, + ES2017 = 1 << 4, + ContainsES2017 = 1 << 5, + ES2016 = 1 << 6, + ContainsES2016 = 1 << 7, + ES6 = 1 << 8, + ContainsES6 = 1 << 9, + DestructuringAssignment = 1 << 10, + Generator = 1 << 11, + ContainsGenerator = 1 << 12, // Markers // - Flags used to indicate that a subtree contains a specific transformation. - ContainsDecorators = 1 << 11, - ContainsPropertyInitializer = 1 << 12, - ContainsLexicalThis = 1 << 13, - ContainsCapturedLexicalThis = 1 << 14, - ContainsLexicalThisInComputedPropertyName = 1 << 15, - ContainsDefaultValueAssignments = 1 << 16, - ContainsParameterPropertyAssignments = 1 << 17, - ContainsSpreadElementExpression = 1 << 18, - ContainsComputedPropertyName = 1 << 19, - ContainsBlockScopedBinding = 1 << 20, - ContainsBindingPattern = 1 << 21, - ContainsYield = 1 << 22, - ContainsHoistedDeclarationOrCompletion = 1 << 23, + ContainsDecorators = 1 << 13, + ContainsPropertyInitializer = 1 << 14, + ContainsLexicalThis = 1 << 15, + ContainsCapturedLexicalThis = 1 << 16, + ContainsLexicalThisInComputedPropertyName = 1 << 17, + ContainsDefaultValueAssignments = 1 << 18, + ContainsParameterPropertyAssignments = 1 << 19, + ContainsSpreadElementExpression = 1 << 20, + ContainsComputedPropertyName = 1 << 21, + ContainsBlockScopedBinding = 1 << 22, + ContainsBindingPattern = 1 << 23, + ContainsYield = 1 << 24, + ContainsHoistedDeclarationOrCompletion = 1 << 25, HasComputedFlags = 1 << 29, // Transform flags have been computed. @@ -3149,14 +3151,15 @@ namespace ts { // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. AssertTypeScript = TypeScript | ContainsTypeScript, AssertJsx = Jsx | ContainsJsx, - AssertES7 = ES7 | ContainsES7, + AssertES2017 = ES2017 | ContainsES2017, + AssertES2016 = ES2016 | ContainsES2016, AssertES6 = ES6 | ContainsES6, AssertGenerator = Generator | ContainsGenerator, // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - NodeExcludes = TypeScript | Jsx | ES7 | ES6 | DestructuringAssignment | Generator | HasComputedFlags, + NodeExcludes = TypeScript | Jsx | ES2017 | ES2016 | ES6 | DestructuringAssignment | Generator | HasComputedFlags, ArrowFunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, FunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsCapturedLexicalThis | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, ConstructorExcludes = NodeExcludes | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 1a4d95feca54f..b661cefb5a646 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4141,7 +4141,15 @@ namespace ts { namespace ts { export function getDefaultLibFileName(options: CompilerOptions): string { - return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts"; + switch (options.target) { + case ScriptTarget.ES2016: + return "lib.es2016.d.ts"; + case ScriptTarget.ES6: + return "lib.es2015.d.ts"; + + default: + return "lib.d.ts"; + } } export function textSpanEnd(span: TextSpan) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 7c82aeece788c..b8703ebc8f276 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -941,7 +941,15 @@ namespace Harness { } export function getDefaultLibFileName(options: ts.CompilerOptions): string { - return options.target === ts.ScriptTarget.ES6 ? es2015DefaultLibFileName : defaultLibFileName; + switch (options.target) { + case ts.ScriptTarget.ES2016: + return "lib.es2016.d.ts"; + case ts.ScriptTarget.ES6: + return es2015DefaultLibFileName; + + default: + return defaultLibFileName; + } } // Cache these between executions so we don't have to re-parse them for every test diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index f9d302ace81ed..aa46c8ee8d079 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -26,7 +26,7 @@ "../compiler/visitor.ts", "../compiler/transformers/ts.ts", "../compiler/transformers/jsx.ts", - "../compiler/transformers/es7.ts", + "../compiler/transformers/es2016.ts", "../compiler/transformers/es6.ts", "../compiler/transformers/generators.ts", "../compiler/transformers/destructuring.ts", diff --git a/src/harness/unittests/commandLineParsing.ts b/src/harness/unittests/commandLineParsing.ts index 42fc242f08e06..cd9bf88df60e7 100644 --- a/src/harness/unittests/commandLineParsing.ts +++ b/src/harness/unittests/commandLineParsing.ts @@ -165,7 +165,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es8', 'es2015', 'es2017'", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/harness/unittests/convertCompilerOptionsFromJson.ts b/src/harness/unittests/convertCompilerOptionsFromJson.ts index db3d6cfc1025c..13f54e369ed46 100644 --- a/src/harness/unittests/convertCompilerOptionsFromJson.ts +++ b/src/harness/unittests/convertCompilerOptionsFromJson.ts @@ -176,7 +176,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es8', 'es2015', 'es2017'", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 58312c6f38ff3..e759ab35b483f 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -25,7 +25,7 @@ "../compiler/visitor.ts", "../compiler/transformers/ts.ts", "../compiler/transformers/jsx.ts", - "../compiler/transformers/es7.ts", + "../compiler/transformers/es2016.ts", "../compiler/transformers/es6.ts", "../compiler/transformers/generators.ts", "../compiler/transformers/destructuring.ts", diff --git a/tests/cases/compiler/es8-async.ts b/tests/cases/compiler/es2017basicAsync.ts similarity index 97% rename from tests/cases/compiler/es8-async.ts rename to tests/cases/compiler/es2017basicAsync.ts index 0ceb6e397e551..b13a5d29bc0c0 100644 --- a/tests/cases/compiler/es8-async.ts +++ b/tests/cases/compiler/es2017basicAsync.ts @@ -1,4 +1,4 @@ -// @target: es8 +// @target: es2017 // @lib: es2017 // @noEmitHelpers: true From 5d52c9fd3b28b25d2752b5157bc51453187065c9 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Wed, 12 Oct 2016 21:34:00 +0200 Subject: [PATCH 04/13] Move async/await into separate es2017 transformer --- Jakefile.js | 2 + src/compiler/binder.ts | 24 +- src/compiler/transformer.ts | 4 + src/compiler/transformers/es2017.ts | 544 ++++++++++++++++++ src/compiler/transformers/module/module.ts | 4 +- src/compiler/transformers/module/system.ts | 6 +- src/compiler/transformers/ts.ts | 238 +------- src/compiler/tsconfig.json | 1 + src/compiler/utilities.ts | 2 + src/harness/harness.ts | 2 + src/harness/tsconfig.json | 1 + src/services/tsconfig.json | 1 + .../{es8-async.js => es2017basicAsync.js} | 4 +- ...async.symbols => es2017basicAsync.symbols} | 22 +- ...es8-async.types => es2017basicAsync.types} | 2 +- 15 files changed, 614 insertions(+), 243 deletions(-) create mode 100644 src/compiler/transformers/es2017.ts rename tests/baselines/reference/{es8-async.js => es2017basicAsync.js} (94%) rename tests/baselines/reference/{es8-async.symbols => es2017basicAsync.symbols} (78%) rename tests/baselines/reference/{es8-async.types => es2017basicAsync.types} (94%) diff --git a/Jakefile.js b/Jakefile.js index ecbd0ae2be2ee..8d46368653c04 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -74,6 +74,7 @@ var compilerSources = [ "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", + "transformers/es2017.ts", "transformers/es2016.ts", "transformers/generators.ts", "transformers/es6.ts", @@ -108,6 +109,7 @@ var servicesSources = [ "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", + "transformers/es2017.ts", "transformers/es2016.ts", "transformers/generators.ts", "transformers/es6.ts", diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index ce482dcdfd9b0..4edbb5d9e1a7c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2555,6 +2555,11 @@ namespace ts { // extends clause of a class. let transformFlags = subtreeFlags | TransformFlags.AssertES6; + // propagate ES2017 + if (node.expression.transformFlags & TransformFlags.ContainsES2017) { + transformFlags |= TransformFlags.ContainsES2017; + } + // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. if (node.typeArguments) { @@ -2595,6 +2600,11 @@ namespace ts { transformFlags |= TransformFlags.AssertTypeScript; } + // Async MethodDeclaration is ES2017 + if (modifierFlags & ModifierFlags.Async) { + transformFlags |= TransformFlags.AssertES2017; + } + // Currently, we only support generators that were originally async function bodies. if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { transformFlags |= TransformFlags.AssertGenerator; @@ -2656,7 +2666,7 @@ namespace ts { // If a FunctionDeclaration is async, then it is TypeScript syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript; + transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; } // If a FunctionDeclaration's subtree has marked the container as needing to capture the @@ -2687,7 +2697,7 @@ namespace ts { // An async function expression is TypeScript syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript; + transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; } // If a FunctionExpression's subtree has marked the container as needing to capture the @@ -2717,7 +2727,7 @@ namespace ts { // An async arrow function is TypeScript syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript; + transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; } // If an ArrowFunction contains a lexical this, its container must capture the lexical this. @@ -2856,14 +2866,18 @@ namespace ts { let excludeFlags = TransformFlags.NodeExcludes; switch (kind) { + case SyntaxKind.AsyncKeyword: + case SyntaxKind.AwaitExpression: + // Typescript async/await are ES2017 features + transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; + break; + case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.AbstractKeyword: case SyntaxKind.DeclareKeyword: - case SyntaxKind.AsyncKeyword: case SyntaxKind.ConstKeyword: - case SyntaxKind.AwaitExpression: case SyntaxKind.EnumDeclaration: case SyntaxKind.EnumMember: case SyntaxKind.TypeAssertionExpression: diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 9e548268052ca..55b83ea669d4a 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -1,6 +1,7 @@ /// /// /// +/// /// /// /// @@ -115,6 +116,9 @@ namespace ts { transformers.push(transformJsx); } + if (languageVersion < ScriptTarget.ES2017) { + transformers.push(transformES2017); + } if (languageVersion < ScriptTarget.ES2016) { transformers.push(transformES2016); diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts new file mode 100644 index 0000000000000..33376bbceb125 --- /dev/null +++ b/src/compiler/transformers/es2017.ts @@ -0,0 +1,544 @@ +/// +/// + +/*@internal*/ +namespace ts { + type SuperContainer = ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration; + + export function transformES2017(context: TransformationContext) { + + const enum ES2017SubstitutionFlags { + /** Enables substitutions for async methods with `super` calls. */ + AsyncMethodsWithSuper = 1 << 0 + } + + const { + startLexicalEnvironment, + endLexicalEnvironment, + } = context; + + const resolver = context.getEmitResolver(); + const compilerOptions = context.getCompilerOptions(); + const languageVersion = getEmitScriptTarget(compilerOptions); + + // These variables contain state that changes as we descend into the tree. + let currentSourceFileExternalHelpersModuleName: Identifier; + /** + * Keeps track of whether expression substitution has been enabled for specific edge cases. + * They are persisted between each SourceFile transformation and should not be reset. + */ + let enabledSubstitutions: ES2017SubstitutionFlags; + + /** + * Keeps track of whether we are within any containing namespaces when performing + * just-in-time substitution while printing an expression identifier. + */ + let applicableSubstitutions: ES2017SubstitutionFlags; + + /** + * This keeps track of containers where `super` is valid, for use with + * just-in-time substitution for `super` expressions inside of async methods. + */ + let currentSuperContainer: SuperContainer; + + // Save the previous transformation hooks. + const previousOnEmitNode = context.onEmitNode; + const previousOnSubstituteNode = context.onSubstituteNode; + + // Set new transformation hooks. + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + + let currentScope: SourceFile | Block | ModuleBlock | CaseBlock; + + return transformSourceFile; + + function transformSourceFile(node: SourceFile) { + if (isDeclarationFile(node)) { + return node; + } + + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; + + return visitEachChild(node, visitor, context); + } + + function visitor(node: Node): VisitResult { + if (node.transformFlags & TransformFlags.ES2017) { + return visitorWorker(node); + } + else if (node.transformFlags & TransformFlags.ContainsES2017) { + return visitEachChild(node, visitor, context); + } + + // node = visitEachChild(node, visitor, context); + // return visitEachChild(node, visitor, context); + return node; + } + + function visitorWorker(node: Node): VisitResult { + switch (node.kind) { + case SyntaxKind.AsyncKeyword: + return undefined; + + case SyntaxKind.AwaitExpression: + // Typescript 'await' expressions must be transformed for targets < ES2017. + return visitAwaitExpression(node); + + case SyntaxKind.MethodDeclaration: + // TypeScript method declarations may be 'async' + return visitMethodDeclaration(node); + + case SyntaxKind.FunctionDeclaration: + // TypeScript function declarations may be 'async' + return visitFunctionDeclaration(node); + + case SyntaxKind.FunctionExpression: + // TypeScript function expressions may be 'async' + return visitFunctionExpression(node); + + case SyntaxKind.ArrowFunction: + // TypeScript arrow functions may be 'async' + return visitArrowFunction(node); + + default: + Debug.failBadSyntaxKind(node); + return node; + } + } + + /** + * Visits an await expression. + * + * This function will be called any time a ES2017 await expression is encountered. + * + * @param node The await expression node. + */ + function visitAwaitExpression(node: AwaitExpression): Expression { + return setOriginalNode( + createYield( + /*asteriskToken*/ undefined, + visitNode(node.expression, visitor, isExpression), + /*location*/ node + ), + node + ); + } + + /** + * Visits a method declaration of a class. + * + * This function will be called when one of the following conditions are met: + * - The node is marked as async + * + * @param node The method node. + */ + function visitMethodDeclaration(node: MethodDeclaration) { + if (!isAsyncFunctionLike(node)) { + return node; + } + const method = createMethod( + /*decorators*/ undefined, + visitNodes(node.modifiers, visitor, isModifier), + node.asteriskToken, + node.name, + /*typeParameters*/ undefined, + visitNodes(node.parameters, visitor, isParameter), + /*type*/ undefined, + transformFunctionBody(node), + /*location*/ node + ); + + // While we emit the source map for the node after skipping decorators and modifiers, + // we need to emit the comments for the original range. + setCommentRange(method, node); + setSourceMapRange(method, moveRangePastDecorators(node)); + setOriginalNode(method, node); + + return method; + } + + /** + * Visits a function declaration. + * + * This function will be called when one of the following conditions are met: + * - The node is an overload + * - The node is marked async + * - The node is exported from a TypeScript namespace + * + * @param node The function node. + */ + function visitFunctionDeclaration(node: FunctionDeclaration): VisitResult { + if (!isAsyncFunctionLike(node)) { + return node; + } + const func = createFunctionDeclaration( + /*decorators*/ undefined, + visitNodes(node.modifiers, visitor, isModifier), + node.asteriskToken, + node.name, + /*typeParameters*/ undefined, + visitNodes(node.parameters, visitor, isParameter), + /*type*/ undefined, + transformFunctionBody(node), + /*location*/ node + ); + setOriginalNode(func, node); + + return func; + } + + /** + * Visits a function expression node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The function expression node. + */ + function visitFunctionExpression(node: FunctionExpression): Expression { + if (!isAsyncFunctionLike(node)) { + return node; + } + if (nodeIsMissing(node.body)) { + return createOmittedExpression(); + } + + const func = createFunctionExpression( + node.asteriskToken, + node.name, + /*typeParameters*/ undefined, + visitNodes(node.parameters, visitor, isParameter), + /*type*/ undefined, + transformFunctionBody(node), + /*location*/ node + ); + + node.modifiers = visitNodes(node.modifiers, visitor, isModifier); + + setOriginalNode(func, node); + + return func; + } + + /** + * @remarks + * This function will be called when one of the following conditions are met: + * - The node is marked async + */ + function visitArrowFunction(node: ArrowFunction) { + if (!isAsyncFunctionLike(node)) { + return node; + } + const func = createArrowFunction( + visitNodes(node.modifiers, visitor, isModifier), + /*typeParameters*/ undefined, + visitNodes(node.parameters, visitor, isParameter), + /*type*/ undefined, + node.equalsGreaterThanToken, + transformConciseBody(node), + /*location*/ node + ); + + setOriginalNode(func, node); + + return func; + } + + function transformFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody { + return transformAsyncFunctionBody(node); + } + + function transformConciseBody(node: ArrowFunction): ConciseBody { + return transformAsyncFunctionBody(node); + } + + function transformFunctionBodyWorker(body: Block, start = 0) { + const savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + + const statements = visitNodes(body.statements, visitor, isStatement, start); + const visited = updateBlock(body, statements); + const declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + + function transformAsyncFunctionBody(node: FunctionLikeDeclaration): ConciseBody | FunctionBody { + const nodeType = node.original ? (node.original).type : node.type; + const promiseConstructor = languageVersion < ScriptTarget.ES6 ? getPromiseConstructor(nodeType) : undefined; + const isArrowFunction = node.kind === SyntaxKind.ArrowFunction; + const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; + + // An async function is emit as an outer function that calls an inner + // generator function. To preserve lexical bindings, we pass the current + // `this` and `arguments` objects to `__awaiter`. The generator function + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + + + if (!isArrowFunction) { + const statements: Statement[] = []; + const statementOffset = addPrologueDirectives(statements, (node.body).statements, /*ensureUseStrict*/ false, visitor); + statements.push( + createReturn( + createAwaiterHelper( + currentSourceFileExternalHelpersModuleName, + hasLexicalArguments, + promiseConstructor, + transformFunctionBodyWorker(node.body, statementOffset) + ) + ) + ); + + const block = createBlock(statements, /*location*/ node.body, /*multiLine*/ true); + + // Minor optimization, emit `_super` helper to capture `super` access in an arrow. + // This step isn't needed if we eventually transform this to ES5. + if (languageVersion >= ScriptTarget.ES6) { + if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) { + enableSubstitutionForAsyncMethodsWithSuper(); + setEmitFlags(block, EmitFlags.EmitAdvancedSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuper) { + enableSubstitutionForAsyncMethodsWithSuper(); + setEmitFlags(block, EmitFlags.EmitSuperHelper); + } + } + + return block; + } + else { + return createAwaiterHelper( + currentSourceFileExternalHelpersModuleName, + hasLexicalArguments, + promiseConstructor, + transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true) + ); + } + } + + function transformConciseBodyWorker(body: Block | Expression, forceBlockFunctionBody: boolean) { + if (isBlock(body)) { + return transformFunctionBodyWorker(body); + } + else { + startLexicalEnvironment(); + const visited: Expression | Block = visitNode(body, visitor, isConciseBody); + const declarations = endLexicalEnvironment(); + const merged = mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !isBlock(merged)) { + return createBlock([ + createReturn(merged) + ]); + } + else { + return merged; + } + } + } + + function getPromiseConstructor(type: TypeNode) { + const typeName = getEntityNameFromTypeNode(type); + if (typeName && isEntityName(typeName)) { + const serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + + return undefined; + } + + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper) === 0) { + enabledSubstitutions |= ES2017SubstitutionFlags.AsyncMethodsWithSuper; + + // We need to enable substitutions for call, property access, and element access + // if we need to rewrite super calls. + context.enableSubstitution(SyntaxKind.CallExpression); + context.enableSubstitution(SyntaxKind.PropertyAccessExpression); + context.enableSubstitution(SyntaxKind.ElementAccessExpression); + + // We need to be notified when entering and exiting declarations that bind super. + context.enableEmitNotification(SyntaxKind.ClassDeclaration); + context.enableEmitNotification(SyntaxKind.MethodDeclaration); + context.enableEmitNotification(SyntaxKind.GetAccessor); + context.enableEmitNotification(SyntaxKind.SetAccessor); + context.enableEmitNotification(SyntaxKind.Constructor); + } + } + + function substituteExpression(node: Expression) { + switch (node.kind) { + case SyntaxKind.PropertyAccessExpression: + return substitutePropertyAccessExpression(node); + case SyntaxKind.ElementAccessExpression: + return substituteElementAccessExpression(node); + case SyntaxKind.CallExpression: + if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper) { + return substituteCallExpression(node); + } + break; + } + + return node; + } + + function substitutePropertyAccessExpression(node: PropertyAccessExpression) { + if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) { + const flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod( + createLiteral(node.name.text), + flags, + node + ); + } + } + + return substituteConstantValue(node); + } + + function substituteElementAccessExpression(node: ElementAccessExpression) { + if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) { + const flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod( + node.argumentExpression, + flags, + node + ); + } + } + + return substituteConstantValue(node); + } + + function substituteConstantValue(node: PropertyAccessExpression | ElementAccessExpression): LeftHandSideExpression { + const constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + const substitute = createLiteral(constantValue); + setSourceMapRange(substitute, node); + setCommentRange(substitute, node); + if (!compilerOptions.removeComments) { + const propertyName = isPropertyAccessExpression(node) + ? declarationNameToString(node.name) + : getTextOfNode(node.argumentExpression); + substitute.trailingComment = ` ${propertyName} `; + } + + setConstantValue(node, constantValue); + return substitute; + } + + return node; + } + + function tryGetConstEnumValue(node: Node): number { + if (compilerOptions.isolatedModules) { + return undefined; + } + + return isPropertyAccessExpression(node) || isElementAccessExpression(node) + ? resolver.getConstantValue(node) + : undefined; + } + + function substituteCallExpression(node: CallExpression): Expression { + const expression = node.expression; + if (isSuperProperty(expression)) { + const flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + const argumentExpression = isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return createCall( + createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, + [ + createThis(), + ...node.arguments + ] + ); + } + } + return node; + } + + function isSuperContainer(node: Node): node is SuperContainer { + const kind = node.kind; + return kind === SyntaxKind.ClassDeclaration + || kind === SyntaxKind.Constructor + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.SetAccessor; + } + + /** + * Hook for node emit. + * + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void { + const savedApplicableSubstitutions = applicableSubstitutions; + const savedCurrentSuperContainer = currentSuperContainer; + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) { + currentSuperContainer = node; + } + + previousOnEmitNode(emitContext, node, emitCallback); + + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + + /** + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. + */ + function onSubstituteNode(emitContext: EmitContext, node: Node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === EmitContext.Expression) { + return substituteExpression(node); + } + + return node; + } + + function createSuperAccessInAsyncMethod(argumentExpression: Expression, flags: NodeCheckFlags, location: TextRange): LeftHandSideExpression { + if (flags & NodeCheckFlags.AsyncMethodWithSuperBinding) { + return createPropertyAccess( + createCall( + createIdentifier("_super"), + /*typeArguments*/ undefined, + [argumentExpression] + ), + "value", + location + ); + } + else { + return createCall( + createIdentifier("_super"), + /*typeArguments*/ undefined, + [argumentExpression], + location + ); + } + } + + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding); + } + } +} diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index c4e9b4c31c802..3877169e6c37a 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -701,11 +701,13 @@ namespace ts { const statements: Statement[] = []; const name = node.name || getGeneratedNameForNode(node); if (hasModifier(node, ModifierFlags.Export)) { + // Keep async modifier for ES2017 transformer + const isAsync = hasModifier(node, ModifierFlags.Async); statements.push( setOriginalNode( createFunctionDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, + isAsync ? [createNode(SyntaxKind.AsyncKeyword)] : undefined, node.asteriskToken, name, /*typeParameters*/ undefined, diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 4a137c89a9336..d4ee4f36b87d0 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -662,9 +662,11 @@ namespace ts { if (hasModifier(node, ModifierFlags.Export)) { // If the function is exported, ensure it has a name and rewrite the function without any export flags. const name = node.name || getGeneratedNameForNode(node); + // Keep async modifier for ES2017 transformer + const isAsync = hasModifier(node, ModifierFlags.Async); const newNode = createFunctionDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, + isAsync ? [createNode(SyntaxKind.AsyncKeyword)] : undefined, node.asteriskToken, name, /*typeParameters*/ undefined, @@ -1402,4 +1404,4 @@ namespace ts { return updated; } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index c98fbfc26ccec..30276deff92b8 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -4,8 +4,6 @@ /*@internal*/ namespace ts { - type SuperContainer = ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration; - /** * Indicates whether to emit type metadata in the new format. */ @@ -16,8 +14,6 @@ namespace ts { ClassAliases = 1 << 0, /** Enables substitutions for namespace exports. */ NamespaceExports = 1 << 1, - /** Enables substitutions for async methods with `super` calls. */ - AsyncMethodsWithSuper = 1 << 2, /* Enables substitutions for unqualified enum members */ NonQualifiedEnumMembers = 1 << 3 } @@ -72,12 +68,6 @@ namespace ts { */ let applicableSubstitutions: TypeScriptSubstitutionFlags; - /** - * This keeps track of containers where `super` is valid, for use with - * just-in-time substitution for `super` expressions inside of async methods. - */ - let currentSuperContainer: SuperContainer; - return transformSourceFile; /** @@ -240,6 +230,7 @@ namespace ts { // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; + // Typescript ES2017 async/await are handled by ES2017 transformer case SyntaxKind.AsyncKeyword: return node; @@ -388,7 +379,7 @@ namespace ts { return visitEnumDeclaration(node); case SyntaxKind.AwaitExpression: - // TypeScript 'await' expressions must be transformed. + // Typescript ES2017 async/await are handled by ES2017 transformer return visitAwaitExpression(node); case SyntaxKind.VariableStatement: @@ -2225,13 +2216,9 @@ namespace ts { /*location*/ node ); - // Add ES8 async function expression modifier - // Not sure this is the right place? Might be better to move this - // into createFunctionExpression itself. - if ((languageVersion >= ScriptTarget.ES8) && isAsyncFunctionLike(node)) { - const funcModifiers = visitNodes(node.modifiers, visitor, isModifier); - func.modifiers = createNodeArray(funcModifiers); - } + // Keep modifiers in case of async functions + const funcModifiers = visitNodes(node.modifiers, visitor, isModifier); + func.modifiers = createNodeArray(funcModifiers); setOriginalNode(func, node); @@ -2260,9 +2247,9 @@ namespace ts { } function transformFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody { - if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES8) { - return transformAsyncFunctionBody(node); - } + // if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES2017) { + // return transformAsyncFunctionBody(node); + // } return transformFunctionBodyWorker(node.body); } @@ -2280,9 +2267,9 @@ namespace ts { } function transformConciseBody(node: ArrowFunction): ConciseBody { - if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES8) { - return transformAsyncFunctionBody(node); - } + // if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES2017) { + // return transformAsyncFunctionBody(node); + // } return transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ false); } @@ -2307,72 +2294,6 @@ namespace ts { } } - function getPromiseConstructor(type: TypeNode) { - const typeName = getEntityNameFromTypeNode(type); - if (typeName && isEntityName(typeName)) { - const serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - - return undefined; - } - - function transformAsyncFunctionBody(node: FunctionLikeDeclaration): ConciseBody | FunctionBody { - const promiseConstructor = languageVersion < ScriptTarget.ES6 ? getPromiseConstructor(node.type) : undefined; - const isArrowFunction = node.kind === SyntaxKind.ArrowFunction; - const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; - - // An async function is emit as an outer function that calls an inner - // generator function. To preserve lexical bindings, we pass the current - // `this` and `arguments` objects to `__awaiter`. The generator function - // passed to `__awaiter` is executed inside of the callback to the - // promise constructor. - - - if (!isArrowFunction) { - const statements: Statement[] = []; - const statementOffset = addPrologueDirectives(statements, (node.body).statements, /*ensureUseStrict*/ false, visitor); - statements.push( - createReturn( - createAwaiterHelper( - currentSourceFileExternalHelpersModuleName, - hasLexicalArguments, - promiseConstructor, - transformFunctionBodyWorker(node.body, statementOffset) - ) - ) - ); - - const block = createBlock(statements, /*location*/ node.body, /*multiLine*/ true); - - // Minor optimization, emit `_super` helper to capture `super` access in an arrow. - // This step isn't needed if we eventually transform this to ES5. - if (languageVersion >= ScriptTarget.ES6) { - if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) { - enableSubstitutionForAsyncMethodsWithSuper(); - setEmitFlags(block, EmitFlags.EmitAdvancedSuperHelper); - } - else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuper) { - enableSubstitutionForAsyncMethodsWithSuper(); - setEmitFlags(block, EmitFlags.EmitSuperHelper); - } - } - - return block; - } - else { - return createAwaiterHelper( - currentSourceFileExternalHelpersModuleName, - hasLexicalArguments, - promiseConstructor, - transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true) - ); - } - } - /** * Visits a parameter declaration node. * @@ -2458,33 +2379,18 @@ namespace ts { /** * Visits an await expression. * - * This function will be called any time a TypeScript await expression is encountered. + * This function will be called any time a ES2017 await expression is encountered. * * @param node The await expression node. */ function visitAwaitExpression(node: AwaitExpression): Expression { - const targetAtLeastES8 = languageVersion >= ScriptTarget.ES8; - return setOriginalNode( - targetAtLeastES8 ? createAwaitExpression() : createYieldExpression(), - node - ); - - function createAwaitExpression() { - const awaitExpression = createAwait( + return updateNode( + createAwait( visitNode(node.expression, visitor, isExpression), /*location*/ node - ); - return awaitExpression; - } - - function createYieldExpression() { - const yieldExpression = createYield( - /*asteriskToken*/ undefined, - visitNode(node.expression, visitor, isExpression), - /*location*/ node - ); - return yieldExpression; - } + ), + node + ); } /** @@ -3241,25 +3147,6 @@ namespace ts { } } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper) === 0) { - enabledSubstitutions |= TypeScriptSubstitutionFlags.AsyncMethodsWithSuper; - - // We need to enable substitutions for call, property access, and element access - // if we need to rewrite super calls. - context.enableSubstitution(SyntaxKind.CallExpression); - context.enableSubstitution(SyntaxKind.PropertyAccessExpression); - context.enableSubstitution(SyntaxKind.ElementAccessExpression); - - // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(SyntaxKind.ClassDeclaration); - context.enableEmitNotification(SyntaxKind.MethodDeclaration); - context.enableEmitNotification(SyntaxKind.GetAccessor); - context.enableEmitNotification(SyntaxKind.SetAccessor); - context.enableEmitNotification(SyntaxKind.Constructor); - } - } - function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & TypeScriptSubstitutionFlags.ClassAliases) === 0) { enabledSubstitutions |= TypeScriptSubstitutionFlags.ClassAliases; @@ -3287,15 +3174,6 @@ namespace ts { } } - function isSuperContainer(node: Node): node is SuperContainer { - const kind = node.kind; - return kind === SyntaxKind.ClassDeclaration - || kind === SyntaxKind.Constructor - || kind === SyntaxKind.MethodDeclaration - || kind === SyntaxKind.GetAccessor - || kind === SyntaxKind.SetAccessor; - } - function isTransformedModuleDeclaration(node: Node): boolean { return getOriginalNode(node).kind === SyntaxKind.ModuleDeclaration; } @@ -3312,12 +3190,6 @@ namespace ts { */ function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void { const savedApplicableSubstitutions = applicableSubstitutions; - const savedCurrentSuperContainer = currentSuperContainer; - // If we need to support substitutions for `super` in an async method, - // we should track it here. - if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= TypeScriptSubstitutionFlags.NamespaceExports; @@ -3330,7 +3202,6 @@ namespace ts { previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } /** @@ -3377,11 +3248,6 @@ namespace ts { return substitutePropertyAccessExpression(node); case SyntaxKind.ElementAccessExpression: return substituteElementAccessExpression(node); - case SyntaxKind.CallExpression: - if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper) { - return substituteCallExpression(node); - } - break; } return node; @@ -3436,54 +3302,11 @@ namespace ts { return undefined; } - function substituteCallExpression(node: CallExpression): Expression { - const expression = node.expression; - if (isSuperProperty(expression)) { - const flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - const argumentExpression = isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return createCall( - createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, - [ - createThis(), - ...node.arguments - ] - ); - } - } - return node; - } - function substitutePropertyAccessExpression(node: PropertyAccessExpression) { - if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) { - const flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod( - createLiteral(node.name.text), - flags, - node - ); - } - } - return substituteConstantValue(node); } function substituteElementAccessExpression(node: ElementAccessExpression) { - if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) { - const flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod( - node.argumentExpression, - flags, - node - ); - } - } - return substituteConstantValue(node); } @@ -3516,32 +3339,5 @@ namespace ts { ? resolver.getConstantValue(node) : undefined; } - - function createSuperAccessInAsyncMethod(argumentExpression: Expression, flags: NodeCheckFlags, location: TextRange): LeftHandSideExpression { - if (flags & NodeCheckFlags.AsyncMethodWithSuperBinding) { - return createPropertyAccess( - createCall( - createIdentifier("_super"), - /*typeArguments*/ undefined, - [argumentExpression] - ), - "value", - location - ); - } - else { - return createCall( - createIdentifier("_super"), - /*typeArguments*/ undefined, - [argumentExpression], - location - ); - } - } - - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding); - } } } diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index fc0f016f66453..de710e74a4681 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -24,6 +24,7 @@ "visitor.ts", "transformers/ts.ts", "transformers/jsx.ts", + "transformers/es2017.ts", "transformers/es2016.ts", "transformers/es6.ts", "transformers/generators.ts", diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b661cefb5a646..92ce6ecc6a475 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4142,6 +4142,8 @@ namespace ts { namespace ts { export function getDefaultLibFileName(options: CompilerOptions): string { switch (options.target) { + case ScriptTarget.ES2017: + return "lib.es2017.d.ts"; case ScriptTarget.ES2016: return "lib.es2016.d.ts"; case ScriptTarget.ES6: diff --git a/src/harness/harness.ts b/src/harness/harness.ts index b8703ebc8f276..c50f33a74c332 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -942,6 +942,8 @@ namespace Harness { export function getDefaultLibFileName(options: ts.CompilerOptions): string { switch (options.target) { + case ts.ScriptTarget.ES2017: + return "lib.es2017.d.ts"; case ts.ScriptTarget.ES2016: return "lib.es2016.d.ts"; case ts.ScriptTarget.ES6: diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index aa46c8ee8d079..c8b90645ce24f 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -26,6 +26,7 @@ "../compiler/visitor.ts", "../compiler/transformers/ts.ts", "../compiler/transformers/jsx.ts", + "../compiler/transformers/es2017.ts", "../compiler/transformers/es2016.ts", "../compiler/transformers/es6.ts", "../compiler/transformers/generators.ts", diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index e759ab35b483f..45e3c9036e0cd 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -25,6 +25,7 @@ "../compiler/visitor.ts", "../compiler/transformers/ts.ts", "../compiler/transformers/jsx.ts", + "../compiler/transformers/es2017.ts", "../compiler/transformers/es2016.ts", "../compiler/transformers/es6.ts", "../compiler/transformers/generators.ts", diff --git a/tests/baselines/reference/es8-async.js b/tests/baselines/reference/es2017basicAsync.js similarity index 94% rename from tests/baselines/reference/es8-async.js rename to tests/baselines/reference/es2017basicAsync.js index 3338b1f88a62c..da219f4614c12 100644 --- a/tests/baselines/reference/es8-async.js +++ b/tests/baselines/reference/es2017basicAsync.js @@ -1,4 +1,4 @@ -//// [es8-async.ts] +//// [es2017-async.ts] async (): Promise => { await 0; @@ -47,7 +47,7 @@ class AsyncClass { } -//// [es8-async.js] +//// [es2017-async.js] async () => { await 0; }; diff --git a/tests/baselines/reference/es8-async.symbols b/tests/baselines/reference/es2017basicAsync.symbols similarity index 78% rename from tests/baselines/reference/es8-async.symbols rename to tests/baselines/reference/es2017basicAsync.symbols index 25a77351aef6c..be3b2e723f4c5 100644 --- a/tests/baselines/reference/es8-async.symbols +++ b/tests/baselines/reference/es2017basicAsync.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es8-async.ts === +=== tests/cases/compiler/es2017-async.ts === async (): Promise => { >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) @@ -7,20 +7,20 @@ async (): Promise => { } async function asyncFunc() { ->asyncFunc : Symbol(asyncFunc, Decl(es8-async.ts, 3, 1)) +>asyncFunc : Symbol(asyncFunc, Decl(es2017-async.ts, 3, 1)) await 0; } const asycnArrowFunc = async (): Promise => { ->asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es8-async.ts, 9, 5)) +>asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es2017-async.ts, 9, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 0; } async function asyncIIFE() { ->asyncIIFE : Symbol(asyncIIFE, Decl(es8-async.ts, 11, 1)) +>asyncIIFE : Symbol(asyncIIFE, Decl(es2017-async.ts, 11, 1)) await 0; @@ -31,7 +31,7 @@ async function asyncIIFE() { })(); await (async function asyncNamedFunc(): Promise { ->asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es8-async.ts, 20, 11)) +>asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es2017-async.ts, 20, 11)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 1; @@ -45,32 +45,32 @@ async function asyncIIFE() { } class AsyncClass { ->AsyncClass : Symbol(AsyncClass, Decl(es8-async.ts, 27, 1)) +>AsyncClass : Symbol(AsyncClass, Decl(es2017-async.ts, 27, 1)) asyncPropFunc = async function(): Promise { ->asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es8-async.ts, 29, 18)) +>asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es2017-async.ts, 29, 18)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } asyncPropNamedFunc = async function namedFunc(): Promise { ->asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es8-async.ts, 32, 5)) ->namedFunc : Symbol(namedFunc, Decl(es8-async.ts, 34, 24)) +>asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es2017-async.ts, 32, 5)) +>namedFunc : Symbol(namedFunc, Decl(es2017-async.ts, 34, 24)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } asyncPropArrowFunc = async (): Promise => { ->asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es8-async.ts, 36, 5)) +>asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es2017-async.ts, 36, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } async asyncMethod(): Promise { ->asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es8-async.ts, 40, 5)) +>asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es2017-async.ts, 40, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; diff --git a/tests/baselines/reference/es8-async.types b/tests/baselines/reference/es2017basicAsync.types similarity index 94% rename from tests/baselines/reference/es8-async.types rename to tests/baselines/reference/es2017basicAsync.types index da0ca0637777b..79f3a005e6e65 100644 --- a/tests/baselines/reference/es8-async.types +++ b/tests/baselines/reference/es2017basicAsync.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es8-async.ts === +=== tests/cases/compiler/es2017-async.ts === async (): Promise => { >async (): Promise => { await 0;} : () => Promise From 1b4c0e331e5aa11133f0a36e1ba24d7ee748a58a Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Wed, 12 Oct 2016 21:34:55 +0200 Subject: [PATCH 05/13] Add es2017 async conformance --- ...owFunctionWithParameterNameAsync_es2017.js | 6 + ...ctionWithParameterNameAsync_es2017.symbols | 7 + ...unctionWithParameterNameAsync_es2017.types | 8 ++ .../reference/asyncAliasReturnType_es2017.js | 9 ++ .../asyncAliasReturnType_es2017.symbols | 11 ++ .../asyncAliasReturnType_es2017.types | 11 ++ .../asyncArrowFunction10_es2017.errors.txt | 12 ++ .../reference/asyncArrowFunction10_es2017.js | 13 ++ .../reference/asyncArrowFunction1_es2017.js | 8 ++ .../asyncArrowFunction1_es2017.symbols | 7 + .../asyncArrowFunction1_es2017.types | 8 ++ .../reference/asyncArrowFunction2_es2017.js | 7 + .../asyncArrowFunction2_es2017.symbols | 5 + .../asyncArrowFunction2_es2017.types | 6 + .../asyncArrowFunction3_es2017.errors.txt | 8 ++ .../reference/asyncArrowFunction3_es2017.js | 7 + .../reference/asyncArrowFunction4_es2017.js | 7 + .../asyncArrowFunction4_es2017.symbols | 4 + .../asyncArrowFunction4_es2017.types | 5 + .../asyncArrowFunction5_es2017.errors.txt | 24 ++++ .../reference/asyncArrowFunction5_es2017.js | 9 ++ .../asyncArrowFunction6_es2017.errors.txt | 12 ++ .../reference/asyncArrowFunction6_es2017.js | 8 ++ .../asyncArrowFunction7_es2017.errors.txt | 15 ++ .../reference/asyncArrowFunction7_es2017.js | 14 ++ .../asyncArrowFunction8_es2017.errors.txt | 10 ++ .../reference/asyncArrowFunction8_es2017.js | 10 ++ .../asyncArrowFunction9_es2017.errors.txt | 23 ++++ .../reference/asyncArrowFunction9_es2017.js | 8 ++ ...ncArrowFunctionCapturesArguments_es2017.js | 16 +++ ...owFunctionCapturesArguments_es2017.symbols | 20 +++ ...rrowFunctionCapturesArguments_es2017.types | 23 ++++ .../asyncArrowFunctionCapturesThis_es2017.js | 14 ++ ...ncArrowFunctionCapturesThis_es2017.symbols | 13 ++ ...syncArrowFunctionCapturesThis_es2017.types | 15 ++ ...syncAwaitIsolatedModules_es2017.errors.txt | 45 ++++++ .../asyncAwaitIsolatedModules_es2017.js | 73 ++++++++++ .../baselines/reference/asyncAwait_es2017.js | 73 ++++++++++ .../reference/asyncAwait_es2017.symbols | 118 ++++++++++++++++ .../reference/asyncAwait_es2017.types | 129 ++++++++++++++++++ .../reference/asyncClass_es2017.errors.txt | 8 ++ .../baselines/reference/asyncClass_es2017.js | 7 + .../asyncConstructor_es2017.errors.txt | 10 ++ .../reference/asyncConstructor_es2017.js | 11 ++ .../reference/asyncDeclare_es2017.errors.txt | 7 + .../reference/asyncDeclare_es2017.js | 4 + .../reference/asyncEnum_es2017.errors.txt | 9 ++ tests/baselines/reference/asyncEnum_es2017.js | 10 ++ ...yncFunctionDeclaration10_es2017.errors.txt | 26 ++++ .../asyncFunctionDeclaration10_es2017.js | 7 + .../asyncFunctionDeclaration11_es2017.js | 7 + .../asyncFunctionDeclaration11_es2017.symbols | 5 + .../asyncFunctionDeclaration11_es2017.types | 5 + ...yncFunctionDeclaration12_es2017.errors.txt | 16 +++ .../asyncFunctionDeclaration12_es2017.js | 5 + ...yncFunctionDeclaration13_es2017.errors.txt | 11 ++ .../asyncFunctionDeclaration13_es2017.js | 12 ++ .../asyncFunctionDeclaration14_es2017.js | 9 ++ .../asyncFunctionDeclaration14_es2017.symbols | 7 + .../asyncFunctionDeclaration14_es2017.types | 7 + ...yncFunctionDeclaration15_es2017.errors.txt | 48 +++++++ .../asyncFunctionDeclaration15_es2017.js | 64 +++++++++ .../asyncFunctionDeclaration1_es2017.js | 7 + .../asyncFunctionDeclaration1_es2017.symbols | 5 + .../asyncFunctionDeclaration1_es2017.types | 5 + .../asyncFunctionDeclaration2_es2017.js | 7 + .../asyncFunctionDeclaration2_es2017.symbols | 5 + .../asyncFunctionDeclaration2_es2017.types | 5 + ...syncFunctionDeclaration3_es2017.errors.txt | 8 ++ .../asyncFunctionDeclaration3_es2017.js | 7 + .../asyncFunctionDeclaration4_es2017.js | 7 + .../asyncFunctionDeclaration4_es2017.symbols | 4 + .../asyncFunctionDeclaration4_es2017.types | 4 + ...syncFunctionDeclaration5_es2017.errors.txt | 20 +++ .../asyncFunctionDeclaration5_es2017.js | 7 + ...syncFunctionDeclaration6_es2017.errors.txt | 11 ++ .../asyncFunctionDeclaration6_es2017.js | 7 + ...syncFunctionDeclaration7_es2017.errors.txt | 14 ++ .../asyncFunctionDeclaration7_es2017.js | 13 ++ ...syncFunctionDeclaration8_es2017.errors.txt | 10 ++ .../asyncFunctionDeclaration8_es2017.js | 5 + ...syncFunctionDeclaration9_es2017.errors.txt | 9 ++ .../asyncFunctionDeclaration9_es2017.js | 9 ++ .../reference/asyncGetter_es2017.errors.txt | 13 ++ .../baselines/reference/asyncGetter_es2017.js | 11 ++ .../asyncImportedPromise_es2017.errors.txt | 13 ++ .../reference/asyncImportedPromise_es2017.js | 21 +++ .../asyncInterface_es2017.errors.txt | 8 ++ .../reference/asyncInterface_es2017.js | 5 + .../reference/asyncMethodWithSuper_es2017.js | 90 ++++++++++++ .../asyncMethodWithSuper_es2017.symbols | 102 ++++++++++++++ .../asyncMethodWithSuper_es2017.types | 123 +++++++++++++++++ .../reference/asyncModule_es2017.errors.txt | 8 ++ .../baselines/reference/asyncModule_es2017.js | 5 + .../reference/asyncMultiFile_es2017.js | 11 ++ .../reference/asyncMultiFile_es2017.symbols | 8 ++ .../reference/asyncMultiFile_es2017.types | 8 ++ ...asyncQualifiedReturnType_es2017.errors.txt | 13 ++ .../asyncQualifiedReturnType_es2017.js | 18 +++ .../reference/asyncSetter_es2017.errors.txt | 10 ++ .../baselines/reference/asyncSetter_es2017.js | 11 ++ ...syncUnParenthesizedArrowFunction_es2017.js | 9 ++ ...nParenthesizedArrowFunction_es2017.symbols | 19 +++ ...cUnParenthesizedArrowFunction_es2017.types | 25 ++++ .../reference/asyncUseStrict_es2017.js | 13 ++ .../reference/asyncUseStrict_es2017.symbols | 18 +++ .../reference/asyncUseStrict_es2017.types | 22 +++ .../awaitBinaryExpression1_es2017.js | 17 +++ .../awaitBinaryExpression1_es2017.symbols | 29 ++++ .../awaitBinaryExpression1_es2017.types | 33 +++++ .../awaitBinaryExpression2_es2017.js | 17 +++ .../awaitBinaryExpression2_es2017.symbols | 29 ++++ .../awaitBinaryExpression2_es2017.types | 33 +++++ .../awaitBinaryExpression3_es2017.js | 17 +++ .../awaitBinaryExpression3_es2017.symbols | 29 ++++ .../awaitBinaryExpression3_es2017.types | 33 +++++ .../awaitBinaryExpression4_es2017.js | 17 +++ .../awaitBinaryExpression4_es2017.symbols | 29 ++++ .../awaitBinaryExpression4_es2017.types | 34 +++++ .../awaitBinaryExpression5_es2017.js | 19 +++ .../awaitBinaryExpression5_es2017.symbols | 34 +++++ .../awaitBinaryExpression5_es2017.types | 38 ++++++ .../reference/awaitCallExpression1_es2017.js | 21 +++ .../awaitCallExpression1_es2017.symbols | 59 ++++++++ .../awaitCallExpression1_es2017.types | 62 +++++++++ .../reference/awaitCallExpression2_es2017.js | 21 +++ .../awaitCallExpression2_es2017.symbols | 59 ++++++++ .../awaitCallExpression2_es2017.types | 63 +++++++++ .../reference/awaitCallExpression3_es2017.js | 21 +++ .../awaitCallExpression3_es2017.symbols | 59 ++++++++ .../awaitCallExpression3_es2017.types | 63 +++++++++ .../reference/awaitCallExpression4_es2017.js | 21 +++ .../awaitCallExpression4_es2017.symbols | 59 ++++++++ .../awaitCallExpression4_es2017.types | 64 +++++++++ .../reference/awaitCallExpression5_es2017.js | 21 +++ .../awaitCallExpression5_es2017.symbols | 61 +++++++++ .../awaitCallExpression5_es2017.types | 64 +++++++++ .../reference/awaitCallExpression6_es2017.js | 21 +++ .../awaitCallExpression6_es2017.symbols | 61 +++++++++ .../awaitCallExpression6_es2017.types | 65 +++++++++ .../reference/awaitCallExpression7_es2017.js | 21 +++ .../awaitCallExpression7_es2017.symbols | 61 +++++++++ .../awaitCallExpression7_es2017.types | 65 +++++++++ .../reference/awaitCallExpression8_es2017.js | 21 +++ .../awaitCallExpression8_es2017.symbols | 61 +++++++++ .../awaitCallExpression8_es2017.types | 66 +++++++++ .../reference/awaitClassExpression_es2017.js | 14 ++ .../awaitClassExpression_es2017.symbols | 18 +++ .../awaitClassExpression_es2017.types | 20 +++ .../baselines/reference/awaitUnion_es2017.js | 22 +++ .../reference/awaitUnion_es2017.symbols | 44 ++++++ .../reference/awaitUnion_es2017.types | 49 +++++++ .../reference/await_unaryExpression_es2017.js | 31 +++++ .../await_unaryExpression_es2017.symbols | 25 ++++ .../await_unaryExpression_es2017.types | 37 +++++ .../await_unaryExpression_es2017_1.js | 38 ++++++ .../await_unaryExpression_es2017_1.symbols | 31 +++++ .../await_unaryExpression_es2017_1.types | 46 +++++++ .../await_unaryExpression_es2017_2.js | 24 ++++ .../await_unaryExpression_es2017_2.symbols | 19 +++ .../await_unaryExpression_es2017_2.types | 28 ++++ .../await_unaryExpression_es2017_3.errors.txt | 27 ++++ .../await_unaryExpression_es2017_3.js | 37 +++++ tests/baselines/reference/es2017basicAsync.js | 4 +- .../reference/es2017basicAsync.symbols | 22 +-- .../reference/es2017basicAsync.types | 2 +- .../es2017/asyncAliasReturnType_es2017.ts | 6 + ...owFunctionWithParameterNameAsync_es2017.ts | 4 + .../asyncArrowFunction10_es2017.ts | 7 + .../asyncArrowFunction1_es2017.ts | 5 + .../asyncArrowFunction2_es2017.ts | 4 + .../asyncArrowFunction3_es2017.ts | 4 + .../asyncArrowFunction4_es2017.ts | 4 + .../asyncArrowFunction5_es2017.ts | 5 + .../asyncArrowFunction6_es2017.ts | 5 + .../asyncArrowFunction7_es2017.ts | 8 ++ .../asyncArrowFunction8_es2017.ts | 6 + .../asyncArrowFunction9_es2017.ts | 4 + ...ncArrowFunctionCapturesArguments_es2017.ts | 8 ++ .../asyncArrowFunctionCapturesThis_es2017.ts | 7 + ...syncUnParenthesizedArrowFunction_es2017.ts | 6 + .../asyncAwaitIsolatedModules_es2017.ts | 41 ++++++ .../async/es2017/asyncAwait_es2017.ts | 40 ++++++ .../async/es2017/asyncClass_es2017.ts | 4 + .../async/es2017/asyncConstructor_es2017.ts | 6 + .../async/es2017/asyncDeclare_es2017.ts | 3 + .../async/es2017/asyncEnum_es2017.ts | 5 + .../async/es2017/asyncGetter_es2017.ts | 6 + .../es2017/asyncImportedPromise_es2017.ts | 10 ++ .../async/es2017/asyncInterface_es2017.ts | 4 + .../es2017/asyncMethodWithSuper_es2017.ts | 52 +++++++ .../async/es2017/asyncModule_es2017.ts | 4 + .../async/es2017/asyncMultiFile_es2017.ts | 5 + .../es2017/asyncQualifiedReturnType_es2017.ts | 9 ++ .../async/es2017/asyncSetter_es2017.ts | 6 + .../async/es2017/asyncUseStrict_es2017.ts | 8 ++ .../awaitBinaryExpression1_es2017.ts | 11 ++ .../awaitBinaryExpression2_es2017.ts | 11 ++ .../awaitBinaryExpression3_es2017.ts | 11 ++ .../awaitBinaryExpression4_es2017.ts | 11 ++ .../awaitBinaryExpression5_es2017.ts | 12 ++ .../awaitCallExpression1_es2017.ts | 15 ++ .../awaitCallExpression2_es2017.ts | 15 ++ .../awaitCallExpression3_es2017.ts | 15 ++ .../awaitCallExpression4_es2017.ts | 15 ++ .../awaitCallExpression5_es2017.ts | 15 ++ .../awaitCallExpression6_es2017.ts | 15 ++ .../awaitCallExpression7_es2017.ts | 15 ++ .../awaitCallExpression8_es2017.ts | 15 ++ .../es2017/awaitClassExpression_es2017.ts | 9 ++ .../async/es2017/awaitUnion_es2017.ts | 14 ++ .../es2017/await_unaryExpression_es2017.ts | 17 +++ .../es2017/await_unaryExpression_es2017_1.ts | 21 +++ .../es2017/await_unaryExpression_es2017_2.ts | 13 ++ .../es2017/await_unaryExpression_es2017_3.ts | 19 +++ .../asyncFunctionDeclaration10_es2017.ts | 4 + .../asyncFunctionDeclaration11_es2017.ts | 4 + .../asyncFunctionDeclaration12_es2017.ts | 3 + .../asyncFunctionDeclaration13_es2017.ts | 6 + .../asyncFunctionDeclaration14_es2017.ts | 5 + .../asyncFunctionDeclaration15_es2017.ts | 25 ++++ .../asyncFunctionDeclaration1_es2017.ts | 4 + .../asyncFunctionDeclaration2_es2017.ts | 4 + .../asyncFunctionDeclaration3_es2017.ts | 4 + .../asyncFunctionDeclaration4_es2017.ts | 4 + .../asyncFunctionDeclaration5_es2017.ts | 4 + .../asyncFunctionDeclaration6_es2017.ts | 4 + .../asyncFunctionDeclaration7_es2017.ts | 7 + .../asyncFunctionDeclaration8_es2017.ts | 3 + .../asyncFunctionDeclaration9_es2017.ts | 5 + 230 files changed, 4602 insertions(+), 14 deletions(-) create mode 100644 tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.js create mode 100644 tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.symbols create mode 100644 tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.types create mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.js create mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.symbols create mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.types create mode 100644 tests/baselines/reference/asyncArrowFunction10_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction10_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction1_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction1_es2017.symbols create mode 100644 tests/baselines/reference/asyncArrowFunction1_es2017.types create mode 100644 tests/baselines/reference/asyncArrowFunction2_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction2_es2017.symbols create mode 100644 tests/baselines/reference/asyncArrowFunction2_es2017.types create mode 100644 tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction3_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction4_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction4_es2017.symbols create mode 100644 tests/baselines/reference/asyncArrowFunction4_es2017.types create mode 100644 tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction5_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction6_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction6_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction7_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction7_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction8_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction8_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction9_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.symbols create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.types create mode 100644 tests/baselines/reference/asyncAwaitIsolatedModules_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js create mode 100644 tests/baselines/reference/asyncAwait_es2017.js create mode 100644 tests/baselines/reference/asyncAwait_es2017.symbols create mode 100644 tests/baselines/reference/asyncAwait_es2017.types create mode 100644 tests/baselines/reference/asyncClass_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncClass_es2017.js create mode 100644 tests/baselines/reference/asyncConstructor_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncConstructor_es2017.js create mode 100644 tests/baselines/reference/asyncDeclare_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncDeclare_es2017.js create mode 100644 tests/baselines/reference/asyncEnum_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncEnum_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration11_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration11_es2017.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration12_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration13_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration13_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration14_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration14_es2017.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration15_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration1_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration1_es2017.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration2_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration2_es2017.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration2_es2017.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration3_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration4_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration4_es2017.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration4_es2017.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration5_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration6_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration6_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration7_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration7_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration8_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration8_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration9_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration9_es2017.js create mode 100644 tests/baselines/reference/asyncGetter_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncGetter_es2017.js create mode 100644 tests/baselines/reference/asyncImportedPromise_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncImportedPromise_es2017.js create mode 100644 tests/baselines/reference/asyncInterface_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncInterface_es2017.js create mode 100644 tests/baselines/reference/asyncMethodWithSuper_es2017.js create mode 100644 tests/baselines/reference/asyncMethodWithSuper_es2017.symbols create mode 100644 tests/baselines/reference/asyncMethodWithSuper_es2017.types create mode 100644 tests/baselines/reference/asyncModule_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncModule_es2017.js create mode 100644 tests/baselines/reference/asyncMultiFile_es2017.js create mode 100644 tests/baselines/reference/asyncMultiFile_es2017.symbols create mode 100644 tests/baselines/reference/asyncMultiFile_es2017.types create mode 100644 tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncQualifiedReturnType_es2017.js create mode 100644 tests/baselines/reference/asyncSetter_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncSetter_es2017.js create mode 100644 tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.js create mode 100644 tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols create mode 100644 tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.types create mode 100644 tests/baselines/reference/asyncUseStrict_es2017.js create mode 100644 tests/baselines/reference/asyncUseStrict_es2017.symbols create mode 100644 tests/baselines/reference/asyncUseStrict_es2017.types create mode 100644 tests/baselines/reference/awaitBinaryExpression1_es2017.js create mode 100644 tests/baselines/reference/awaitBinaryExpression1_es2017.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression1_es2017.types create mode 100644 tests/baselines/reference/awaitBinaryExpression2_es2017.js create mode 100644 tests/baselines/reference/awaitBinaryExpression2_es2017.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression2_es2017.types create mode 100644 tests/baselines/reference/awaitBinaryExpression3_es2017.js create mode 100644 tests/baselines/reference/awaitBinaryExpression3_es2017.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression3_es2017.types create mode 100644 tests/baselines/reference/awaitBinaryExpression4_es2017.js create mode 100644 tests/baselines/reference/awaitBinaryExpression4_es2017.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression4_es2017.types create mode 100644 tests/baselines/reference/awaitBinaryExpression5_es2017.js create mode 100644 tests/baselines/reference/awaitBinaryExpression5_es2017.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression5_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression1_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression1_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression1_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression2_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression2_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression2_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression3_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression3_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression3_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression4_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression4_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression4_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression5_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression5_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression5_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression6_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression6_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression6_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression7_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression7_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression7_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression8_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression8_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression8_es2017.types create mode 100644 tests/baselines/reference/awaitClassExpression_es2017.js create mode 100644 tests/baselines/reference/awaitClassExpression_es2017.symbols create mode 100644 tests/baselines/reference/awaitClassExpression_es2017.types create mode 100644 tests/baselines/reference/awaitUnion_es2017.js create mode 100644 tests/baselines/reference/awaitUnion_es2017.symbols create mode 100644 tests/baselines/reference/awaitUnion_es2017.types create mode 100644 tests/baselines/reference/await_unaryExpression_es2017.js create mode 100644 tests/baselines/reference/await_unaryExpression_es2017.symbols create mode 100644 tests/baselines/reference/await_unaryExpression_es2017.types create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_1.js create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_1.symbols create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_1.types create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_2.js create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_2.symbols create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_2.types create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_3.errors.txt create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_3.js create mode 100644 tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncAwait_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncClass_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncEnum_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncGetter_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncInterface_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncModule_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncSetter_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitUnion_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts create mode 100644 tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts create mode 100644 tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts diff --git a/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.js b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.js new file mode 100644 index 0000000000000..daaff29cad927 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.js @@ -0,0 +1,6 @@ +//// [arrowFunctionWithParameterNameAsync_es2017.ts] + +const x = async => async; + +//// [arrowFunctionWithParameterNameAsync_es2017.js] +var x = function (async) { return async; }; diff --git a/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.symbols b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.symbols new file mode 100644 index 0000000000000..481697c0afdc9 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts === + +const x = async => async; +>x : Symbol(x, Decl(arrowFunctionWithParameterNameAsync_es2017.ts, 1, 5)) +>async : Symbol(async, Decl(arrowFunctionWithParameterNameAsync_es2017.ts, 1, 9)) +>async : Symbol(async, Decl(arrowFunctionWithParameterNameAsync_es2017.ts, 1, 9)) + diff --git a/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.types b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.types new file mode 100644 index 0000000000000..ccb8654284c2e --- /dev/null +++ b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts === + +const x = async => async; +>x : (async: any) => any +>async => async : (async: any) => any +>async : any +>async : any + diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.js b/tests/baselines/reference/asyncAliasReturnType_es2017.js new file mode 100644 index 0000000000000..f76f2b13b458b --- /dev/null +++ b/tests/baselines/reference/asyncAliasReturnType_es2017.js @@ -0,0 +1,9 @@ +//// [asyncAliasReturnType_es2017.ts] +type PromiseAlias = Promise; + +async function f(): PromiseAlias { +} + +//// [asyncAliasReturnType_es2017.js] +async function f() { +} diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.symbols b/tests/baselines/reference/asyncAliasReturnType_es2017.symbols new file mode 100644 index 0000000000000..cc4fc5b809627 --- /dev/null +++ b/tests/baselines/reference/asyncAliasReturnType_es2017.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts === +type PromiseAlias = Promise; +>PromiseAlias : Symbol(PromiseAlias, Decl(asyncAliasReturnType_es2017.ts, 0, 0)) +>T : Symbol(T, Decl(asyncAliasReturnType_es2017.ts, 0, 18)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(asyncAliasReturnType_es2017.ts, 0, 18)) + +async function f(): PromiseAlias { +>f : Symbol(f, Decl(asyncAliasReturnType_es2017.ts, 0, 34)) +>PromiseAlias : Symbol(PromiseAlias, Decl(asyncAliasReturnType_es2017.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.types b/tests/baselines/reference/asyncAliasReturnType_es2017.types new file mode 100644 index 0000000000000..67c521b77fa4b --- /dev/null +++ b/tests/baselines/reference/asyncAliasReturnType_es2017.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts === +type PromiseAlias = Promise; +>PromiseAlias : Promise +>T : T +>Promise : Promise +>T : T + +async function f(): PromiseAlias { +>f : () => Promise +>PromiseAlias : Promise +} diff --git a/tests/baselines/reference/asyncArrowFunction10_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction10_es2017.errors.txt new file mode 100644 index 0000000000000..923dbed6dad93 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es2017.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts(4,11): error TS2304: Cannot find name 'await'. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts (1 errors) ==== + + var foo = async (): Promise => { + // Legal to use 'await' in a type context. + var v: await; + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction10_es2017.js b/tests/baselines/reference/asyncArrowFunction10_es2017.js new file mode 100644 index 0000000000000..3c966201bc20c --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es2017.js @@ -0,0 +1,13 @@ +//// [asyncArrowFunction10_es2017.ts] + +var foo = async (): Promise => { + // Legal to use 'await' in a type context. + var v: await; +} + + +//// [asyncArrowFunction10_es2017.js] +var foo = async () => { + // Legal to use 'await' in a type context. + var v; +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es2017.js b/tests/baselines/reference/asyncArrowFunction1_es2017.js new file mode 100644 index 0000000000000..ff6a4624242bd --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es2017.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction1_es2017.ts] + +var foo = async (): Promise => { +}; + +//// [asyncArrowFunction1_es2017.js] +var foo = async () => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es2017.symbols b/tests/baselines/reference/asyncArrowFunction1_es2017.symbols new file mode 100644 index 0000000000000..35fd033d6b4af --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es2017.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts === + +var foo = async (): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction1_es2017.ts, 1, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es2017.types b/tests/baselines/reference/asyncArrowFunction1_es2017.types new file mode 100644 index 0000000000000..bdc6cacc91704 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es2017.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts === + +var foo = async (): Promise => { +>foo : () => Promise +>async (): Promise => {} : () => Promise +>Promise : Promise + +}; diff --git a/tests/baselines/reference/asyncArrowFunction2_es2017.js b/tests/baselines/reference/asyncArrowFunction2_es2017.js new file mode 100644 index 0000000000000..d2a5d0306b10d --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es2017.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction2_es2017.ts] +var f = (await) => { +} + +//// [asyncArrowFunction2_es2017.js] +var f = (await) => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction2_es2017.symbols b/tests/baselines/reference/asyncArrowFunction2_es2017.symbols new file mode 100644 index 0000000000000..a56c5bb62c839 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es2017.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts === +var f = (await) => { +>f : Symbol(f, Decl(asyncArrowFunction2_es2017.ts, 0, 3)) +>await : Symbol(await, Decl(asyncArrowFunction2_es2017.ts, 0, 9)) +} diff --git a/tests/baselines/reference/asyncArrowFunction2_es2017.types b/tests/baselines/reference/asyncArrowFunction2_es2017.types new file mode 100644 index 0000000000000..1feb033e6eef8 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es2017.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts === +var f = (await) => { +>f : (await: any) => void +>(await) => {} : (await: any) => void +>await : any +} diff --git a/tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt new file mode 100644 index 0000000000000..1c1fd7117606e --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts (1 errors) ==== + function f(await = await) { + ~~~~~ +!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction3_es2017.js b/tests/baselines/reference/asyncArrowFunction3_es2017.js new file mode 100644 index 0000000000000..7ae371facc117 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es2017.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction3_es2017.ts] +function f(await = await) { +} + +//// [asyncArrowFunction3_es2017.js] +function f(await = await) { +} diff --git a/tests/baselines/reference/asyncArrowFunction4_es2017.js b/tests/baselines/reference/asyncArrowFunction4_es2017.js new file mode 100644 index 0000000000000..ebec1e6dbd67d --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es2017.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction4_es2017.ts] +var await = () => { +} + +//// [asyncArrowFunction4_es2017.js] +var await = () => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction4_es2017.symbols b/tests/baselines/reference/asyncArrowFunction4_es2017.symbols new file mode 100644 index 0000000000000..b44fc0dbdf60d --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es2017.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts === +var await = () => { +>await : Symbol(await, Decl(asyncArrowFunction4_es2017.ts, 0, 3)) +} diff --git a/tests/baselines/reference/asyncArrowFunction4_es2017.types b/tests/baselines/reference/asyncArrowFunction4_es2017.types new file mode 100644 index 0000000000000..6af5f94c75869 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es2017.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts === +var await = () => { +>await : () => void +>() => {} : () => void +} diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt new file mode 100644 index 0000000000000..3df5617710712 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(2,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(2,18): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(2,24): error TS1005: ',' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.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/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(2,33): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(2,40): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts (6 errors) ==== + + var foo = async (await): Promise => { + ~~~~~ +!!! 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. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.js b/tests/baselines/reference/asyncArrowFunction5_es2017.js new file mode 100644 index 0000000000000..0c61a141f176c --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.js @@ -0,0 +1,9 @@ +//// [asyncArrowFunction5_es2017.ts] + +var foo = async (await): Promise => { +} + +//// [asyncArrowFunction5_es2017.js] +var foo = async(await), Promise = ; +{ +} diff --git a/tests/baselines/reference/asyncArrowFunction6_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction6_es2017.errors.txt new file mode 100644 index 0000000000000..202ecb1727fd5 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es2017.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts(2,22): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts(2,27): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts (2 errors) ==== + + var foo = async (a = await): Promise => { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction6_es2017.js b/tests/baselines/reference/asyncArrowFunction6_es2017.js new file mode 100644 index 0000000000000..c36f75a180a76 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es2017.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction6_es2017.ts] + +var foo = async (a = await): Promise => { +} + +//// [asyncArrowFunction6_es2017.js] +var foo = async (a = await ) => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction7_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction7_es2017.errors.txt new file mode 100644 index 0000000000000..33e03624283e6 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es2017.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts(4,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts(4,29): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts (2 errors) ==== + + var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction7_es2017.js b/tests/baselines/reference/asyncArrowFunction7_es2017.js new file mode 100644 index 0000000000000..11d8c879eb8bd --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es2017.js @@ -0,0 +1,14 @@ +//// [asyncArrowFunction7_es2017.ts] + +var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + } +} + +//// [asyncArrowFunction7_es2017.js] +var bar = async () => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await ) => { + }; +}; diff --git a/tests/baselines/reference/asyncArrowFunction8_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction8_es2017.errors.txt new file mode 100644 index 0000000000000..75e460490bd85 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es2017.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts(3,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts (1 errors) ==== + + var foo = async (): Promise => { + var v = { [await]: foo } + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction8_es2017.js b/tests/baselines/reference/asyncArrowFunction8_es2017.js new file mode 100644 index 0000000000000..1358f186ce221 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es2017.js @@ -0,0 +1,10 @@ +//// [asyncArrowFunction8_es2017.ts] + +var foo = async (): Promise => { + var v = { [await]: foo } +} + +//// [asyncArrowFunction8_es2017.js] +var foo = async () => { + var v = { [await ]: foo }; +}; diff --git a/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt new file mode 100644 index 0000000000000..ee94f3f9caf72 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,18): error TS2304: Cannot find name 'a'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,37): error TS1005: ',' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.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/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,46): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts (6 errors) ==== + var foo = async (a = await => await): Promise => { + ~~~~~ +!!! 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. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es2017.js b/tests/baselines/reference/asyncArrowFunction9_es2017.js new file mode 100644 index 0000000000000..c1fec991ec18c --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es2017.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction9_es2017.ts] +var foo = async (a = await => await): Promise => { +} + +//// [asyncArrowFunction9_es2017.js] +var foo = async(a = await => await), Promise = ; +{ +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.js b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.js new file mode 100644 index 0000000000000..f7f813ad50230 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.js @@ -0,0 +1,16 @@ +//// [asyncArrowFunctionCapturesArguments_es2017.ts] +class C { + method() { + function other() {} + var fn = async () => await other.apply(this, arguments); + } +} + + +//// [asyncArrowFunctionCapturesArguments_es2017.js] +class C { + method() { + function other() { } + var fn = async () => await other.apply(this, arguments); + } +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols new file mode 100644 index 0000000000000..ccd9b48e400e5 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts === +class C { +>C : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 0, 0)) + + method() { +>method : Symbol(C.method, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 0, 9)) + + function other() {} +>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 1, 13)) + + var fn = async () => await other.apply(this, arguments); +>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 3, 9)) +>other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) +>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 1, 13)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) +>this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 0, 0)) +>arguments : Symbol(arguments) + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types new file mode 100644 index 0000000000000..a7a80424e1977 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts === +class C { +>C : C + + method() { +>method : () => void + + function other() {} +>other : () => void + + var fn = async () => await other.apply(this, arguments); +>fn : () => Promise +>async () => await other.apply(this, arguments) : () => Promise +>await other.apply(this, arguments) : any +>other.apply(this, arguments) : any +>other.apply : (this: Function, thisArg: any, argArray?: any) => any +>other : () => void +>apply : (this: Function, thisArg: any, argArray?: any) => any +>this : this +>arguments : IArguments + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.js b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.js new file mode 100644 index 0000000000000..13560557ffef0 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.js @@ -0,0 +1,14 @@ +//// [asyncArrowFunctionCapturesThis_es2017.ts] +class C { + method() { + var fn = async () => await this; + } +} + + +//// [asyncArrowFunctionCapturesThis_es2017.js] +class C { + method() { + var fn = async () => await this; + } +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.symbols new file mode 100644 index 0000000000000..bc14bafa0c5e6 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts === +class C { +>C : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es2017.ts, 0, 0)) + + method() { +>method : Symbol(C.method, Decl(asyncArrowFunctionCapturesThis_es2017.ts, 0, 9)) + + var fn = async () => await this; +>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesThis_es2017.ts, 2, 9)) +>this : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es2017.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.types b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.types new file mode 100644 index 0000000000000..57f59302bb5bc --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts === +class C { +>C : C + + method() { +>method : () => void + + var fn = async () => await this; +>fn : () => Promise +>async () => await this : () => Promise +>await this : this +>this : this + } +} + diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.errors.txt b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.errors.txt new file mode 100644 index 0000000000000..95927c283aa4b --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts(1,27): error TS2307: Cannot find module 'missing'. + + +==== tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts (1 errors) ==== + import { MyPromise } from "missing"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'missing'. + + declare var p: Promise; + declare var mp: MyPromise; + + async function f0() { } + async function f1(): Promise { } + async function f3(): MyPromise { } + + let f4 = async function() { } + let f5 = async function(): Promise { } + let f6 = async function(): MyPromise { } + + let f7 = async () => { }; + let f8 = async (): Promise => { }; + let f9 = async (): MyPromise => { }; + let f10 = async () => p; + let f11 = async () => mp; + let f12 = async (): Promise => mp; + let f13 = async (): MyPromise => p; + + let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } + }; + + class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } + } + + module M { + export async function f1() { } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js new file mode 100644 index 0000000000000..065aa675b6e57 --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js @@ -0,0 +1,73 @@ +//// [asyncAwaitIsolatedModules_es2017.ts] +import { MyPromise } from "missing"; + +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} + +//// [asyncAwaitIsolatedModules_es2017.js] +async function f0() { } +async function f1() { } +async function f3() { } +let f4 = async function () { }; +let f5 = async function () { }; +let f6 = async function () { }; +let f7 = async () => { }; +let f8 = async () => { }; +let f9 = async () => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async () => mp; +let f13 = async () => p; +let o = { + async m1() { }, + async m2() { }, + async m3() { } +}; +class C { + async m1() { } + async m2() { } + async m3() { } + static async m4() { } + static async m5() { } + static async m6() { } +} +var M; +(function (M) { + async function f1() { } + M.f1 = f1; +})(M || (M = {})); diff --git a/tests/baselines/reference/asyncAwait_es2017.js b/tests/baselines/reference/asyncAwait_es2017.js new file mode 100644 index 0000000000000..314c99fa21077 --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es2017.js @@ -0,0 +1,73 @@ +//// [asyncAwait_es2017.ts] +type MyPromise = Promise; +declare var MyPromise: typeof Promise; +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} + +//// [asyncAwait_es2017.js] +async function f0() { } +async function f1() { } +async function f3() { } +let f4 = async function () { }; +let f5 = async function () { }; +let f6 = async function () { }; +let f7 = async () => { }; +let f8 = async () => { }; +let f9 = async () => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async () => mp; +let f13 = async () => p; +let o = { + async m1() { }, + async m2() { }, + async m3() { } +}; +class C { + async m1() { } + async m2() { } + async m3() { } + static async m4() { } + static async m5() { } + static async m6() { } +} +var M; +(function (M) { + async function f1() { } + M.f1 = f1; +})(M || (M = {})); diff --git a/tests/baselines/reference/asyncAwait_es2017.symbols b/tests/baselines/reference/asyncAwait_es2017.symbols new file mode 100644 index 0000000000000..34dc9802a25de --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es2017.symbols @@ -0,0 +1,118 @@ +=== tests/cases/conformance/async/es2017/asyncAwait_es2017.ts === +type MyPromise = Promise; +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) +>T : Symbol(T, Decl(asyncAwait_es2017.ts, 0, 15)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(asyncAwait_es2017.ts, 0, 15)) + +declare var MyPromise: typeof Promise; +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare var p: Promise; +>p : Symbol(p, Decl(asyncAwait_es2017.ts, 2, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare var mp: MyPromise; +>mp : Symbol(mp, Decl(asyncAwait_es2017.ts, 3, 11)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + +async function f0() { } +>f0 : Symbol(f0, Decl(asyncAwait_es2017.ts, 3, 34)) + +async function f1(): Promise { } +>f1 : Symbol(f1, Decl(asyncAwait_es2017.ts, 5, 23)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +async function f3(): MyPromise { } +>f3 : Symbol(f3, Decl(asyncAwait_es2017.ts, 6, 38)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + +let f4 = async function() { } +>f4 : Symbol(f4, Decl(asyncAwait_es2017.ts, 9, 3)) + +let f5 = async function(): Promise { } +>f5 : Symbol(f5, Decl(asyncAwait_es2017.ts, 10, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +let f6 = async function(): MyPromise { } +>f6 : Symbol(f6, Decl(asyncAwait_es2017.ts, 11, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + +let f7 = async () => { }; +>f7 : Symbol(f7, Decl(asyncAwait_es2017.ts, 13, 3)) + +let f8 = async (): Promise => { }; +>f8 : Symbol(f8, Decl(asyncAwait_es2017.ts, 14, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +let f9 = async (): MyPromise => { }; +>f9 : Symbol(f9, Decl(asyncAwait_es2017.ts, 15, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + +let f10 = async () => p; +>f10 : Symbol(f10, Decl(asyncAwait_es2017.ts, 16, 3)) +>p : Symbol(p, Decl(asyncAwait_es2017.ts, 2, 11)) + +let f11 = async () => mp; +>f11 : Symbol(f11, Decl(asyncAwait_es2017.ts, 17, 3)) +>mp : Symbol(mp, Decl(asyncAwait_es2017.ts, 3, 11)) + +let f12 = async (): Promise => mp; +>f12 : Symbol(f12, Decl(asyncAwait_es2017.ts, 18, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>mp : Symbol(mp, Decl(asyncAwait_es2017.ts, 3, 11)) + +let f13 = async (): MyPromise => p; +>f13 : Symbol(f13, Decl(asyncAwait_es2017.ts, 19, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) +>p : Symbol(p, Decl(asyncAwait_es2017.ts, 2, 11)) + +let o = { +>o : Symbol(o, Decl(asyncAwait_es2017.ts, 21, 3)) + + async m1() { }, +>m1 : Symbol(m1, Decl(asyncAwait_es2017.ts, 21, 9)) + + async m2(): Promise { }, +>m2 : Symbol(m2, Decl(asyncAwait_es2017.ts, 22, 16)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + async m3(): MyPromise { } +>m3 : Symbol(m3, Decl(asyncAwait_es2017.ts, 23, 31)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + +}; + +class C { +>C : Symbol(C, Decl(asyncAwait_es2017.ts, 25, 2)) + + async m1() { } +>m1 : Symbol(C.m1, Decl(asyncAwait_es2017.ts, 27, 9)) + + async m2(): Promise { } +>m2 : Symbol(C.m2, Decl(asyncAwait_es2017.ts, 28, 15)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + async m3(): MyPromise { } +>m3 : Symbol(C.m3, Decl(asyncAwait_es2017.ts, 29, 30)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + + static async m4() { } +>m4 : Symbol(C.m4, Decl(asyncAwait_es2017.ts, 30, 32)) + + static async m5(): Promise { } +>m5 : Symbol(C.m5, Decl(asyncAwait_es2017.ts, 31, 22)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + static async m6(): MyPromise { } +>m6 : Symbol(C.m6, Decl(asyncAwait_es2017.ts, 32, 37)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) +} + +module M { +>M : Symbol(M, Decl(asyncAwait_es2017.ts, 34, 1)) + + export async function f1() { } +>f1 : Symbol(f1, Decl(asyncAwait_es2017.ts, 36, 10)) +} diff --git a/tests/baselines/reference/asyncAwait_es2017.types b/tests/baselines/reference/asyncAwait_es2017.types new file mode 100644 index 0000000000000..a1226d0cbfe70 --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es2017.types @@ -0,0 +1,129 @@ +=== tests/cases/conformance/async/es2017/asyncAwait_es2017.ts === +type MyPromise = Promise; +>MyPromise : Promise +>T : T +>Promise : Promise +>T : T + +declare var MyPromise: typeof Promise; +>MyPromise : PromiseConstructor +>Promise : PromiseConstructor + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare var mp: MyPromise; +>mp : Promise +>MyPromise : Promise + +async function f0() { } +>f0 : () => Promise + +async function f1(): Promise { } +>f1 : () => Promise +>Promise : Promise + +async function f3(): MyPromise { } +>f3 : () => Promise +>MyPromise : Promise + +let f4 = async function() { } +>f4 : () => Promise +>async function() { } : () => Promise + +let f5 = async function(): Promise { } +>f5 : () => Promise +>async function(): Promise { } : () => Promise +>Promise : Promise + +let f6 = async function(): MyPromise { } +>f6 : () => Promise +>async function(): MyPromise { } : () => Promise +>MyPromise : Promise + +let f7 = async () => { }; +>f7 : () => Promise +>async () => { } : () => Promise + +let f8 = async (): Promise => { }; +>f8 : () => Promise +>async (): Promise => { } : () => Promise +>Promise : Promise + +let f9 = async (): MyPromise => { }; +>f9 : () => Promise +>async (): MyPromise => { } : () => Promise +>MyPromise : Promise + +let f10 = async () => p; +>f10 : () => Promise +>async () => p : () => Promise +>p : Promise + +let f11 = async () => mp; +>f11 : () => Promise +>async () => mp : () => Promise +>mp : Promise + +let f12 = async (): Promise => mp; +>f12 : () => Promise +>async (): Promise => mp : () => Promise +>Promise : Promise +>mp : Promise + +let f13 = async (): MyPromise => p; +>f13 : () => Promise +>async (): MyPromise => p : () => Promise +>MyPromise : Promise +>p : Promise + +let o = { +>o : { m1(): Promise; m2(): Promise; m3(): Promise; } +>{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): Promise; } + + async m1() { }, +>m1 : () => Promise + + async m2(): Promise { }, +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => Promise +>MyPromise : Promise + +}; + +class C { +>C : C + + async m1() { } +>m1 : () => Promise + + async m2(): Promise { } +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => Promise +>MyPromise : Promise + + static async m4() { } +>m4 : () => Promise + + static async m5(): Promise { } +>m5 : () => Promise +>Promise : Promise + + static async m6(): MyPromise { } +>m6 : () => Promise +>MyPromise : Promise +} + +module M { +>M : typeof M + + export async function f1() { } +>f1 : () => Promise +} diff --git a/tests/baselines/reference/asyncClass_es2017.errors.txt b/tests/baselines/reference/asyncClass_es2017.errors.txt new file mode 100644 index 0000000000000..37612b0b0f2d2 --- /dev/null +++ b/tests/baselines/reference/asyncClass_es2017.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es2017/asyncClass_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es2017/asyncClass_es2017.ts (1 errors) ==== + async class C { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncClass_es2017.js b/tests/baselines/reference/asyncClass_es2017.js new file mode 100644 index 0000000000000..e619bd50b9735 --- /dev/null +++ b/tests/baselines/reference/asyncClass_es2017.js @@ -0,0 +1,7 @@ +//// [asyncClass_es2017.ts] +async class C { +} + +//// [asyncClass_es2017.js] +async class C { +} diff --git a/tests/baselines/reference/asyncConstructor_es2017.errors.txt b/tests/baselines/reference/asyncConstructor_es2017.errors.txt new file mode 100644 index 0000000000000..3b0c1b42fa90c --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es2017.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts(2,3): error TS1089: 'async' modifier cannot appear on a constructor declaration. + + +==== tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts (1 errors) ==== + class C { + async constructor() { + ~~~~~ +!!! error TS1089: 'async' modifier cannot appear on a constructor declaration. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncConstructor_es2017.js b/tests/baselines/reference/asyncConstructor_es2017.js new file mode 100644 index 0000000000000..7dcd6ec694364 --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es2017.js @@ -0,0 +1,11 @@ +//// [asyncConstructor_es2017.ts] +class C { + async constructor() { + } +} + +//// [asyncConstructor_es2017.js] +class C { + async constructor() { + } +} diff --git a/tests/baselines/reference/asyncDeclare_es2017.errors.txt b/tests/baselines/reference/asyncDeclare_es2017.errors.txt new file mode 100644 index 0000000000000..bb74a3865d5c4 --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es2017.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts(1,9): error TS1040: 'async' modifier cannot be used in an ambient context. + + +==== tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts (1 errors) ==== + declare async function foo(): Promise; + ~~~~~ +!!! error TS1040: 'async' modifier cannot be used in an ambient context. \ No newline at end of file diff --git a/tests/baselines/reference/asyncDeclare_es2017.js b/tests/baselines/reference/asyncDeclare_es2017.js new file mode 100644 index 0000000000000..2ff588b285158 --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es2017.js @@ -0,0 +1,4 @@ +//// [asyncDeclare_es2017.ts] +declare async function foo(): Promise; + +//// [asyncDeclare_es2017.js] diff --git a/tests/baselines/reference/asyncEnum_es2017.errors.txt b/tests/baselines/reference/asyncEnum_es2017.errors.txt new file mode 100644 index 0000000000000..8e0015d0b24a0 --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es2017.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/async/es2017/asyncEnum_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es2017/asyncEnum_es2017.ts (1 errors) ==== + async enum E { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + Value + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncEnum_es2017.js b/tests/baselines/reference/asyncEnum_es2017.js new file mode 100644 index 0000000000000..df1f846c2f9af --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es2017.js @@ -0,0 +1,10 @@ +//// [asyncEnum_es2017.ts] +async enum E { + Value +} + +//// [asyncEnum_es2017.js] +var E; +(function (E) { + E[E["Value"] = 0] = "Value"; +})(E || (E = {})); diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt new file mode 100644 index 0000000000000..d5da34322640e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,30): error TS1109: Expression expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,33): error TS1138: Parameter declaration expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,33): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,38): error TS1005: ';' expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (7 errors) ==== + async function foo(a = await => await): Promise { + ~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~ +!!! error TS1109: Expression expected. + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js new file mode 100644 index 0000000000000..0e687c1e0d589 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration10_es2017.ts] +async function foo(a = await => await): Promise { +} + +//// [asyncFunctionDeclaration10_es2017.js] +await; +Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.js new file mode 100644 index 0000000000000..0ae906ebfe13c --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration11_es2017.ts] +async function await(): Promise { +} + +//// [asyncFunctionDeclaration11_es2017.js] +async function await() { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols new file mode 100644 index 0000000000000..02c35d81d6230 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts === +async function await(): Promise { +>await : Symbol(await, Decl(asyncFunctionDeclaration11_es2017.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.types new file mode 100644 index 0000000000000..b86601bf33da9 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts === +async function await(): Promise { +>await : () => Promise +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt new file mode 100644 index 0000000000000..f951bee715c5e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,24): error TS1005: '(' expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,29): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,47): error TS1005: '=>' expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts (4 errors) ==== + var v = async function await(): Promise { } + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1005: '=' expected. + ~~~~~~~~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. + ~ +!!! error TS1005: '=>' expected. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js new file mode 100644 index 0000000000000..69f5993f5c069 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js @@ -0,0 +1,5 @@ +//// [asyncFunctionDeclaration12_es2017.ts] +var v = async function await(): Promise { } + +//// [asyncFunctionDeclaration12_es2017.js] +var v = , await = () => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.errors.txt new file mode 100644 index 0000000000000..41ea0a7cafbd0 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts(3,11): error TS2304: Cannot find name 'await'. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts (1 errors) ==== + async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.js new file mode 100644 index 0000000000000..a16236aea7fdc --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.js @@ -0,0 +1,12 @@ +//// [asyncFunctionDeclaration13_es2017.ts] +async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; +} + + +//// [asyncFunctionDeclaration13_es2017.js] +async function foo() { + // Legal to use 'await' in a type context. + var v; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.js new file mode 100644 index 0000000000000..308b8f1763cb1 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration14_es2017.ts] +async function foo(): Promise { + return; +} + +//// [asyncFunctionDeclaration14_es2017.js] +async function foo() { + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols new file mode 100644 index 0000000000000..1b5bca844c062 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es2017.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.types new file mode 100644 index 0000000000000..1e505f93a2c75 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise + + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt new file mode 100644 index 0000000000000..efc1e2440bf3a --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt @@ -0,0 +1,48 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(6,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(7,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(8,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(9,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(10,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(17,16): error TS1059: Return expression in async function does not have a valid callable 'then' member. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(23,25): error TS1058: Operand for 'await' does not have a valid callable 'then' member. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts (7 errors) ==== + declare class Thenable { then(): void; } + declare let a: any; + declare let obj: { then: string; }; + declare let thenable: Thenable; + async function fn1() { } // valid: Promise + async function fn2(): { } { } // error + ~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + async function fn3(): any { } // error + ~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + async function fn4(): number { } // error + ~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + async function fn5(): PromiseLike { } // error + ~~~~~~~~~~~~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + async function fn6(): Thenable { } // error + ~~~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + async function fn7() { return; } // valid: Promise + async function fn8() { return 1; } // valid: Promise + async function fn9() { return null; } // valid: Promise + async function fn10() { return undefined; } // valid: Promise + async function fn11() { return a; } // valid: Promise + async function fn12() { return obj; } // valid: Promise<{ then: string; }> + async function fn13() { return thenable; } // error + ~~~~ +!!! error TS1059: Return expression in async function does not have a valid callable 'then' member. + async function fn14() { await 1; } // valid: Promise + async function fn15() { await null; } // valid: Promise + async function fn16() { await undefined; } // valid: Promise + async function fn17() { await a; } // valid: Promise + async function fn18() { await obj; } // valid: Promise + async function fn19() { await thenable; } // error + ~~~~~~~~~~~~~~ +!!! error TS1058: Operand for 'await' does not have a valid callable 'then' member. + \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js new file mode 100644 index 0000000000000..5704366025efe --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js @@ -0,0 +1,64 @@ +//// [asyncFunctionDeclaration15_es2017.ts] +declare class Thenable { then(): void; } +declare let a: any; +declare let obj: { then: string; }; +declare let thenable: Thenable; +async function fn1() { } // valid: Promise +async function fn2(): { } { } // error +async function fn3(): any { } // error +async function fn4(): number { } // error +async function fn5(): PromiseLike { } // error +async function fn6(): Thenable { } // error +async function fn7() { return; } // valid: Promise +async function fn8() { return 1; } // valid: Promise +async function fn9() { return null; } // valid: Promise +async function fn10() { return undefined; } // valid: Promise +async function fn11() { return a; } // valid: Promise +async function fn12() { return obj; } // valid: Promise<{ then: string; }> +async function fn13() { return thenable; } // error +async function fn14() { await 1; } // valid: Promise +async function fn15() { await null; } // valid: Promise +async function fn16() { await undefined; } // valid: Promise +async function fn17() { await a; } // valid: Promise +async function fn18() { await obj; } // valid: Promise +async function fn19() { await thenable; } // error + + +//// [asyncFunctionDeclaration15_es2017.js] +async function fn1() { } // valid: Promise +// valid: Promise +async function fn2() { } // error +// error +async function fn3() { } // error +// error +async function fn4() { } // error +// error +async function fn5() { } // error +// error +async function fn6() { } // error +// error +async function fn7() { return; } // valid: Promise +// valid: Promise +async function fn8() { return 1; } // valid: Promise +// valid: Promise +async function fn9() { return null; } // valid: Promise +// valid: Promise +async function fn10() { return undefined; } // valid: Promise +// valid: Promise +async function fn11() { return a; } // valid: Promise +// valid: Promise +async function fn12() { return obj; } // valid: Promise<{ then: string; }> +// valid: Promise<{ then: string; }> +async function fn13() { return thenable; } // error +// error +async function fn14() { await 1; } // valid: Promise +// valid: Promise +async function fn15() { await null; } // valid: Promise +// valid: Promise +async function fn16() { await undefined; } // valid: Promise +// valid: Promise +async function fn17() { await a; } // valid: Promise +// valid: Promise +async function fn18() { await obj; } // valid: Promise +// valid: Promise +async function fn19() { await thenable; } // error diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.js new file mode 100644 index 0000000000000..549fd226b2f34 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration1_es2017.ts] +async function foo(): Promise { +} + +//// [asyncFunctionDeclaration1_es2017.js] +async function foo() { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols new file mode 100644 index 0000000000000..a712df4589636 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es2017.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.types new file mode 100644 index 0000000000000..ff97e686c43f7 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.js new file mode 100644 index 0000000000000..6de061456e823 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration2_es2017.ts] +function f(await) { +} + +//// [asyncFunctionDeclaration2_es2017.js] +function f(await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.symbols new file mode 100644 index 0000000000000..aed41f50310c2 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts === +function f(await) { +>f : Symbol(f, Decl(asyncFunctionDeclaration2_es2017.ts, 0, 0)) +>await : Symbol(await, Decl(asyncFunctionDeclaration2_es2017.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.types new file mode 100644 index 0000000000000..8413bea692ad6 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts === +function f(await) { +>f : (await: any) => void +>await : any +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt new file mode 100644 index 0000000000000..53a8507483435 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts (1 errors) ==== + function f(await = await) { + ~~~~~ +!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.js new file mode 100644 index 0000000000000..d6110265fdc1f --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration3_es2017.ts] +function f(await = await) { +} + +//// [asyncFunctionDeclaration3_es2017.js] +function f(await = await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.js new file mode 100644 index 0000000000000..6209531e5499a --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration4_es2017.ts] +function await() { +} + +//// [asyncFunctionDeclaration4_es2017.js] +function await() { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.symbols new file mode 100644 index 0000000000000..7afbd879c5964 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts === +function await() { +>await : Symbol(await, Decl(asyncFunctionDeclaration4_es2017.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.types new file mode 100644 index 0000000000000..f7c4248f7c35e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts === +function await() { +>await : () => void +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt new file mode 100644 index 0000000000000..ad8c02802069f --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,20): error TS1138: Parameter declaration expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,20): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,25): error TS1005: ';' expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,40): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts (5 errors) ==== + async function foo(await): Promise { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js new file mode 100644 index 0000000000000..13c04c5d5bc79 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration5_es2017.ts] +async function foo(await): Promise { +} + +//// [asyncFunctionDeclaration5_es2017.js] +await; +Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.errors.txt new file mode 100644 index 0000000000000..b5a5ddccdce5b --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts(1,29): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts (2 errors) ==== + async function foo(a = await): Promise { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.js new file mode 100644 index 0000000000000..6df02000846d5 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration6_es2017.ts] +async function foo(a = await): Promise { +} + +//// [asyncFunctionDeclaration6_es2017.js] +async function foo(a = await ) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.errors.txt new file mode 100644 index 0000000000000..ad9ec9a043a66 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts(3,26): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts(3,31): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts (2 errors) ==== + async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.js new file mode 100644 index 0000000000000..c9aaa80b9b072 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.js @@ -0,0 +1,13 @@ +//// [asyncFunctionDeclaration7_es2017.ts] +async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + } +} + +//// [asyncFunctionDeclaration7_es2017.js] +async function bar() { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await ) { + } +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.errors.txt new file mode 100644 index 0000000000000..b82f012d69478 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts(1,12): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts(1,20): error TS2304: Cannot find name 'foo'. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts (2 errors) ==== + var v = { [await]: foo } + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~~~ +!!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.js new file mode 100644 index 0000000000000..db7bfa4f9fb6d --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.js @@ -0,0 +1,5 @@ +//// [asyncFunctionDeclaration8_es2017.ts] +var v = { [await]: foo } + +//// [asyncFunctionDeclaration8_es2017.js] +var v = { [await]: foo }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.errors.txt new file mode 100644 index 0000000000000..27c41d8b2538c --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts(2,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts (1 errors) ==== + async function foo(): Promise { + var v = { [await]: foo } + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.js new file mode 100644 index 0000000000000..08cb8e44ba070 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration9_es2017.ts] +async function foo(): Promise { + var v = { [await]: foo } +} + +//// [asyncFunctionDeclaration9_es2017.js] +async function foo() { + var v = { [await ]: foo }; +} diff --git a/tests/baselines/reference/asyncGetter_es2017.errors.txt b/tests/baselines/reference/asyncGetter_es2017.errors.txt new file mode 100644 index 0000000000000..386e95d59771d --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es2017.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/async/es2017/asyncGetter_es2017.ts(2,3): error TS1042: 'async' modifier cannot be used here. +tests/cases/conformance/async/es2017/asyncGetter_es2017.ts(2,13): error TS2378: A 'get' accessor must return a value. + + +==== tests/cases/conformance/async/es2017/asyncGetter_es2017.ts (2 errors) ==== + class C { + async get foo() { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + ~~~ +!!! error TS2378: A 'get' accessor must return a value. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncGetter_es2017.js b/tests/baselines/reference/asyncGetter_es2017.js new file mode 100644 index 0000000000000..ad8fa347cb5ee --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es2017.js @@ -0,0 +1,11 @@ +//// [asyncGetter_es2017.ts] +class C { + async get foo() { + } +} + +//// [asyncGetter_es2017.js] +class C { + async get foo() { + } +} diff --git a/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt b/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt new file mode 100644 index 0000000000000..a0348b2e691a1 --- /dev/null +++ b/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/async/es2017/test.ts(3,25): error TS1064: The return type of an async function or method must be the global Promise type. + + +==== tests/cases/conformance/async/es2017/task.ts (0 errors) ==== + export class Task extends Promise { } + +==== tests/cases/conformance/async/es2017/test.ts (1 errors) ==== + import { Task } from "./task"; + class Test { + async example(): Task { return; } + ~~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncImportedPromise_es2017.js b/tests/baselines/reference/asyncImportedPromise_es2017.js new file mode 100644 index 0000000000000..a48c58c17077a --- /dev/null +++ b/tests/baselines/reference/asyncImportedPromise_es2017.js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts] //// + +//// [task.ts] +export class Task extends Promise { } + +//// [test.ts] +import { Task } from "./task"; +class Test { + async example(): Task { return; } +} + +//// [task.js] +"use strict"; +class Task extends Promise { +} +exports.Task = Task; +//// [test.js] +"use strict"; +class Test { + async example() { return; } +} diff --git a/tests/baselines/reference/asyncInterface_es2017.errors.txt b/tests/baselines/reference/asyncInterface_es2017.errors.txt new file mode 100644 index 0000000000000..dfbc87897972e --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es2017.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es2017/asyncInterface_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es2017/asyncInterface_es2017.ts (1 errors) ==== + async interface I { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncInterface_es2017.js b/tests/baselines/reference/asyncInterface_es2017.js new file mode 100644 index 0000000000000..4d897389538e0 --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es2017.js @@ -0,0 +1,5 @@ +//// [asyncInterface_es2017.ts] +async interface I { +} + +//// [asyncInterface_es2017.js] diff --git a/tests/baselines/reference/asyncMethodWithSuper_es2017.js b/tests/baselines/reference/asyncMethodWithSuper_es2017.js new file mode 100644 index 0000000000000..b692579316380 --- /dev/null +++ b/tests/baselines/reference/asyncMethodWithSuper_es2017.js @@ -0,0 +1,90 @@ +//// [asyncMethodWithSuper_es2017.ts] +class A { + x() { + } +} + +class B extends A { + // async method with only call/get on 'super' does not require a binding + async simple() { + // call with property access + super.x(); + + // call with element access + super["x"](); + + // property access (read) + const a = super.x; + + // element access (read) + const b = super["x"]; + } + + // async method with assignment/destructuring on 'super' requires a binding + async advanced() { + const f = () => {}; + + // call with property access + super.x(); + + // call with element access + super["x"](); + + // property access (read) + const a = super.x; + + // element access (read) + const b = super["x"]; + + // property access (assign) + super.x = f; + + // element access (assign) + super["x"] = f; + + // destructuring assign with property access + ({ f: super.x } = { f }); + + // destructuring assign with element access + ({ f: super["x"] } = { f }); + } +} + +//// [asyncMethodWithSuper_es2017.js] +class A { + x() { + } +} +class B extends A { + // async method with only call/get on 'super' does not require a binding + async simple() { + // call with property access + super.x(); + // call with element access + super["x"](); + // property access (read) + const a = super.x; + // element access (read) + const b = super["x"]; + } + // async method with assignment/destructuring on 'super' requires a binding + async advanced() { + const f = () => { }; + // call with property access + super.x(); + // call with element access + super["x"](); + // property access (read) + const a = super.x; + // element access (read) + const b = super["x"]; + // property access (assign) + super.x = f; + // element access (assign) + super["x"] = f; + // destructuring assign with property access + ({ f: super.x } = { f }); + // destructuring assign with element access + ({ f: super["x"] } = { f }); + } +} diff --git a/tests/baselines/reference/asyncMethodWithSuper_es2017.symbols b/tests/baselines/reference/asyncMethodWithSuper_es2017.symbols new file mode 100644 index 0000000000000..39ed91d7acb4f --- /dev/null +++ b/tests/baselines/reference/asyncMethodWithSuper_es2017.symbols @@ -0,0 +1,102 @@ +=== tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts === +class A { +>A : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) + + x() { +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + } +} + +class B extends A { +>B : Symbol(B, Decl(asyncMethodWithSuper_es2017.ts, 3, 1)) +>A : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) + + // async method with only call/get on 'super' does not require a binding + async simple() { +>simple : Symbol(B.simple, Decl(asyncMethodWithSuper_es2017.ts, 5, 19)) + + // call with property access + super.x(); +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // call with element access + super["x"](); +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // property access (read) + const a = super.x; +>a : Symbol(a, Decl(asyncMethodWithSuper_es2017.ts, 15, 13)) +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // element access (read) + const b = super["x"]; +>b : Symbol(b, Decl(asyncMethodWithSuper_es2017.ts, 18, 13)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + } + + // async method with assignment/destructuring on 'super' requires a binding + async advanced() { +>advanced : Symbol(B.advanced, Decl(asyncMethodWithSuper_es2017.ts, 19, 5)) + + const f = () => {}; +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 23, 13)) + + // call with property access + super.x(); +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // call with element access + super["x"](); +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // property access (read) + const a = super.x; +>a : Symbol(a, Decl(asyncMethodWithSuper_es2017.ts, 32, 13)) +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // element access (read) + const b = super["x"]; +>b : Symbol(b, Decl(asyncMethodWithSuper_es2017.ts, 35, 13)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // property access (assign) + super.x = f; +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 23, 13)) + + // element access (assign) + super["x"] = f; +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 23, 13)) + + // destructuring assign with property access + ({ f: super.x } = { f }); +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 44, 10)) +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 44, 27)) + + // destructuring assign with element access + ({ f: super["x"] } = { f }); +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 47, 10)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 47, 30)) + } +} diff --git a/tests/baselines/reference/asyncMethodWithSuper_es2017.types b/tests/baselines/reference/asyncMethodWithSuper_es2017.types new file mode 100644 index 0000000000000..b2678e8b8379d --- /dev/null +++ b/tests/baselines/reference/asyncMethodWithSuper_es2017.types @@ -0,0 +1,123 @@ +=== tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts === +class A { +>A : A + + x() { +>x : () => void + } +} + +class B extends A { +>B : B +>A : A + + // async method with only call/get on 'super' does not require a binding + async simple() { +>simple : () => Promise + + // call with property access + super.x(); +>super.x() : void +>super.x : () => void +>super : A +>x : () => void + + // call with element access + super["x"](); +>super["x"]() : void +>super["x"] : () => void +>super : A +>"x" : "x" + + // property access (read) + const a = super.x; +>a : () => void +>super.x : () => void +>super : A +>x : () => void + + // element access (read) + const b = super["x"]; +>b : () => void +>super["x"] : () => void +>super : A +>"x" : "x" + } + + // async method with assignment/destructuring on 'super' requires a binding + async advanced() { +>advanced : () => Promise + + const f = () => {}; +>f : () => void +>() => {} : () => void + + // call with property access + super.x(); +>super.x() : void +>super.x : () => void +>super : A +>x : () => void + + // call with element access + super["x"](); +>super["x"]() : void +>super["x"] : () => void +>super : A +>"x" : "x" + + // property access (read) + const a = super.x; +>a : () => void +>super.x : () => void +>super : A +>x : () => void + + // element access (read) + const b = super["x"]; +>b : () => void +>super["x"] : () => void +>super : A +>"x" : "x" + + // property access (assign) + super.x = f; +>super.x = f : () => void +>super.x : () => void +>super : A +>x : () => void +>f : () => void + + // element access (assign) + super["x"] = f; +>super["x"] = f : () => void +>super["x"] : () => void +>super : A +>"x" : "x" +>f : () => void + + // destructuring assign with property access + ({ f: super.x } = { f }); +>({ f: super.x } = { f }) : { f: () => void; } +>{ f: super.x } = { f } : { f: () => void; } +>{ f: super.x } : { f: () => void; } +>f : () => void +>super.x : () => void +>super : A +>x : () => void +>{ f } : { f: () => void; } +>f : () => void + + // destructuring assign with element access + ({ f: super["x"] } = { f }); +>({ f: super["x"] } = { f }) : { f: () => void; } +>{ f: super["x"] } = { f } : { f: () => void; } +>{ f: super["x"] } : { f: () => void; } +>f : () => void +>super["x"] : () => void +>super : A +>"x" : "x" +>{ f } : { f: () => void; } +>f : () => void + } +} diff --git a/tests/baselines/reference/asyncModule_es2017.errors.txt b/tests/baselines/reference/asyncModule_es2017.errors.txt new file mode 100644 index 0000000000000..8b6a4c3dc66af --- /dev/null +++ b/tests/baselines/reference/asyncModule_es2017.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es2017/asyncModule_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es2017/asyncModule_es2017.ts (1 errors) ==== + async module M { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncModule_es2017.js b/tests/baselines/reference/asyncModule_es2017.js new file mode 100644 index 0000000000000..fe3e17d5e7410 --- /dev/null +++ b/tests/baselines/reference/asyncModule_es2017.js @@ -0,0 +1,5 @@ +//// [asyncModule_es2017.ts] +async module M { +} + +//// [asyncModule_es2017.js] diff --git a/tests/baselines/reference/asyncMultiFile_es2017.js b/tests/baselines/reference/asyncMultiFile_es2017.js new file mode 100644 index 0000000000000..804a58e4b4c9b --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile_es2017.js @@ -0,0 +1,11 @@ +//// [tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts] //// + +//// [a.ts] +async function f() {} +//// [b.ts] +function g() { } + +//// [a.js] +async function f() { } +//// [b.js] +function g() { } diff --git a/tests/baselines/reference/asyncMultiFile_es2017.symbols b/tests/baselines/reference/asyncMultiFile_es2017.symbols new file mode 100644 index 0000000000000..9d8ff6dbe85c5 --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile_es2017.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es2017/a.ts === +async function f() {} +>f : Symbol(f, Decl(a.ts, 0, 0)) + +=== tests/cases/conformance/async/es2017/b.ts === +function g() { } +>g : Symbol(g, Decl(b.ts, 0, 0)) + diff --git a/tests/baselines/reference/asyncMultiFile_es2017.types b/tests/baselines/reference/asyncMultiFile_es2017.types new file mode 100644 index 0000000000000..e1f8da34c94db --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile_es2017.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es2017/a.ts === +async function f() {} +>f : () => Promise + +=== tests/cases/conformance/async/es2017/b.ts === +function g() { } +>g : () => void + diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt b/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt new file mode 100644 index 0000000000000..b9027c365396c --- /dev/null +++ b/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts(6,21): error TS1064: The return type of an async function or method must be the global Promise type. + + +==== tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts (1 errors) ==== + namespace X { + export class MyPromise extends Promise { + } + } + + async function f(): X.MyPromise { + ~~~~~~~~~~~~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es2017.js b/tests/baselines/reference/asyncQualifiedReturnType_es2017.js new file mode 100644 index 0000000000000..164a4fef61057 --- /dev/null +++ b/tests/baselines/reference/asyncQualifiedReturnType_es2017.js @@ -0,0 +1,18 @@ +//// [asyncQualifiedReturnType_es2017.ts] +namespace X { + export class MyPromise extends Promise { + } +} + +async function f(): X.MyPromise { +} + +//// [asyncQualifiedReturnType_es2017.js] +var X; +(function (X) { + class MyPromise extends Promise { + } + X.MyPromise = MyPromise; +})(X || (X = {})); +async function f() { +} diff --git a/tests/baselines/reference/asyncSetter_es2017.errors.txt b/tests/baselines/reference/asyncSetter_es2017.errors.txt new file mode 100644 index 0000000000000..0acd8538f2017 --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es2017.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es2017/asyncSetter_es2017.ts(2,3): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es2017/asyncSetter_es2017.ts (1 errors) ==== + class C { + async set foo(value) { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncSetter_es2017.js b/tests/baselines/reference/asyncSetter_es2017.js new file mode 100644 index 0000000000000..8260c5232a243 --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es2017.js @@ -0,0 +1,11 @@ +//// [asyncSetter_es2017.ts] +class C { + async set foo(value) { + } +} + +//// [asyncSetter_es2017.js] +class C { + async set foo(value) { + } +} diff --git a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.js b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.js new file mode 100644 index 0000000000000..c97fda43011dd --- /dev/null +++ b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.js @@ -0,0 +1,9 @@ +//// [asyncUnParenthesizedArrowFunction_es2017.ts] + +declare function someOtherFunction(i: any): Promise; +const x = async i => await someOtherFunction(i) +const x1 = async (i) => await someOtherFunction(i); + +//// [asyncUnParenthesizedArrowFunction_es2017.js] +const x = async (i) => await someOtherFunction(i); +const x1 = async (i) => await someOtherFunction(i); diff --git a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols new file mode 100644 index 0000000000000..b5f83de6021ae --- /dev/null +++ b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts === + +declare function someOtherFunction(i: any): Promise; +>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 0, 0)) +>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 1, 35)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +const x = async i => await someOtherFunction(i) +>x : Symbol(x, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 2, 5)) +>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 2, 15)) +>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 0, 0)) +>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 2, 15)) + +const x1 = async (i) => await someOtherFunction(i); +>x1 : Symbol(x1, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 3, 5)) +>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 3, 18)) +>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 0, 0)) +>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 3, 18)) + diff --git a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.types b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.types new file mode 100644 index 0000000000000..ff573e29ed367 --- /dev/null +++ b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts === + +declare function someOtherFunction(i: any): Promise; +>someOtherFunction : (i: any) => Promise +>i : any +>Promise : Promise + +const x = async i => await someOtherFunction(i) +>x : (i: any) => Promise +>async i => await someOtherFunction(i) : (i: any) => Promise +>i : any +>await someOtherFunction(i) : void +>someOtherFunction(i) : Promise +>someOtherFunction : (i: any) => Promise +>i : any + +const x1 = async (i) => await someOtherFunction(i); +>x1 : (i: any) => Promise +>async (i) => await someOtherFunction(i) : (i: any) => Promise +>i : any +>await someOtherFunction(i) : void +>someOtherFunction(i) : Promise +>someOtherFunction : (i: any) => Promise +>i : any + diff --git a/tests/baselines/reference/asyncUseStrict_es2017.js b/tests/baselines/reference/asyncUseStrict_es2017.js new file mode 100644 index 0000000000000..1b9d1dc7f205f --- /dev/null +++ b/tests/baselines/reference/asyncUseStrict_es2017.js @@ -0,0 +1,13 @@ +//// [asyncUseStrict_es2017.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "use strict"; + var b = await p || a; +} + +//// [asyncUseStrict_es2017.js] +async function func() { + "use strict"; + var b = await p || a; +} diff --git a/tests/baselines/reference/asyncUseStrict_es2017.symbols b/tests/baselines/reference/asyncUseStrict_es2017.symbols new file mode 100644 index 0000000000000..23fd654ca29d1 --- /dev/null +++ b/tests/baselines/reference/asyncUseStrict_es2017.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(asyncUseStrict_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(asyncUseStrict_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +async function func(): Promise { +>func : Symbol(func, Decl(asyncUseStrict_es2017.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + "use strict"; + var b = await p || a; +>b : Symbol(b, Decl(asyncUseStrict_es2017.ts, 4, 7)) +>p : Symbol(p, Decl(asyncUseStrict_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(asyncUseStrict_es2017.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncUseStrict_es2017.types b/tests/baselines/reference/asyncUseStrict_es2017.types new file mode 100644 index 0000000000000..267eda835251b --- /dev/null +++ b/tests/baselines/reference/asyncUseStrict_es2017.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "use strict"; +>"use strict" : "use strict" + + var b = await p || a; +>b : boolean +>await p || a : boolean +>await p : boolean +>p : Promise +>a : boolean +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es2017.js b/tests/baselines/reference/awaitBinaryExpression1_es2017.js new file mode 100644 index 0000000000000..9016a2b58269c --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es2017.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression1_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p || a; + after(); +} + +//// [awaitBinaryExpression1_es2017.js] +async function func() { + before(); + var b = await p || a; + after(); +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression1_es2017.symbols new file mode 100644 index 0000000000000..827769b3db5c9 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es2017.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression1_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression1_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitBinaryExpression1_es2017.ts, 1, 32)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitBinaryExpression1_es2017.ts, 2, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression1_es2017.ts, 3, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitBinaryExpression1_es2017.ts, 1, 32)) + + var b = await p || a; +>b : Symbol(b, Decl(awaitBinaryExpression1_es2017.ts, 6, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression1_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitBinaryExpression1_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitBinaryExpression1_es2017.ts, 2, 32)) +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es2017.types b/tests/baselines/reference/awaitBinaryExpression1_es2017.types new file mode 100644 index 0000000000000..c86631804c598 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es2017.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = await p || a; +>b : boolean +>await p || a : boolean +>await p : boolean +>p : Promise +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es2017.js b/tests/baselines/reference/awaitBinaryExpression2_es2017.js new file mode 100644 index 0000000000000..1d5ad324fdab7 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es2017.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression2_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p && a; + after(); +} + +//// [awaitBinaryExpression2_es2017.js] +async function func() { + before(); + var b = await p && a; + after(); +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression2_es2017.symbols new file mode 100644 index 0000000000000..549eb49cf9297 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es2017.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression2_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression2_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitBinaryExpression2_es2017.ts, 1, 32)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitBinaryExpression2_es2017.ts, 2, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression2_es2017.ts, 3, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitBinaryExpression2_es2017.ts, 1, 32)) + + var b = await p && a; +>b : Symbol(b, Decl(awaitBinaryExpression2_es2017.ts, 6, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression2_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitBinaryExpression2_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitBinaryExpression2_es2017.ts, 2, 32)) +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es2017.types b/tests/baselines/reference/awaitBinaryExpression2_es2017.types new file mode 100644 index 0000000000000..f803b1ac8402b --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es2017.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = await p && a; +>b : boolean +>await p && a : boolean +>await p : boolean +>p : Promise +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es2017.js b/tests/baselines/reference/awaitBinaryExpression3_es2017.js new file mode 100644 index 0000000000000..c752ec3be4a56 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es2017.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression3_es2017.ts] +declare var a: number; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p + a; + after(); +} + +//// [awaitBinaryExpression3_es2017.js] +async function func() { + before(); + var b = await p + a; + after(); +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression3_es2017.symbols new file mode 100644 index 0000000000000..29c8fb7f398ef --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es2017.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts === +declare var a: number; +>a : Symbol(a, Decl(awaitBinaryExpression3_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression3_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitBinaryExpression3_es2017.ts, 1, 31)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitBinaryExpression3_es2017.ts, 2, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression3_es2017.ts, 3, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitBinaryExpression3_es2017.ts, 1, 31)) + + var b = await p + a; +>b : Symbol(b, Decl(awaitBinaryExpression3_es2017.ts, 6, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression3_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitBinaryExpression3_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitBinaryExpression3_es2017.ts, 2, 32)) +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es2017.types b/tests/baselines/reference/awaitBinaryExpression3_es2017.types new file mode 100644 index 0000000000000..623d06952374f --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es2017.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts === +declare var a: number; +>a : number + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = await p + a; +>b : number +>await p + a : number +>await p : number +>p : Promise +>a : number + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es2017.js b/tests/baselines/reference/awaitBinaryExpression4_es2017.js new file mode 100644 index 0000000000000..3fc296ea14250 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es2017.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression4_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await p, a); + after(); +} + +//// [awaitBinaryExpression4_es2017.js] +async function func() { + before(); + var b = (await p, a); + after(); +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression4_es2017.symbols new file mode 100644 index 0000000000000..0db5a20e0c11e --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es2017.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression4_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression4_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitBinaryExpression4_es2017.ts, 1, 32)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitBinaryExpression4_es2017.ts, 2, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression4_es2017.ts, 3, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitBinaryExpression4_es2017.ts, 1, 32)) + + var b = (await p, a); +>b : Symbol(b, Decl(awaitBinaryExpression4_es2017.ts, 6, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression4_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitBinaryExpression4_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitBinaryExpression4_es2017.ts, 2, 32)) +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es2017.types b/tests/baselines/reference/awaitBinaryExpression4_es2017.types new file mode 100644 index 0000000000000..714b6b1ea3a59 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es2017.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = (await p, a); +>b : boolean +>(await p, a) : boolean +>await p, a : boolean +>await p : boolean +>p : Promise +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es2017.js b/tests/baselines/reference/awaitBinaryExpression5_es2017.js new file mode 100644 index 0000000000000..b6c5e12ce761f --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es2017.js @@ -0,0 +1,19 @@ +//// [awaitBinaryExpression5_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var o: { a: boolean; }; + o.a = await p; + after(); +} + +//// [awaitBinaryExpression5_es2017.js] +async function func() { + before(); + var o; + o.a = await p; + after(); +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression5_es2017.symbols new file mode 100644 index 0000000000000..e2d30c658f711 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es2017.symbols @@ -0,0 +1,34 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression5_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression5_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitBinaryExpression5_es2017.ts, 1, 32)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitBinaryExpression5_es2017.ts, 2, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression5_es2017.ts, 3, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitBinaryExpression5_es2017.ts, 1, 32)) + + var o: { a: boolean; }; +>o : Symbol(o, Decl(awaitBinaryExpression5_es2017.ts, 6, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression5_es2017.ts, 6, 12)) + + o.a = await p; +>o.a : Symbol(a, Decl(awaitBinaryExpression5_es2017.ts, 6, 12)) +>o : Symbol(o, Decl(awaitBinaryExpression5_es2017.ts, 6, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression5_es2017.ts, 6, 12)) +>p : Symbol(p, Decl(awaitBinaryExpression5_es2017.ts, 1, 11)) + + after(); +>after : Symbol(after, Decl(awaitBinaryExpression5_es2017.ts, 2, 32)) +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es2017.types b/tests/baselines/reference/awaitBinaryExpression5_es2017.types new file mode 100644 index 0000000000000..763f9e5086289 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es2017.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var o: { a: boolean; }; +>o : { a: boolean; } +>a : boolean + + o.a = await p; +>o.a = await p : boolean +>o.a : boolean +>o : { a: boolean; } +>a : boolean +>await p : boolean +>p : Promise + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression1_es2017.js b/tests/baselines/reference/awaitCallExpression1_es2017.js new file mode 100644 index 0000000000000..89fe7dfd91269 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression1_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(a, a, a); + after(); +} + +//// [awaitCallExpression1_es2017.js] +async function func() { + before(); + var b = fn(a, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression1_es2017.symbols b/tests/baselines/reference/awaitCallExpression1_es2017.symbols new file mode 100644 index 0000000000000..68c28d153507e --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es2017.symbols @@ -0,0 +1,59 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression1_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression1_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression1_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression1_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression1_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression1_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression1_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression1_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression1_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression1_es2017.ts, 5, 84)) + + var b = fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression1_es2017.ts, 10, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es2017.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression1_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression1_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression1_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression1_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression1_es2017.types b/tests/baselines/reference/awaitCallExpression1_es2017.types new file mode 100644 index 0000000000000..c5cea09187866 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es2017.types @@ -0,0 +1,62 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = fn(a, a, a); +>b : void +>fn(a, a, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression2_es2017.js b/tests/baselines/reference/awaitCallExpression2_es2017.js new file mode 100644 index 0000000000000..24b3012f85d33 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression2_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(await p, a, a); + after(); +} + +//// [awaitCallExpression2_es2017.js] +async function func() { + before(); + var b = fn(await p, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression2_es2017.symbols b/tests/baselines/reference/awaitCallExpression2_es2017.symbols new file mode 100644 index 0000000000000..4528ae4c0743d --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es2017.symbols @@ -0,0 +1,59 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression2_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression2_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression2_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression2_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression2_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression2_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression2_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression2_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression2_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression2_es2017.ts, 5, 84)) + + var b = fn(await p, a, a); +>b : Symbol(b, Decl(awaitCallExpression2_es2017.ts, 10, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es2017.ts, 1, 32)) +>p : Symbol(p, Decl(awaitCallExpression2_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitCallExpression2_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression2_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression2_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression2_es2017.types b/tests/baselines/reference/awaitCallExpression2_es2017.types new file mode 100644 index 0000000000000..a15609a40782a --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es2017.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = fn(await p, a, a); +>b : void +>fn(await p, a, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>await p : boolean +>p : Promise +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression3_es2017.js b/tests/baselines/reference/awaitCallExpression3_es2017.js new file mode 100644 index 0000000000000..6b432851b000c --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression3_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(a, await p, a); + after(); +} + +//// [awaitCallExpression3_es2017.js] +async function func() { + before(); + var b = fn(a, await p, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression3_es2017.symbols b/tests/baselines/reference/awaitCallExpression3_es2017.symbols new file mode 100644 index 0000000000000..a1120103fb070 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es2017.symbols @@ -0,0 +1,59 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression3_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression3_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression3_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression3_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression3_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression3_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression3_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression3_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression3_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression3_es2017.ts, 5, 84)) + + var b = fn(a, await p, a); +>b : Symbol(b, Decl(awaitCallExpression3_es2017.ts, 10, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es2017.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression3_es2017.ts, 0, 11)) +>p : Symbol(p, Decl(awaitCallExpression3_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitCallExpression3_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression3_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression3_es2017.types b/tests/baselines/reference/awaitCallExpression3_es2017.types new file mode 100644 index 0000000000000..a491836fa0610 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es2017.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = fn(a, await p, a); +>b : void +>fn(a, await p, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>await p : boolean +>p : Promise +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression4_es2017.js b/tests/baselines/reference/awaitCallExpression4_es2017.js new file mode 100644 index 0000000000000..9243ac58f82ab --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression4_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await pfn)(a, a, a); + after(); +} + +//// [awaitCallExpression4_es2017.js] +async function func() { + before(); + var b = (await pfn)(a, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression4_es2017.symbols b/tests/baselines/reference/awaitCallExpression4_es2017.symbols new file mode 100644 index 0000000000000..fb607d9841f4f --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es2017.symbols @@ -0,0 +1,59 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression4_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression4_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression4_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression4_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression4_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression4_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression4_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression4_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression4_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression4_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression4_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression4_es2017.ts, 5, 84)) + + var b = (await pfn)(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression4_es2017.ts, 10, 7)) +>pfn : Symbol(pfn, Decl(awaitCallExpression4_es2017.ts, 4, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression4_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression4_es2017.types b/tests/baselines/reference/awaitCallExpression4_es2017.types new file mode 100644 index 0000000000000..3f1b478e66925 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es2017.types @@ -0,0 +1,64 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = (await pfn)(a, a, a); +>b : void +>(await pfn)(a, a, a) : void +>(await pfn) : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>await pfn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>a : boolean +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression5_es2017.js b/tests/baselines/reference/awaitCallExpression5_es2017.js new file mode 100644 index 0000000000000..d08823ac5a354 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression5_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(a, a, a); + after(); +} + +//// [awaitCallExpression5_es2017.js] +async function func() { + before(); + var b = o.fn(a, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression5_es2017.symbols b/tests/baselines/reference/awaitCallExpression5_es2017.symbols new file mode 100644 index 0000000000000..3854353314aef --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es2017.symbols @@ -0,0 +1,61 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression5_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression5_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression5_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression5_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression5_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression5_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression5_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression5_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression5_es2017.ts, 5, 84)) + + var b = o.fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression5_es2017.ts, 10, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression5_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression5_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression5_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression5_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression5_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression5_es2017.types b/tests/baselines/reference/awaitCallExpression5_es2017.types new file mode 100644 index 0000000000000..f31320e44f7d4 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es2017.types @@ -0,0 +1,64 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = o.fn(a, a, a); +>b : void +>o.fn(a, a, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression6_es2017.js b/tests/baselines/reference/awaitCallExpression6_es2017.js new file mode 100644 index 0000000000000..77a47ba806589 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression6_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(await p, a, a); + after(); +} + +//// [awaitCallExpression6_es2017.js] +async function func() { + before(); + var b = o.fn(await p, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression6_es2017.symbols b/tests/baselines/reference/awaitCallExpression6_es2017.symbols new file mode 100644 index 0000000000000..6a651510328a4 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es2017.symbols @@ -0,0 +1,61 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression6_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression6_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression6_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression6_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression6_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression6_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression6_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression6_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression6_es2017.ts, 5, 84)) + + var b = o.fn(await p, a, a); +>b : Symbol(b, Decl(awaitCallExpression6_es2017.ts, 10, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression6_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 3, 16)) +>p : Symbol(p, Decl(awaitCallExpression6_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitCallExpression6_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression6_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression6_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression6_es2017.types b/tests/baselines/reference/awaitCallExpression6_es2017.types new file mode 100644 index 0000000000000..ccce4cad366eb --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es2017.types @@ -0,0 +1,65 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = o.fn(await p, a, a); +>b : void +>o.fn(await p, a, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>await p : boolean +>p : Promise +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression7_es2017.js b/tests/baselines/reference/awaitCallExpression7_es2017.js new file mode 100644 index 0000000000000..b3391ced6b605 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression7_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(a, await p, a); + after(); +} + +//// [awaitCallExpression7_es2017.js] +async function func() { + before(); + var b = o.fn(a, await p, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression7_es2017.symbols b/tests/baselines/reference/awaitCallExpression7_es2017.symbols new file mode 100644 index 0000000000000..e95078c68500a --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es2017.symbols @@ -0,0 +1,61 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression7_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression7_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression7_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression7_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression7_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression7_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression7_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression7_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression7_es2017.ts, 5, 84)) + + var b = o.fn(a, await p, a); +>b : Symbol(b, Decl(awaitCallExpression7_es2017.ts, 10, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression7_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression7_es2017.ts, 0, 11)) +>p : Symbol(p, Decl(awaitCallExpression7_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitCallExpression7_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression7_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression7_es2017.types b/tests/baselines/reference/awaitCallExpression7_es2017.types new file mode 100644 index 0000000000000..aefe791685235 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es2017.types @@ -0,0 +1,65 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = o.fn(a, await p, a); +>b : void +>o.fn(a, await p, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>await p : boolean +>p : Promise +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression8_es2017.js b/tests/baselines/reference/awaitCallExpression8_es2017.js new file mode 100644 index 0000000000000..7e04402e90aef --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression8_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await po).fn(a, a, a); + after(); +} + +//// [awaitCallExpression8_es2017.js] +async function func() { + before(); + var b = (await po).fn(a, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression8_es2017.symbols b/tests/baselines/reference/awaitCallExpression8_es2017.symbols new file mode 100644 index 0000000000000..e3fd465c120f0 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es2017.symbols @@ -0,0 +1,61 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression8_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression8_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression8_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression8_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression8_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression8_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression8_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression8_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression8_es2017.ts, 5, 84)) + + var b = (await po).fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression8_es2017.ts, 10, 7)) +>(await po).fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 5, 25)) +>po : Symbol(po, Decl(awaitCallExpression8_es2017.ts, 5, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 5, 25)) +>a : Symbol(a, Decl(awaitCallExpression8_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression8_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression8_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression8_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression8_es2017.types b/tests/baselines/reference/awaitCallExpression8_es2017.types new file mode 100644 index 0000000000000..a9a115d39f28b --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es2017.types @@ -0,0 +1,66 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = (await po).fn(a, a, a); +>b : void +>(await po).fn(a, a, a) : void +>(await po).fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>(await po) : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>await po : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitClassExpression_es2017.js b/tests/baselines/reference/awaitClassExpression_es2017.js new file mode 100644 index 0000000000000..d84f01f61cfa4 --- /dev/null +++ b/tests/baselines/reference/awaitClassExpression_es2017.js @@ -0,0 +1,14 @@ +//// [awaitClassExpression_es2017.ts] +declare class C { } +declare var p: Promise; + +async function func(): Promise { + class D extends (await p) { + } +} + +//// [awaitClassExpression_es2017.js] +async function func() { + class D extends (await p) { + } +} diff --git a/tests/baselines/reference/awaitClassExpression_es2017.symbols b/tests/baselines/reference/awaitClassExpression_es2017.symbols new file mode 100644 index 0000000000000..bebffa2bbada4 --- /dev/null +++ b/tests/baselines/reference/awaitClassExpression_es2017.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts === +declare class C { } +>C : Symbol(C, Decl(awaitClassExpression_es2017.ts, 0, 0)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitClassExpression_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>C : Symbol(C, Decl(awaitClassExpression_es2017.ts, 0, 0)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitClassExpression_es2017.ts, 1, 33)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + class D extends (await p) { +>D : Symbol(D, Decl(awaitClassExpression_es2017.ts, 3, 38)) +>p : Symbol(p, Decl(awaitClassExpression_es2017.ts, 1, 11)) + } +} diff --git a/tests/baselines/reference/awaitClassExpression_es2017.types b/tests/baselines/reference/awaitClassExpression_es2017.types new file mode 100644 index 0000000000000..39d17b1cc503c --- /dev/null +++ b/tests/baselines/reference/awaitClassExpression_es2017.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts === +declare class C { } +>C : C + +declare var p: Promise; +>p : Promise +>Promise : Promise +>C : typeof C + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + class D extends (await p) { +>D : D +>(await p) : C +>await p : typeof C +>p : Promise + } +} diff --git a/tests/baselines/reference/awaitUnion_es2017.js b/tests/baselines/reference/awaitUnion_es2017.js new file mode 100644 index 0000000000000..12f8b95a65269 --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es2017.js @@ -0,0 +1,22 @@ +//// [awaitUnion_es2017.ts] +declare let a: number | string; +declare let b: PromiseLike | PromiseLike; +declare let c: PromiseLike; +declare let d: number | PromiseLike; +declare let e: number | PromiseLike; +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} + +//// [awaitUnion_es2017.js] +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} diff --git a/tests/baselines/reference/awaitUnion_es2017.symbols b/tests/baselines/reference/awaitUnion_es2017.symbols new file mode 100644 index 0000000000000..e70abce4f0b6f --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es2017.symbols @@ -0,0 +1,44 @@ +=== tests/cases/conformance/async/es2017/awaitUnion_es2017.ts === +declare let a: number | string; +>a : Symbol(a, Decl(awaitUnion_es2017.ts, 0, 11)) + +declare let b: PromiseLike | PromiseLike; +>b : Symbol(b, Decl(awaitUnion_es2017.ts, 1, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) + +declare let c: PromiseLike; +>c : Symbol(c, Decl(awaitUnion_es2017.ts, 2, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) + +declare let d: number | PromiseLike; +>d : Symbol(d, Decl(awaitUnion_es2017.ts, 3, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) + +declare let e: number | PromiseLike; +>e : Symbol(e, Decl(awaitUnion_es2017.ts, 4, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) + +async function f() { +>f : Symbol(f, Decl(awaitUnion_es2017.ts, 4, 53)) + + let await_a = await a; +>await_a : Symbol(await_a, Decl(awaitUnion_es2017.ts, 6, 4)) +>a : Symbol(a, Decl(awaitUnion_es2017.ts, 0, 11)) + + let await_b = await b; +>await_b : Symbol(await_b, Decl(awaitUnion_es2017.ts, 7, 4)) +>b : Symbol(b, Decl(awaitUnion_es2017.ts, 1, 11)) + + let await_c = await c; +>await_c : Symbol(await_c, Decl(awaitUnion_es2017.ts, 8, 4)) +>c : Symbol(c, Decl(awaitUnion_es2017.ts, 2, 11)) + + let await_d = await d; +>await_d : Symbol(await_d, Decl(awaitUnion_es2017.ts, 9, 4)) +>d : Symbol(d, Decl(awaitUnion_es2017.ts, 3, 11)) + + let await_e = await e; +>await_e : Symbol(await_e, Decl(awaitUnion_es2017.ts, 10, 4)) +>e : Symbol(e, Decl(awaitUnion_es2017.ts, 4, 11)) +} diff --git a/tests/baselines/reference/awaitUnion_es2017.types b/tests/baselines/reference/awaitUnion_es2017.types new file mode 100644 index 0000000000000..58f8a4ec4b4aa --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es2017.types @@ -0,0 +1,49 @@ +=== tests/cases/conformance/async/es2017/awaitUnion_es2017.ts === +declare let a: number | string; +>a : string | number + +declare let b: PromiseLike | PromiseLike; +>b : PromiseLike | PromiseLike +>PromiseLike : PromiseLike +>PromiseLike : PromiseLike + +declare let c: PromiseLike; +>c : PromiseLike +>PromiseLike : PromiseLike + +declare let d: number | PromiseLike; +>d : number | PromiseLike +>PromiseLike : PromiseLike + +declare let e: number | PromiseLike; +>e : number | PromiseLike +>PromiseLike : PromiseLike + +async function f() { +>f : () => Promise + + let await_a = await a; +>await_a : string | number +>await a : string | number +>a : string | number + + let await_b = await b; +>await_b : string | number +>await b : string | number +>b : PromiseLike | PromiseLike + + let await_c = await c; +>await_c : string | number +>await c : string | number +>c : PromiseLike + + let await_d = await d; +>await_d : string | number +>await d : string | number +>d : number | PromiseLike + + let await_e = await e; +>await_e : string | number +>await e : string | number +>e : number | PromiseLike +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017.js b/tests/baselines/reference/await_unaryExpression_es2017.js new file mode 100644 index 0000000000000..83fce6588e646 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017.js @@ -0,0 +1,31 @@ +//// [await_unaryExpression_es2017.ts] + +async function bar() { + !await 42; // OK +} + +async function bar1() { + +await 42; // OK +} + +async function bar3() { + -await 42; // OK +} + +async function bar4() { + ~await 42; // OK +} + +//// [await_unaryExpression_es2017.js] +async function bar() { + !await 42; // OK +} +async function bar1() { + +await 42; // OK +} +async function bar3() { + -await 42; // OK +} +async function bar4() { + ~await 42; // OK +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017.symbols b/tests/baselines/reference/await_unaryExpression_es2017.symbols new file mode 100644 index 0000000000000..1aa31031177c0 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts === + +async function bar() { +>bar : Symbol(bar, Decl(await_unaryExpression_es2017.ts, 0, 0)) + + !await 42; // OK +} + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es2017.ts, 3, 1)) + + +await 42; // OK +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es2017.ts, 7, 1)) + + -await 42; // OK +} + +async function bar4() { +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es2017.ts, 11, 1)) + + ~await 42; // OK +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017.types b/tests/baselines/reference/await_unaryExpression_es2017.types new file mode 100644 index 0000000000000..4f4254df318a9 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts === + +async function bar() { +>bar : () => Promise + + !await 42; // OK +>!await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar1() { +>bar1 : () => Promise + + +await 42; // OK +>+await 42 : number +>await 42 : 42 +>42 : 42 +} + +async function bar3() { +>bar3 : () => Promise + + -await 42; // OK +>-await 42 : number +>await 42 : 42 +>42 : 42 +} + +async function bar4() { +>bar4 : () => Promise + + ~await 42; // OK +>~await 42 : number +>await 42 : 42 +>42 : 42 +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_1.js b/tests/baselines/reference/await_unaryExpression_es2017_1.js new file mode 100644 index 0000000000000..f863fb19a7e1f --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_1.js @@ -0,0 +1,38 @@ +//// [await_unaryExpression_es2017_1.ts] + +async function bar() { + !await 42; // OK +} + +async function bar1() { + delete await 42; // OK +} + +async function bar2() { + delete await 42; // OK +} + +async function bar3() { + void await 42; +} + +async function bar4() { + +await 42; +} + +//// [await_unaryExpression_es2017_1.js] +async function bar() { + !await 42; // OK +} +async function bar1() { + delete await 42; // OK +} +async function bar2() { + delete await 42; // OK +} +async function bar3() { + void await 42; +} +async function bar4() { + +await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_1.symbols b/tests/baselines/reference/await_unaryExpression_es2017_1.symbols new file mode 100644 index 0000000000000..81bb31a7efd57 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_1.symbols @@ -0,0 +1,31 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts === + +async function bar() { +>bar : Symbol(bar, Decl(await_unaryExpression_es2017_1.ts, 0, 0)) + + !await 42; // OK +} + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es2017_1.ts, 3, 1)) + + delete await 42; // OK +} + +async function bar2() { +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es2017_1.ts, 7, 1)) + + delete await 42; // OK +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es2017_1.ts, 11, 1)) + + void await 42; +} + +async function bar4() { +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es2017_1.ts, 15, 1)) + + +await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_1.types b/tests/baselines/reference/await_unaryExpression_es2017_1.types new file mode 100644 index 0000000000000..7afa4fe900190 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_1.types @@ -0,0 +1,46 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts === + +async function bar() { +>bar : () => Promise + + !await 42; // OK +>!await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar1() { +>bar1 : () => Promise + + delete await 42; // OK +>delete await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar2() { +>bar2 : () => Promise + + delete await 42; // OK +>delete await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar3() { +>bar3 : () => Promise + + void await 42; +>void await 42 : undefined +>await 42 : 42 +>42 : 42 +} + +async function bar4() { +>bar4 : () => Promise + + +await 42; +>+await 42 : number +>await 42 : 42 +>42 : 42 +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_2.js b/tests/baselines/reference/await_unaryExpression_es2017_2.js new file mode 100644 index 0000000000000..b982b20245c0e --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_2.js @@ -0,0 +1,24 @@ +//// [await_unaryExpression_es2017_2.ts] + +async function bar1() { + delete await 42; +} + +async function bar2() { + delete await 42; +} + +async function bar3() { + void await 42; +} + +//// [await_unaryExpression_es2017_2.js] +async function bar1() { + delete await 42; +} +async function bar2() { + delete await 42; +} +async function bar3() { + void await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_2.symbols b/tests/baselines/reference/await_unaryExpression_es2017_2.symbols new file mode 100644 index 0000000000000..d4b8a7493d9c1 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_2.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts === + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es2017_2.ts, 0, 0)) + + delete await 42; +} + +async function bar2() { +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es2017_2.ts, 3, 1)) + + delete await 42; +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es2017_2.ts, 7, 1)) + + void await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_2.types b/tests/baselines/reference/await_unaryExpression_es2017_2.types new file mode 100644 index 0000000000000..acaa76d2d6795 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_2.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts === + +async function bar1() { +>bar1 : () => Promise + + delete await 42; +>delete await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar2() { +>bar2 : () => Promise + + delete await 42; +>delete await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar3() { +>bar3 : () => Promise + + void await 42; +>void await 42 : undefined +>await 42 : 42 +>42 : 42 +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_3.errors.txt b/tests/baselines/reference/await_unaryExpression_es2017_3.errors.txt new file mode 100644 index 0000000000000..5d11c4bbb20eb --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_3.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts(3,7): error TS1109: Expression expected. +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts(7,7): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts (2 errors) ==== + + async function bar1() { + ++await 42; // Error + ~~~~~ +!!! error TS1109: Expression expected. + } + + async function bar2() { + --await 42; // Error + ~~~~~ +!!! error TS1109: Expression expected. + } + + async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis + } + + async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis + } \ No newline at end of file diff --git a/tests/baselines/reference/await_unaryExpression_es2017_3.js b/tests/baselines/reference/await_unaryExpression_es2017_3.js new file mode 100644 index 0000000000000..5e3c3c3a4bf44 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_3.js @@ -0,0 +1,37 @@ +//// [await_unaryExpression_es2017_3.ts] + +async function bar1() { + ++await 42; // Error +} + +async function bar2() { + --await 42; // Error +} + +async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis +} + +async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis +} + +//// [await_unaryExpression_es2017_3.js] +async function bar1() { + ++; + await 42; // Error +} +async function bar2() { + --; + await 42; // Error +} +async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis +} +async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis +} diff --git a/tests/baselines/reference/es2017basicAsync.js b/tests/baselines/reference/es2017basicAsync.js index da219f4614c12..b19eaa4b0ba0e 100644 --- a/tests/baselines/reference/es2017basicAsync.js +++ b/tests/baselines/reference/es2017basicAsync.js @@ -1,4 +1,4 @@ -//// [es2017-async.ts] +//// [es2017basicAsync.ts] async (): Promise => { await 0; @@ -47,7 +47,7 @@ class AsyncClass { } -//// [es2017-async.js] +//// [es2017basicAsync.js] async () => { await 0; }; diff --git a/tests/baselines/reference/es2017basicAsync.symbols b/tests/baselines/reference/es2017basicAsync.symbols index be3b2e723f4c5..75f4d2cfa761d 100644 --- a/tests/baselines/reference/es2017basicAsync.symbols +++ b/tests/baselines/reference/es2017basicAsync.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es2017-async.ts === +=== tests/cases/compiler/es2017basicAsync.ts === async (): Promise => { >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) @@ -7,20 +7,20 @@ async (): Promise => { } async function asyncFunc() { ->asyncFunc : Symbol(asyncFunc, Decl(es2017-async.ts, 3, 1)) +>asyncFunc : Symbol(asyncFunc, Decl(es2017basicAsync.ts, 3, 1)) await 0; } const asycnArrowFunc = async (): Promise => { ->asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es2017-async.ts, 9, 5)) +>asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es2017basicAsync.ts, 9, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 0; } async function asyncIIFE() { ->asyncIIFE : Symbol(asyncIIFE, Decl(es2017-async.ts, 11, 1)) +>asyncIIFE : Symbol(asyncIIFE, Decl(es2017basicAsync.ts, 11, 1)) await 0; @@ -31,7 +31,7 @@ async function asyncIIFE() { })(); await (async function asyncNamedFunc(): Promise { ->asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es2017-async.ts, 20, 11)) +>asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es2017basicAsync.ts, 20, 11)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 1; @@ -45,32 +45,32 @@ async function asyncIIFE() { } class AsyncClass { ->AsyncClass : Symbol(AsyncClass, Decl(es2017-async.ts, 27, 1)) +>AsyncClass : Symbol(AsyncClass, Decl(es2017basicAsync.ts, 27, 1)) asyncPropFunc = async function(): Promise { ->asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es2017-async.ts, 29, 18)) +>asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es2017basicAsync.ts, 29, 18)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } asyncPropNamedFunc = async function namedFunc(): Promise { ->asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es2017-async.ts, 32, 5)) ->namedFunc : Symbol(namedFunc, Decl(es2017-async.ts, 34, 24)) +>asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es2017basicAsync.ts, 32, 5)) +>namedFunc : Symbol(namedFunc, Decl(es2017basicAsync.ts, 34, 24)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } asyncPropArrowFunc = async (): Promise => { ->asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es2017-async.ts, 36, 5)) +>asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es2017basicAsync.ts, 36, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } async asyncMethod(): Promise { ->asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es2017-async.ts, 40, 5)) +>asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es2017basicAsync.ts, 40, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; diff --git a/tests/baselines/reference/es2017basicAsync.types b/tests/baselines/reference/es2017basicAsync.types index 79f3a005e6e65..71c2dbe50f312 100644 --- a/tests/baselines/reference/es2017basicAsync.types +++ b/tests/baselines/reference/es2017basicAsync.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es2017-async.ts === +=== tests/cases/compiler/es2017basicAsync.ts === async (): Promise => { >async (): Promise => { await 0;} : () => Promise diff --git a/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts b/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts new file mode 100644 index 0000000000000..87bbc42e1668c --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true +type PromiseAlias = Promise; + +async function f(): PromiseAlias { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts new file mode 100644 index 0000000000000..1ade02c09d2e8 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts @@ -0,0 +1,4 @@ +// @target: ES5 +// @noEmitHelpers: true + +const x = async => async; \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts new file mode 100644 index 0000000000000..09d97cc253be7 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts @@ -0,0 +1,7 @@ +// @target: es2017 +// @noEmitHelpers: true + +var foo = async (): Promise => { + // Legal to use 'await' in a type context. + var v: await; +} diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts new file mode 100644 index 0000000000000..0f9ec479a3163 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true + +var foo = async (): Promise => { +}; \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts new file mode 100644 index 0000000000000..b11441372ffdc --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +var f = (await) => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts new file mode 100644 index 0000000000000..9b5924fc1455f --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +function f(await = await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts new file mode 100644 index 0000000000000..5a9882778365f --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +var await = () => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts new file mode 100644 index 0000000000000..aabe5a99372ad --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true + +var foo = async (await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts new file mode 100644 index 0000000000000..d82ce86442107 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true + +var foo = async (a = await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts new file mode 100644 index 0000000000000..bc49c5995e6a5 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts @@ -0,0 +1,8 @@ +// @target: es2017 +// @noEmitHelpers: true + +var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts new file mode 100644 index 0000000000000..387b09c791a47 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true + +var foo = async (): Promise => { + var v = { [await]: foo } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts new file mode 100644 index 0000000000000..93254fee5c746 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +var foo = async (a = await => await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts new file mode 100644 index 0000000000000..c71c6ddecb0a8 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts @@ -0,0 +1,8 @@ +// @target: es2017 +// @noEmitHelpers: true +class C { + method() { + function other() {} + var fn = async () => await other.apply(this, arguments); + } +} diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts new file mode 100644 index 0000000000000..3f398d9be82c1 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts @@ -0,0 +1,7 @@ +// @target: es2017 +// @noEmitHelpers: true +class C { + method() { + var fn = async () => await this; + } +} diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts new file mode 100644 index 0000000000000..9b63b7bd468c3 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true + +declare function someOtherFunction(i: any): Promise; +const x = async i => await someOtherFunction(i) +const x1 = async (i) => await someOtherFunction(i); \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts b/tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts new file mode 100644 index 0000000000000..c0ab4838f70f2 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts @@ -0,0 +1,41 @@ +// @target: es2017 +// @isolatedModules: true +import { MyPromise } from "missing"; + +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncAwait_es2017.ts b/tests/cases/conformance/async/es2017/asyncAwait_es2017.ts new file mode 100644 index 0000000000000..a255cb7cb710c --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncAwait_es2017.ts @@ -0,0 +1,40 @@ +// @target: es2017 +type MyPromise = Promise; +declare var MyPromise: typeof Promise; +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncClass_es2017.ts b/tests/cases/conformance/async/es2017/asyncClass_es2017.ts new file mode 100644 index 0000000000000..78746c972d09e --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncClass_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async class C { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts b/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts new file mode 100644 index 0000000000000..874c0b99239d2 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true +class C { + async constructor() { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts b/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts new file mode 100644 index 0000000000000..d7fd4888fed55 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts @@ -0,0 +1,3 @@ +// @target: es2017 +// @noEmitHelpers: true +declare async function foo(): Promise; \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts b/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts new file mode 100644 index 0000000000000..dc995206e847b --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true +async enum E { + Value +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts b/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts new file mode 100644 index 0000000000000..340c33138cf52 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true +class C { + async get foo() { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts b/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts new file mode 100644 index 0000000000000..81f5b690edd47 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts @@ -0,0 +1,10 @@ +// @target: es2017 +// @module: commonjs +// @filename: task.ts +export class Task extends Promise { } + +// @filename: test.ts +import { Task } from "./task"; +class Test { + async example(): Task { return; } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts b/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts new file mode 100644 index 0000000000000..252730f9ff6f0 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async interface I { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts b/tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts new file mode 100644 index 0000000000000..b9005c4859657 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts @@ -0,0 +1,52 @@ +// @target: es2017 +// @noEmitHelpers: true +class A { + x() { + } +} + +class B extends A { + // async method with only call/get on 'super' does not require a binding + async simple() { + // call with property access + super.x(); + + // call with element access + super["x"](); + + // property access (read) + const a = super.x; + + // element access (read) + const b = super["x"]; + } + + // async method with assignment/destructuring on 'super' requires a binding + async advanced() { + const f = () => {}; + + // call with property access + super.x(); + + // call with element access + super["x"](); + + // property access (read) + const a = super.x; + + // element access (read) + const b = super["x"]; + + // property access (assign) + super.x = f; + + // element access (assign) + super["x"] = f; + + // destructuring assign with property access + ({ f: super.x } = { f }); + + // destructuring assign with element access + ({ f: super["x"] } = { f }); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncModule_es2017.ts b/tests/cases/conformance/async/es2017/asyncModule_es2017.ts new file mode 100644 index 0000000000000..7c577e27fb901 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncModule_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async module M { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts b/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts new file mode 100644 index 0000000000000..920bdfb8bdadb --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @filename: a.ts +async function f() {} +// @filename: b.ts +function g() { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts b/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts new file mode 100644 index 0000000000000..95695168cea0f --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts @@ -0,0 +1,9 @@ +// @target: es2017 +// @noEmitHelpers: true +namespace X { + export class MyPromise extends Promise { + } +} + +async function f(): X.MyPromise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts b/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts new file mode 100644 index 0000000000000..658c07d42e843 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true +class C { + async set foo(value) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts b/tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts new file mode 100644 index 0000000000000..c4d4cafef8a13 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts @@ -0,0 +1,8 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "use strict"; + var b = await p || a; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts new file mode 100644 index 0000000000000..ef9076a8bee13 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts @@ -0,0 +1,11 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p || a; + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts new file mode 100644 index 0000000000000..84d2f6222925d --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts @@ -0,0 +1,11 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p && a; + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts new file mode 100644 index 0000000000000..1f3a8245d42de --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts @@ -0,0 +1,11 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: number; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p + a; + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts new file mode 100644 index 0000000000000..6c36f1e4ce5b5 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts @@ -0,0 +1,11 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await p, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts new file mode 100644 index 0000000000000..abbcbb95ba923 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts @@ -0,0 +1,12 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var o: { a: boolean; }; + o.a = await p; + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts new file mode 100644 index 0000000000000..da46e04ed1e8e --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(a, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts new file mode 100644 index 0000000000000..baf75ab95c3d3 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(await p, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts new file mode 100644 index 0000000000000..17cf6d8c6c9bb --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(a, await p, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts new file mode 100644 index 0000000000000..ef5e1d203d980 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await pfn)(a, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts new file mode 100644 index 0000000000000..8494bc11b4cd8 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(a, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts new file mode 100644 index 0000000000000..7939572baea5a --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(await p, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts new file mode 100644 index 0000000000000..3f1231a50d6b4 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(a, await p, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts new file mode 100644 index 0000000000000..c669122bada3b --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await po).fn(a, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts b/tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts new file mode 100644 index 0000000000000..fe34d53a03cf1 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts @@ -0,0 +1,9 @@ +// @target: es2017 +// @noEmitHelpers: true +declare class C { } +declare var p: Promise; + +async function func(): Promise { + class D extends (await p) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts b/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts new file mode 100644 index 0000000000000..493aa838ffec1 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts @@ -0,0 +1,14 @@ +// @target: es2017 +// @noEmitHelpers: true +declare let a: number | string; +declare let b: PromiseLike | PromiseLike; +declare let c: PromiseLike; +declare let d: number | PromiseLike; +declare let e: number | PromiseLike; +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts new file mode 100644 index 0000000000000..dee2554653d29 --- /dev/null +++ b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts @@ -0,0 +1,17 @@ +// @target: es2017 + +async function bar() { + !await 42; // OK +} + +async function bar1() { + +await 42; // OK +} + +async function bar3() { + -await 42; // OK +} + +async function bar4() { + ~await 42; // OK +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts new file mode 100644 index 0000000000000..f38260b332d70 --- /dev/null +++ b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts @@ -0,0 +1,21 @@ +// @target: es2017 + +async function bar() { + !await 42; // OK +} + +async function bar1() { + delete await 42; // OK +} + +async function bar2() { + delete await 42; // OK +} + +async function bar3() { + void await 42; +} + +async function bar4() { + +await 42; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts new file mode 100644 index 0000000000000..b48c661f0b93a --- /dev/null +++ b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts @@ -0,0 +1,13 @@ +// @target: es2017 + +async function bar1() { + delete await 42; +} + +async function bar2() { + delete await 42; +} + +async function bar3() { + void await 42; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts new file mode 100644 index 0000000000000..d2c608d0e7b32 --- /dev/null +++ b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts @@ -0,0 +1,19 @@ +// @target: es2017 + +async function bar1() { + ++await 42; // Error +} + +async function bar2() { + --await 42; // Error +} + +async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis +} + +async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts new file mode 100644 index 0000000000000..9b744713945d0 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(a = await => await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts new file mode 100644 index 0000000000000..9613e86616374 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async function await(): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts new file mode 100644 index 0000000000000..02b6e833c2c2e --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts @@ -0,0 +1,3 @@ +// @target: es2017 +// @noEmitHelpers: true +var v = async function await(): Promise { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts new file mode 100644 index 0000000000000..40177c1fbcb57 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; +} diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts new file mode 100644 index 0000000000000..06bd2de3eef0b --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(): Promise { + return; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts new file mode 100644 index 0000000000000..2585dc666f4fe --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts @@ -0,0 +1,25 @@ +// @target: es2017 +// @noEmitHelpers: true +declare class Thenable { then(): void; } +declare let a: any; +declare let obj: { then: string; }; +declare let thenable: Thenable; +async function fn1() { } // valid: Promise +async function fn2(): { } { } // error +async function fn3(): any { } // error +async function fn4(): number { } // error +async function fn5(): PromiseLike { } // error +async function fn6(): Thenable { } // error +async function fn7() { return; } // valid: Promise +async function fn8() { return 1; } // valid: Promise +async function fn9() { return null; } // valid: Promise +async function fn10() { return undefined; } // valid: Promise +async function fn11() { return a; } // valid: Promise +async function fn12() { return obj; } // valid: Promise<{ then: string; }> +async function fn13() { return thenable; } // error +async function fn14() { await 1; } // valid: Promise +async function fn15() { await null; } // valid: Promise +async function fn16() { await undefined; } // valid: Promise +async function fn17() { await a; } // valid: Promise +async function fn18() { await obj; } // valid: Promise +async function fn19() { await thenable; } // error diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts new file mode 100644 index 0000000000000..178611ad91b66 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts new file mode 100644 index 0000000000000..08711a4cfbd8e --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +function f(await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts new file mode 100644 index 0000000000000..9b5924fc1455f --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +function f(await = await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts new file mode 100644 index 0000000000000..84c6c93b90faf --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +function await() { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts new file mode 100644 index 0000000000000..c57fb73d6d712 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts new file mode 100644 index 0000000000000..1ceb160c12b8a --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(a = await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts new file mode 100644 index 0000000000000..e5c2649d34edd --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts @@ -0,0 +1,7 @@ +// @target: es2017 +// @noEmitHelpers: true +async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts new file mode 100644 index 0000000000000..64e62a2719ef0 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts @@ -0,0 +1,3 @@ +// @target: es2017 +// @noEmitHelpers: true +var v = { [await]: foo } \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts new file mode 100644 index 0000000000000..7d3b7213b99e0 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(): Promise { + var v = { [await]: foo } +} \ No newline at end of file From e60e97f5c9d7a2c21ba36631c17f9278166feeae Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 01:04:38 +0200 Subject: [PATCH 06/13] Cleanup comments --- src/compiler/transformers/es2017.ts | 2 -- src/compiler/transformers/ts.ts | 8 -------- 2 files changed, 10 deletions(-) diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 33376bbceb125..166e11608289f 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -71,8 +71,6 @@ namespace ts { return visitEachChild(node, visitor, context); } - // node = visitEachChild(node, visitor, context); - // return visitEachChild(node, visitor, context); return node; } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 30276deff92b8..2aa20410d8c6c 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2247,10 +2247,6 @@ namespace ts { } function transformFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody { - // if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES2017) { - // return transformAsyncFunctionBody(node); - // } - return transformFunctionBodyWorker(node.body); } @@ -2267,10 +2263,6 @@ namespace ts { } function transformConciseBody(node: ArrowFunction): ConciseBody { - // if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES2017) { - // return transformAsyncFunctionBody(node); - // } - return transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ false); } From f0fd77ae8edb070e9f01cb0b5f6c69e9454f393a Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 11:58:01 +0200 Subject: [PATCH 07/13] Make async/await an ES2017 feature only --- src/compiler/binder.ts | 31 ++++++++---------- src/compiler/transformers/es2017.ts | 13 ++++---- src/compiler/transformers/ts.ts | 49 ++++++----------------------- 3 files changed, 28 insertions(+), 65 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4edbb5d9e1a7c..3f5db2ae7c5a1 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2555,11 +2555,6 @@ namespace ts { // extends clause of a class. let transformFlags = subtreeFlags | TransformFlags.AssertES6; - // propagate ES2017 - if (node.expression.transformFlags & TransformFlags.ContainsES2017) { - transformFlags |= TransformFlags.ContainsES2017; - } - // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. if (node.typeArguments) { @@ -2591,16 +2586,16 @@ namespace ts { const typeParameters = node.typeParameters; const asteriskToken = node.asteriskToken; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, + // A MethodDeclaration is TypeScript syntax if it is either abstract, overloaded, // generic, or has a decorator. if (!body || typeParameters - || (modifierFlags & (ModifierFlags.Async | ModifierFlags.Abstract)) + || (modifierFlags & ModifierFlags.Abstract) || (subtreeFlags & TransformFlags.ContainsDecorators)) { transformFlags |= TransformFlags.AssertTypeScript; } - // Async MethodDeclaration is ES2017 + // An async method declaration is ES2017 syntax. if (modifierFlags & ModifierFlags.Async) { transformFlags |= TransformFlags.AssertES2017; } @@ -2619,10 +2614,10 @@ namespace ts { const modifierFlags = getModifierFlags(node); const body = node.body; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, + // An accessor is TypeScript syntax if it is either abstract, overloaded, // generic, or has a decorator. if (!body - || (modifierFlags & (ModifierFlags.Async | ModifierFlags.Abstract)) + || (modifierFlags & ModifierFlags.Abstract) || (subtreeFlags & TransformFlags.ContainsDecorators)) { transformFlags |= TransformFlags.AssertTypeScript; } @@ -2664,9 +2659,9 @@ namespace ts { transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES6; } - // If a FunctionDeclaration is async, then it is TypeScript syntax. + // An async function declaration is ES2017 syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; + transformFlags |= TransformFlags.AssertES2017; } // If a FunctionDeclaration's subtree has marked the container as needing to capture the @@ -2695,9 +2690,9 @@ namespace ts { const modifierFlags = getModifierFlags(node); const asteriskToken = node.asteriskToken; - // An async function expression is TypeScript syntax. + // An async function expression is ES2017 syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; + transformFlags |= TransformFlags.AssertES2017; } // If a FunctionExpression's subtree has marked the container as needing to capture the @@ -2725,9 +2720,9 @@ namespace ts { let transformFlags = subtreeFlags | TransformFlags.AssertES6; const modifierFlags = getModifierFlags(node); - // An async arrow function is TypeScript syntax. + // An async arrow function is ES2017 syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; + transformFlags |= TransformFlags.AssertES2017; } // If an ArrowFunction contains a lexical this, its container must capture the lexical this. @@ -2868,8 +2863,8 @@ namespace ts { switch (kind) { case SyntaxKind.AsyncKeyword: case SyntaxKind.AwaitExpression: - // Typescript async/await are ES2017 features - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; + // async/await is ES2017 syntax + transformFlags |= TransformFlags.AssertES2017; break; case SyntaxKind.PublicKeyword: diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 166e11608289f..7555c3bdd774a 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -77,26 +77,27 @@ namespace ts { function visitorWorker(node: Node): VisitResult { switch (node.kind) { case SyntaxKind.AsyncKeyword: + // ES2017 async modifier should be elided for targets < ES2017 return undefined; case SyntaxKind.AwaitExpression: - // Typescript 'await' expressions must be transformed for targets < ES2017. + // ES2017 'await' expressions must be transformed for targets < ES2017. return visitAwaitExpression(node); case SyntaxKind.MethodDeclaration: - // TypeScript method declarations may be 'async' + // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); case SyntaxKind.FunctionDeclaration: - // TypeScript function declarations may be 'async' + // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); case SyntaxKind.FunctionExpression: - // TypeScript function expressions may be 'async' + // ES2017 function expressions may be 'async' return visitFunctionExpression(node); case SyntaxKind.ArrowFunction: - // TypeScript arrow functions may be 'async' + // ES2017 arrow functions may be 'async' return visitArrowFunction(node); default: @@ -160,9 +161,7 @@ namespace ts { * Visits a function declaration. * * This function will be called when one of the following conditions are met: - * - The node is an overload * - The node is marked async - * - The node is exported from a TypeScript namespace * * @param node The function node. */ diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 2aa20410d8c6c..61f40e1ed8097 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -230,10 +230,6 @@ namespace ts { // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - // Typescript ES2017 async/await are handled by ES2017 transformer - case SyntaxKind.AsyncKeyword: - return node; - case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: @@ -297,7 +293,6 @@ namespace ts { // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassDeclaration(node); case SyntaxKind.ClassExpression: @@ -310,7 +305,6 @@ namespace ts { // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassExpression(node); case SyntaxKind.HeritageClause: @@ -325,7 +319,7 @@ namespace ts { return visitExpressionWithTypeArguments(node); case SyntaxKind.MethodDeclaration: - // TypeScript method declarations may be 'async', and may have decorators, modifiers + // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); @@ -334,19 +328,19 @@ namespace ts { return visitGetAccessor(node); case SyntaxKind.SetAccessor: - // Set Accessors can have TypeScript modifiers, decorators, and type annotations. + // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); case SyntaxKind.FunctionDeclaration: - // TypeScript function declarations may be 'async' + // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); case SyntaxKind.FunctionExpression: - // TypeScript function expressions may be 'async' + // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); case SyntaxKind.ArrowFunction: - // TypeScript arrow functions may be 'async' + // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); case SyntaxKind.Parameter: @@ -378,10 +372,6 @@ namespace ts { // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case SyntaxKind.AwaitExpression: - // Typescript ES2017 async/await are handled by ES2017 transformer - return visitAwaitExpression(node); - case SyntaxKind.VariableStatement: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); @@ -2050,7 +2040,7 @@ namespace ts { * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked as abstract, async, public, private, protected, or readonly + * - The node is marked as abstract, public, private, protected, or readonly * - The node has both a decorator and a computed property name * * @param node The method node. @@ -2161,8 +2151,8 @@ namespace ts { * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked async * - The node is exported from a TypeScript namespace + * - The node has decorators * * @param node The function node. */ @@ -2197,7 +2187,7 @@ namespace ts { * Visits a function expression node. * * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations * * @param node The function expression node. */ @@ -2216,10 +2206,6 @@ namespace ts { /*location*/ node ); - // Keep modifiers in case of async functions - const funcModifiers = visitNodes(node.modifiers, visitor, isModifier); - func.modifiers = createNodeArray(funcModifiers); - setOriginalNode(func, node); return func; @@ -2228,7 +2214,7 @@ namespace ts { /** * @remarks * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations */ function visitArrowFunction(node: ArrowFunction) { const func = createArrowFunction( @@ -2368,23 +2354,6 @@ namespace ts { } } - /** - * Visits an await expression. - * - * This function will be called any time a ES2017 await expression is encountered. - * - * @param node The await expression node. - */ - function visitAwaitExpression(node: AwaitExpression): Expression { - return updateNode( - createAwait( - visitNode(node.expression, visitor, isExpression), - /*location*/ node - ), - node - ); - } - /** * Visits a parenthesized expression that contains either a type assertion or an `as` * expression. From 4284a749b45c441dab54f699e1aa5087527ffeac Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 11:32:26 +0200 Subject: [PATCH 08/13] Adjust some async conformance baselines --- .../reference/asyncFunctionDeclaration10_es2017.js | 1 + tests/baselines/reference/asyncFunctionDeclaration10_es5.js | 6 ++++++ tests/baselines/reference/asyncFunctionDeclaration10_es6.js | 3 +++ .../reference/asyncFunctionDeclaration12_es2017.js | 2 +- .../baselines/reference/asyncFunctionDeclaration5_es2017.js | 1 + tests/baselines/reference/asyncFunctionDeclaration5_es5.js | 5 +++++ tests/baselines/reference/asyncFunctionDeclaration5_es6.js | 3 +++ 7 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js index 0e687c1e0d589..f8a22204311e5 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js @@ -3,5 +3,6 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es2017.js] +async function foo(a = await ) { } await; Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.js b/tests/baselines/reference/asyncFunctionDeclaration10_es5.js index 05ff9daa9dabd..758bdab5dc902 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.js @@ -3,5 +3,11 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es5.js] +function foo(a) { + if (a === void 0) { a = yield ; } + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); +} await; Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js index 141c0cbab55cd..1f175035bf085 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js @@ -3,5 +3,8 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es6.js] +function foo(a = yield ) { + return __awaiter(this, void 0, void 0, function* () { }); +} await; Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js index 69f5993f5c069..93fbb0610237d 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js @@ -2,4 +2,4 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es2017.js] -var v = , await = () => { }; +var v = async function () { }, await = () => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js index 13c04c5d5bc79..904bbe62f0ba8 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js @@ -3,5 +3,6 @@ async function foo(await): Promise { } //// [asyncFunctionDeclaration5_es2017.js] +async function foo() { } await; Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.js b/tests/baselines/reference/asyncFunctionDeclaration5_es5.js index 22c18ff6ad412..5f8f8f4273589 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.js @@ -3,5 +3,10 @@ async function foo(await): Promise { } //// [asyncFunctionDeclaration5_es5.js] +function foo() { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); +} await; Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.js b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js index 8d28c371465f8..9521b76041585 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js @@ -3,5 +3,8 @@ async function foo(await): Promise { } //// [asyncFunctionDeclaration5_es6.js] +function foo() { + return __awaiter(this, void 0, void 0, function* () { }); +} await; Promise < void > {}; From 7df3fda2b36e6a1eda5478a9077074e57e35c925 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 12:03:53 +0200 Subject: [PATCH 09/13] Refactor createFunctionExpresson --- src/compiler/factory.ts | 17 +++++++++++------ src/compiler/transformers/es2017.ts | 3 +-- src/compiler/transformers/es6.ts | 5 ++++- src/compiler/transformers/generators.ts | 4 +++- src/compiler/transformers/module/module.ts | 1 + src/compiler/transformers/module/system.ts | 3 +++ src/compiler/transformers/ts.ts | 3 +++ src/compiler/visitor.ts | 3 ++- 8 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index d873c3ef87777..519269ccfd078 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -524,9 +524,9 @@ namespace ts { return node; } - export function createFunctionExpression(asteriskToken: Node, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) { + export function createFunctionExpression(modifiers: Modifier[], asteriskToken: Node, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) { const node = createNode(SyntaxKind.FunctionExpression, location, flags); - node.modifiers = undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; @@ -536,9 +536,9 @@ namespace ts { return node; } - export function updateFunctionExpression(node: FunctionExpression, name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); + export function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); } return node; } @@ -1735,6 +1735,7 @@ namespace ts { export function createAwaiterHelper(externalHelpersModuleName: Identifier | undefined, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression, body: Block) { const generatorFunc = createFunctionExpression( + /*modifiers*/ undefined, createNode(SyntaxKind.AsteriskToken), /*name*/ undefined, /*typeParameters*/ undefined, @@ -1908,6 +1909,7 @@ namespace ts { createCall( createParen( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -2089,6 +2091,7 @@ namespace ts { const properties: ObjectLiteralElementLike[] = []; if (getAccessor) { const getterFunction = createFunctionExpression( + getAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -2104,6 +2107,7 @@ namespace ts { if (setAccessor) { const setterFunction = createFunctionExpression( + setAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -2170,6 +2174,7 @@ namespace ts { createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode( createFunctionExpression( + method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, @@ -2909,4 +2914,4 @@ namespace ts { function tryGetModuleNameFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration, host: EmitHost, resolver: EmitResolver, compilerOptions: CompilerOptions) { return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions); } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 7555c3bdd774a..1d3c189110a19 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -202,6 +202,7 @@ namespace ts { } const func = createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, node.name, /*typeParameters*/ undefined, @@ -211,8 +212,6 @@ namespace ts { /*location*/ node ); - node.modifiers = visitNodes(node.modifiers, visitor, isModifier); - setOriginalNode(func, node); return func; diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es6.ts index 7fb0594a6ccba..ba5f8a3fb7776 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es6.ts @@ -681,6 +681,7 @@ namespace ts { const extendsClauseElement = getClassExtendsHeritageClauseElement(node); const classFunction = createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -1509,6 +1510,7 @@ namespace ts { const expression = setOriginalNode( createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, name, /*typeParameters*/ undefined, @@ -2240,6 +2242,7 @@ namespace ts { /*type*/ undefined, setEmitFlags( createFunctionExpression( + /*modifiers*/ undefined, isAsyncBlockContainingAwait ? createToken(SyntaxKind.AsteriskToken) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -3256,4 +3259,4 @@ namespace ts { return isIdentifier(expression) && expression === parameter.name; } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index f3a47f037cadd..88788022ef8c4 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -496,6 +496,7 @@ namespace ts { if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { node = setOriginalNode( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, @@ -2591,6 +2592,7 @@ namespace ts { createThis(), setEmitFlags( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -3080,4 +3082,4 @@ namespace ts { ); } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 3877169e6c37a..9051f375bf99f 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -179,6 +179,7 @@ namespace ts { // // function (require, exports, module1, module2) ... createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index d4ee4f36b87d0..e7b441f4c9b55 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -110,6 +110,7 @@ namespace ts { const moduleName = tryGetModuleNameFromFile(node, host, compilerOptions); const dependencies = createArrayLiteral(map(dependencyGroups, getNameOfDependencyGroup)); const body = createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -244,6 +245,7 @@ namespace ts { ), createPropertyAssignment("execute", createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -430,6 +432,7 @@ namespace ts { setters.push( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 61f40e1ed8097..77ab6a6ca0e6b 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2197,6 +2197,7 @@ namespace ts { } const func = createFunctionExpression( + visitNodes(node.modifiers, visitor, isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, @@ -2477,6 +2478,7 @@ namespace ts { const enumStatement = createStatement( createCall( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -2748,6 +2750,7 @@ namespace ts { const moduleStatement = createStatement( createCall( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index e147eda8535a6..6910f5aac4d87 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -807,6 +807,7 @@ namespace ts { case SyntaxKind.FunctionExpression: return updateFunctionExpression(node, + visitNodes((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isPropertyName), visitNodes((node).typeParameters, visitor, isTypeParameter), (context.startLexicalEnvironment(), visitNodes((node).parameters, visitor, isParameter)), @@ -1357,4 +1358,4 @@ namespace ts { } } } -} \ No newline at end of file +} From c5ddf27dc68d6dc49a3d6f01e1db35fa6b455b79 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 12:04:36 +0200 Subject: [PATCH 10/13] Remove constant substitution from ES2017 transformer --- src/compiler/transformers/es2017.ts | 32 +---------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 1d3c189110a19..f9e8b539c6a11 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -395,7 +395,7 @@ namespace ts { } } - return substituteConstantValue(node); + return node; } function substituteElementAccessExpression(node: ElementAccessExpression) { @@ -410,39 +410,9 @@ namespace ts { } } - return substituteConstantValue(node); - } - - function substituteConstantValue(node: PropertyAccessExpression | ElementAccessExpression): LeftHandSideExpression { - const constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - const substitute = createLiteral(constantValue); - setSourceMapRange(substitute, node); - setCommentRange(substitute, node); - if (!compilerOptions.removeComments) { - const propertyName = isPropertyAccessExpression(node) - ? declarationNameToString(node.name) - : getTextOfNode(node.argumentExpression); - substitute.trailingComment = ` ${propertyName} `; - } - - setConstantValue(node, constantValue); - return substitute; - } - return node; } - function tryGetConstEnumValue(node: Node): number { - if (compilerOptions.isolatedModules) { - return undefined; - } - - return isPropertyAccessExpression(node) || isElementAccessExpression(node) - ? resolver.getConstantValue(node) - : undefined; - } - function substituteCallExpression(node: CallExpression): Expression { const expression = node.expression; if (isSuperProperty(expression)) { From b871b5353c8a9ca6dedd6bc84706fd75ed86bae4 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 13:32:00 +0200 Subject: [PATCH 11/13] Favor use of ES2015 instead of ES6 --- Jakefile.js | 8 +-- src/compiler/binder.ts | 62 +++++++++---------- src/compiler/checker.ts | 42 ++++++------- src/compiler/core.ts | 2 +- src/compiler/emitter.ts | 4 +- src/compiler/factory.ts | 2 +- src/compiler/program.ts | 4 +- src/compiler/transformer.ts | 10 +-- .../transformers/{es6.ts => es2015.ts} | 26 ++++---- src/compiler/transformers/es2017.ts | 4 +- .../transformers/module/{es6.ts => es2015.ts} | 4 +- src/compiler/transformers/module/module.ts | 2 +- src/compiler/transformers/ts.ts | 6 +- src/compiler/tsconfig.json | 4 +- src/compiler/types.ts | 10 +-- src/compiler/utilities.ts | 6 +- src/harness/harness.ts | 2 +- src/harness/tsconfig.json | 4 +- src/harness/unittests/moduleResolution.ts | 2 +- src/services/tsconfig.json | 4 +- src/services/utilities.ts | 2 +- 21 files changed, 105 insertions(+), 105 deletions(-) rename src/compiler/transformers/{es6.ts => es2015.ts} (97%) rename src/compiler/transformers/module/{es6.ts => es2015.ts} (96%) diff --git a/Jakefile.js b/Jakefile.js index 8d46368653c04..6f86ef35b0927 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -70,14 +70,14 @@ var compilerSources = [ "visitor.ts", "transformers/destructuring.ts", "transformers/ts.ts", - "transformers/module/es6.ts", + "transformers/module/es2015.ts", "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", "transformers/es2017.ts", "transformers/es2016.ts", + "transformers/es2015.ts", "transformers/generators.ts", - "transformers/es6.ts", "transformer.ts", "sourcemap.ts", "comments.ts", @@ -105,14 +105,14 @@ var servicesSources = [ "visitor.ts", "transformers/destructuring.ts", "transformers/ts.ts", - "transformers/module/es6.ts", + "transformers/module/es2015.ts", "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", "transformers/es2017.ts", "transformers/es2016.ts", + "transformers/es2015.ts", "transformers/generators.ts", - "transformers/es6.ts", "transformer.ts", "sourcemap.ts", "comments.ts", diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 3f5db2ae7c5a1..970e481faaa51 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1636,7 +1636,7 @@ namespace ts { } function checkStrictModeFunctionDeclaration(node: FunctionDeclaration) { - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { // Report error if function is not top level function declaration if (blockScopeContainer.kind !== SyntaxKind.SourceFile && blockScopeContainer.kind !== SyntaxKind.ModuleDeclaration && @@ -2376,7 +2376,7 @@ namespace ts { || isSuperOrSuperProperty(expression, expressionKind)) { // If the this node contains a SpreadElementExpression, or is a super call, then it is an ES6 // node. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2407,7 +2407,7 @@ namespace ts { && (leftKind === SyntaxKind.ObjectLiteralExpression || leftKind === SyntaxKind.ArrayLiteralExpression)) { // Destructuring assignments are ES6 syntax. - transformFlags |= TransformFlags.AssertES6 | TransformFlags.DestructuringAssignment; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.DestructuringAssignment; } else if (operatorTokenKind === SyntaxKind.AsteriskAsteriskToken || operatorTokenKind === SyntaxKind.AsteriskAsteriskEqualsToken) { @@ -2445,7 +2445,7 @@ namespace ts { // If a parameter has an initializer, a binding pattern or a dotDotDot token, then // it is ES6 syntax and its container must emit default value assignments or parameter destructuring downlevel. if (subtreeFlags & TransformFlags.ContainsBindingPattern || initializer || dotDotDotToken) { - transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsDefaultValueAssignments; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsDefaultValueAssignments; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2486,7 +2486,7 @@ namespace ts { } else { // A ClassDeclaration is ES6 syntax. - transformFlags = subtreeFlags | TransformFlags.AssertES6; + transformFlags = subtreeFlags | TransformFlags.AssertES2015; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. @@ -2509,7 +2509,7 @@ namespace ts { function computeClassExpression(node: ClassExpression, subtreeFlags: TransformFlags) { // A ClassExpression is ES6 syntax. - let transformFlags = subtreeFlags | TransformFlags.AssertES6; + let transformFlags = subtreeFlags | TransformFlags.AssertES2015; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. @@ -2533,7 +2533,7 @@ namespace ts { switch (node.token) { case SyntaxKind.ExtendsKeyword: // An `extends` HeritageClause is ES6 syntax. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; break; case SyntaxKind.ImplementsKeyword: @@ -2553,7 +2553,7 @@ namespace ts { function computeExpressionWithTypeArguments(node: ExpressionWithTypeArguments, subtreeFlags: TransformFlags) { // An ExpressionWithTypeArguments is ES6 syntax, as it is used in the // extends clause of a class. - let transformFlags = subtreeFlags | TransformFlags.AssertES6; + let transformFlags = subtreeFlags | TransformFlags.AssertES2015; // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. @@ -2580,7 +2580,7 @@ namespace ts { function computeMethod(node: MethodDeclaration, subtreeFlags: TransformFlags) { // A MethodDeclaration is ES6 syntax. - let transformFlags = subtreeFlags | TransformFlags.AssertES6; + let transformFlags = subtreeFlags | TransformFlags.AssertES2015; const modifierFlags = getModifierFlags(node); const body = node.body; const typeParameters = node.typeParameters; @@ -2656,7 +2656,7 @@ namespace ts { // If a FunctionDeclaration is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & ModifierFlags.Export) { - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2015; } // An async function declaration is ES2017 syntax. @@ -2667,8 +2667,8 @@ namespace ts { // If a FunctionDeclaration's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & TransformFlags.ES6FunctionSyntaxMask) { - transformFlags |= TransformFlags.AssertES6; + if (subtreeFlags & TransformFlags.ES2015FunctionSyntaxMask) { + transformFlags |= TransformFlags.AssertES2015; } // If a FunctionDeclaration is generator function and is the body of a @@ -2698,8 +2698,8 @@ namespace ts { // If a FunctionExpression's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & TransformFlags.ES6FunctionSyntaxMask) { - transformFlags |= TransformFlags.AssertES6; + if (subtreeFlags & TransformFlags.ES2015FunctionSyntaxMask) { + transformFlags |= TransformFlags.AssertES2015; } // If a FunctionExpression is generator function and is the body of a @@ -2717,7 +2717,7 @@ namespace ts { function computeArrowFunction(node: ArrowFunction, subtreeFlags: TransformFlags) { // An ArrowFunction is ES6 syntax, and excludes markers that should not escape the scope of an ArrowFunction. - let transformFlags = subtreeFlags | TransformFlags.AssertES6; + let transformFlags = subtreeFlags | TransformFlags.AssertES2015; const modifierFlags = getModifierFlags(node); // An async arrow function is ES2017 syntax. @@ -2755,7 +2755,7 @@ namespace ts { // A VariableDeclaration with a binding pattern is ES6 syntax. if (nameKind === SyntaxKind.ObjectBindingPattern || nameKind === SyntaxKind.ArrayBindingPattern) { - transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsBindingPattern; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBindingPattern; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2776,11 +2776,11 @@ namespace ts { // If a VariableStatement is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & ModifierFlags.Export) { - transformFlags |= TransformFlags.AssertES6 | TransformFlags.AssertTypeScript; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.AssertTypeScript; } if (declarationListTransformFlags & TransformFlags.ContainsBindingPattern) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } } @@ -2794,7 +2794,7 @@ namespace ts { // A labeled statement containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & TransformFlags.ContainsBlockScopedBinding && isIterationStatement(node, /*lookInLabeledStatements*/ true)) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2820,7 +2820,7 @@ namespace ts { // then we treat the statement as ES6 so that we can indicate that we do not // need to hold on to the right-hand side. if (node.expression.transformFlags & TransformFlags.DestructuringAssignment) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2843,12 +2843,12 @@ namespace ts { let transformFlags = subtreeFlags | TransformFlags.ContainsHoistedDeclarationOrCompletion; if (subtreeFlags & TransformFlags.ContainsBindingPattern) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } // If a VariableDeclarationList is `let` or `const`, then it is ES6 syntax. if (node.flags & NodeFlags.BlockScoped) { - transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsBlockScopedBinding; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBlockScopedBinding; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2897,7 +2897,7 @@ namespace ts { case SyntaxKind.ExportKeyword: // This node is both ES6 and TypeScript syntax. - transformFlags |= TransformFlags.AssertES6 | TransformFlags.AssertTypeScript; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.AssertTypeScript; break; case SyntaxKind.DefaultKeyword: @@ -2910,12 +2910,12 @@ namespace ts { case SyntaxKind.ShorthandPropertyAssignment: case SyntaxKind.ForOfStatement: // These nodes are ES6 syntax. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; break; case SyntaxKind.YieldExpression: // This node is ES6 syntax. - transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsYield; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsYield; break; case SyntaxKind.AnyKeyword: @@ -2976,7 +2976,7 @@ namespace ts { case SyntaxKind.SuperKeyword: // This node is ES6 syntax. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; break; case SyntaxKind.ThisKeyword: @@ -2987,7 +2987,7 @@ namespace ts { case SyntaxKind.ObjectBindingPattern: case SyntaxKind.ArrayBindingPattern: // These nodes are ES6 syntax. - transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsBindingPattern; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBindingPattern; break; case SyntaxKind.Decorator: @@ -3000,7 +3000,7 @@ namespace ts { if (subtreeFlags & TransformFlags.ContainsComputedPropertyName) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it // is an ES6 node. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } if (subtreeFlags & TransformFlags.ContainsLexicalThisInComputedPropertyName) { @@ -3017,7 +3017,7 @@ namespace ts { if (subtreeFlags & TransformFlags.ContainsSpreadElementExpression) { // If the this node contains a SpreadElementExpression, then it is an ES6 // node. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } break; @@ -3028,14 +3028,14 @@ namespace ts { case SyntaxKind.ForInStatement: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & TransformFlags.ContainsBlockScopedBinding) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } break; case SyntaxKind.SourceFile: if (subtreeFlags & TransformFlags.ContainsCapturedLexicalThis) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } break; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0b5c396307956..cecf2964f3c5e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3189,7 +3189,7 @@ namespace ts { const elements = pattern.elements; const lastElement = lastOrUndefined(elements); if (elements.length === 0 || (!isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { - return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType; + return languageVersion >= ScriptTarget.ES2015 ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. const elementTypes = map(elements, e => isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors)); @@ -9059,7 +9059,7 @@ namespace ts { // can explicitly bound arguments objects if (symbol === argumentsSymbol) { const container = getContainingFunction(node); - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { 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); } @@ -9084,7 +9084,7 @@ namespace ts { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (languageVersion === ScriptTarget.ES6 + if (languageVersion === ScriptTarget.ES2015 && declaration.kind === SyntaxKind.ClassDeclaration && nodeIsDecorated(declaration)) { let container = getContainingClass(node); @@ -9173,7 +9173,7 @@ namespace ts { } function checkNestedBlockScopedBinding(node: Identifier, symbol: Symbol): void { - if (languageVersion >= ScriptTarget.ES6 || + if (languageVersion >= ScriptTarget.ES2015 || (symbol.flags & (SymbolFlags.BlockScopedVariable | SymbolFlags.Class)) === 0 || symbol.valueDeclaration.parent.kind === SyntaxKind.CatchClause) { return; @@ -9339,7 +9339,7 @@ namespace ts { container = getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code - needToCaptureLexicalThis = (languageVersion < ScriptTarget.ES6); + needToCaptureLexicalThis = (languageVersion < ScriptTarget.ES2015); } switch (container.kind) { @@ -9447,7 +9447,7 @@ namespace ts { if (!isCallExpression) { while (container && container.kind === SyntaxKind.ArrowFunction) { container = getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6; + needToCaptureLexicalThis = languageVersion < ScriptTarget.ES2015; } } @@ -9561,7 +9561,7 @@ namespace ts { } if (container.parent.kind === SyntaxKind.ObjectLiteralExpression) { - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { error(node, Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; } @@ -9929,7 +9929,7 @@ namespace ts { const index = indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, IndexKind.Number) - || (languageVersion >= ScriptTarget.ES6 ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); + || (languageVersion >= ScriptTarget.ES2015 ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -10162,7 +10162,7 @@ namespace ts { // if there is no index type / iterated type. const restArrayType = checkExpression((e).expression, contextualMapper); const restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || - (languageVersion >= ScriptTarget.ES6 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); + (languageVersion >= ScriptTarget.ES2015 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -10909,7 +10909,7 @@ namespace ts { // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < ScriptTarget.ES6 && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { + if (languageVersion < ScriptTarget.ES2015 && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. @@ -14228,7 +14228,7 @@ namespace ts { } if (node.type) { - if (languageVersion >= ScriptTarget.ES6 && isSyntacticallyValidGenerator(node)) { + if (languageVersion >= ScriptTarget.ES2015 && isSyntacticallyValidGenerator(node)) { const returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -15189,7 +15189,7 @@ namespace ts { * callable `then` signature. */ function checkAsyncFunctionReturnType(node: FunctionLikeDeclaration): Type { - if (languageVersion >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES2015) { const returnType = getTypeFromTypeNode(node.type); return checkCorrectPromiseType(returnType, node.type, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); } @@ -15722,7 +15722,7 @@ namespace ts { function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier) { // No need to check for require or exports for ES6 modules and later - if (modulekind >= ModuleKind.ES6) { + if (modulekind >= ModuleKind.ES2015) { return; } @@ -16214,7 +16214,7 @@ namespace ts { if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES2015) { return checkElementTypeOfIterable(inputType, errorNode); } if (allowStringInput) { @@ -16392,7 +16392,7 @@ namespace ts { * 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable). */ function checkElementTypeOfArrayOrString(arrayOrStringType: Type, errorNode: Node): Type { - Debug.assert(languageVersion < ScriptTarget.ES6); + Debug.assert(languageVersion < ScriptTarget.ES2015); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. @@ -17700,7 +17700,7 @@ namespace ts { } } else { - if (modulekind === ModuleKind.ES6 && !isInAmbientContext(node)) { + if (modulekind === ModuleKind.ES2015 && !isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -17788,7 +17788,7 @@ namespace ts { checkExternalModuleExports(container); if (node.isExportEquals && !isInAmbientContext(node)) { - if (modulekind === ModuleKind.ES6) { + if (modulekind === ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } @@ -19296,7 +19296,7 @@ namespace ts { getGlobalTemplateStringsArrayType = memoize(() => getGlobalType("TemplateStringsArray")); - if (languageVersion >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES2015) { getGlobalESSymbolType = memoize(() => getGlobalType("Symbol")); getGlobalIterableType = memoize(() => getGlobalType("Iterable", /*arity*/ 1)); getGlobalIteratorType = memoize(() => getGlobalType("Iterator", /*arity*/ 1)); @@ -19329,7 +19329,7 @@ namespace ts { // If we found the module, report errors if it does not have the necessary exports. if (helpersModule) { const exports = helpersModule.exports; - if (requestedExternalEmitHelpers & NodeFlags.HasClassExtends && languageVersion < ScriptTarget.ES6) { + if (requestedExternalEmitHelpers & NodeFlags.HasClassExtends && languageVersion < ScriptTarget.ES2015) { verifyHelperSymbol(exports, "__extends", SymbolFlags.Value); } if (requestedExternalEmitHelpers & NodeFlags.HasJsxSpreadAttributes && compilerOptions.jsx !== JsxEmit.Preserve) { @@ -19346,7 +19346,7 @@ namespace ts { } if (requestedExternalEmitHelpers & NodeFlags.HasAsyncFunctions) { verifyHelperSymbol(exports, "__awaiter", SymbolFlags.Value); - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { verifyHelperSymbol(exports, "__generator", SymbolFlags.Value); } } @@ -19923,7 +19923,7 @@ namespace ts { if (!node.body) { return grammarErrorOnNode(node.asteriskToken, Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 3f2cc619cb383..3f60ec62c2b8a 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1191,7 +1191,7 @@ namespace ts { export function getEmitModuleKind(compilerOptions: CompilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS; } /* @internal */ diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a3f69e2fd4bd1..734fe2778e579 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2165,7 +2165,7 @@ const _super = (function (geti, seti) { // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) { + if ((languageVersion < ScriptTarget.ES2015) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) { writeLines(extendsHelper); extendsEmitted = true; helpersEmitted = true; @@ -2197,7 +2197,7 @@ const _super = (function (geti, seti) { // For target ES2017 and above, we can emit async/await as is. if ((languageVersion < ScriptTarget.ES2017) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) { writeLines(awaiterHelper); - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { writeLines(generatorHelper); } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 519269ccfd078..57007619c620e 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1985,7 +1985,7 @@ namespace ts { } else if (callee.kind === SyntaxKind.SuperKeyword) { thisArg = createThis(); - target = languageVersion < ScriptTarget.ES6 ? createIdentifier("_super", /*location*/ callee) : callee; + target = languageVersion < ScriptTarget.ES2015 ? createIdentifier("_super", /*location*/ callee) : callee; } else { switch (callee.kind) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5d46038b2b14d..dfe65fc08609c 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1478,7 +1478,7 @@ namespace ts { const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !isDeclarationFile(f) ? f : undefined); if (options.isolatedModules) { - if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES6) { + if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES2015) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } @@ -1488,7 +1488,7 @@ namespace ts { programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && options.module === ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < ScriptTarget.ES2015 && options.module === ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet const span = getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 55b83ea669d4a..fc656e08bf9ae 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -3,16 +3,16 @@ /// /// /// -/// +/// /// /// /// -/// +/// /* @internal */ namespace ts { const moduleTransformerMap = createMap({ - [ModuleKind.ES6]: transformES6Module, + [ModuleKind.ES2015]: transformES2015Module, [ModuleKind.System]: transformSystemModule, [ModuleKind.AMD]: transformModule, [ModuleKind.CommonJS]: transformModule, @@ -124,8 +124,8 @@ namespace ts { transformers.push(transformES2016); } - if (languageVersion < ScriptTarget.ES6) { - transformers.push(transformES6); + if (languageVersion < ScriptTarget.ES2015) { + transformers.push(transformES2015); transformers.push(transformGenerators); } diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es2015.ts similarity index 97% rename from src/compiler/transformers/es6.ts rename to src/compiler/transformers/es2015.ts index ba5f8a3fb7776..101c34a8199b8 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es2015.ts @@ -4,7 +4,7 @@ /*@internal*/ namespace ts { - const enum ES6SubstitutionFlags { + const enum ES2015SubstitutionFlags { /** Enables substitutions for captured `this` */ CapturedThis = 1 << 0, /** Enables substitutions for block-scoped bindings. */ @@ -163,7 +163,7 @@ namespace ts { ReplaceWithReturn, } - export function transformES6(context: TransformationContext) { + export function transformES2015(context: TransformationContext) { const { startLexicalEnvironment, endLexicalEnvironment, @@ -197,7 +197,7 @@ namespace ts { * They are persisted between each SourceFile transformation and should not * be reset. */ - let enabledSubstitutions: ES6SubstitutionFlags; + let enabledSubstitutions: ES2015SubstitutionFlags; return transformSourceFile; @@ -252,7 +252,7 @@ namespace ts { } function shouldCheckNode(node: Node): boolean { - return (node.transformFlags & TransformFlags.ES6) !== 0 || + return (node.transformFlags & TransformFlags.ES2015) !== 0 || node.kind === SyntaxKind.LabeledStatement || (isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } @@ -261,7 +261,7 @@ namespace ts { if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & TransformFlags.ContainsES6) { + else if (node.transformFlags & TransformFlags.ContainsES2015) { return visitEachChild(node, visitor, context); } else { @@ -3037,7 +3037,7 @@ namespace ts { function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) { const savedEnclosingFunction = enclosingFunction; - if (enabledSubstitutions & ES6SubstitutionFlags.CapturedThis && isFunctionLike(node)) { + if (enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis && isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. enclosingFunction = node; } @@ -3052,8 +3052,8 @@ namespace ts { * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & ES6SubstitutionFlags.BlockScopedBindings) === 0) { - enabledSubstitutions |= ES6SubstitutionFlags.BlockScopedBindings; + if ((enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) === 0) { + enabledSubstitutions |= ES2015SubstitutionFlags.BlockScopedBindings; context.enableSubstitution(SyntaxKind.Identifier); } } @@ -3063,8 +3063,8 @@ namespace ts { * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & ES6SubstitutionFlags.CapturedThis) === 0) { - enabledSubstitutions |= ES6SubstitutionFlags.CapturedThis; + if ((enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis) === 0) { + enabledSubstitutions |= ES2015SubstitutionFlags.CapturedThis; context.enableSubstitution(SyntaxKind.ThisKeyword); context.enableEmitNotification(SyntaxKind.Constructor); context.enableEmitNotification(SyntaxKind.MethodDeclaration); @@ -3103,7 +3103,7 @@ namespace ts { function substituteIdentifier(node: Identifier) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & ES6SubstitutionFlags.BlockScopedBindings) { + if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) { const original = getParseTreeNode(node, isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return getGeneratedNameForNode(original); @@ -3156,7 +3156,7 @@ namespace ts { * @param node An Identifier node. */ function substituteExpressionIdentifier(node: Identifier): Identifier { - if (enabledSubstitutions & ES6SubstitutionFlags.BlockScopedBindings) { + if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) { const declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration) { return getGeneratedNameForNode(declaration.name); @@ -3172,7 +3172,7 @@ namespace ts { * @param node The ThisKeyword node. */ function substituteThisKeyword(node: PrimaryExpression): PrimaryExpression { - if (enabledSubstitutions & ES6SubstitutionFlags.CapturedThis + if (enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis && enclosingFunction && getEmitFlags(enclosingFunction) & EmitFlags.CapturesThis) { return createIdentifier("_this", /*location*/ node); diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index f9e8b539c6a11..7800a41e147a3 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -263,7 +263,7 @@ namespace ts { function transformAsyncFunctionBody(node: FunctionLikeDeclaration): ConciseBody | FunctionBody { const nodeType = node.original ? (node.original).type : node.type; - const promiseConstructor = languageVersion < ScriptTarget.ES6 ? getPromiseConstructor(nodeType) : undefined; + const promiseConstructor = languageVersion < ScriptTarget.ES2015 ? getPromiseConstructor(nodeType) : undefined; const isArrowFunction = node.kind === SyntaxKind.ArrowFunction; const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; @@ -292,7 +292,7 @@ namespace ts { // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - if (languageVersion >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES2015) { if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) { enableSubstitutionForAsyncMethodsWithSuper(); setEmitFlags(block, EmitFlags.EmitAdvancedSuperHelper); diff --git a/src/compiler/transformers/module/es6.ts b/src/compiler/transformers/module/es2015.ts similarity index 96% rename from src/compiler/transformers/module/es6.ts rename to src/compiler/transformers/module/es2015.ts index 09a2890727c58..b06acd2d091b6 100644 --- a/src/compiler/transformers/module/es6.ts +++ b/src/compiler/transformers/module/es2015.ts @@ -3,7 +3,7 @@ /*@internal*/ namespace ts { - export function transformES6Module(context: TransformationContext) { + export function transformES2015Module(context: TransformationContext) { const compilerOptions = context.getCompilerOptions(); const resolver = context.getEmitResolver(); @@ -141,4 +141,4 @@ namespace ts { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 9051f375bf99f..989efbfd53fdb 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -416,7 +416,7 @@ namespace ts { ) ], /*location*/ undefined, - /*flags*/ languageVersion >= ScriptTarget.ES6 ? NodeFlags.Const : NodeFlags.None), + /*flags*/ languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None), /*location*/ node ) ); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 77ab6a6ca0e6b..868c371e00f01 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1777,7 +1777,7 @@ namespace ts { return createIdentifier("Number"); case SyntaxKind.SymbolKeyword: - return languageVersion < ScriptTarget.ES6 + return languageVersion < ScriptTarget.ES2015 ? getGlobalSymbolNameWithFallback() : createIdentifier("Symbol"); @@ -1843,7 +1843,7 @@ namespace ts { return createIdentifier("Array"); case TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < ScriptTarget.ES6 + return languageVersion < ScriptTarget.ES2015 ? getGlobalSymbolNameWithFallback() : createIdentifier("Symbol"); @@ -2592,7 +2592,7 @@ namespace ts { function isES6ExportedDeclaration(node: Node) { return isExternalModuleExport(node) - && moduleKind === ModuleKind.ES6; + && moduleKind === ModuleKind.ES2015; } /** diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index de710e74a4681..da356c0b4d327 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -26,12 +26,12 @@ "transformers/jsx.ts", "transformers/es2017.ts", "transformers/es2016.ts", - "transformers/es6.ts", + "transformers/es2015.ts", "transformers/generators.ts", "transformers/destructuring.ts", "transformers/module/module.ts", "transformers/module/system.ts", - "transformers/module/es6.ts", + "transformers/module/es2015.ts", "transformer.ts", "comments.ts", "sourcemap.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b89887cafa080..55200b2967695 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3123,8 +3123,8 @@ namespace ts { ContainsES2017 = 1 << 5, ES2016 = 1 << 6, ContainsES2016 = 1 << 7, - ES6 = 1 << 8, - ContainsES6 = 1 << 9, + ES2015 = 1 << 8, + ContainsES2015 = 1 << 9, DestructuringAssignment = 1 << 10, Generator = 1 << 11, ContainsGenerator = 1 << 12, @@ -3153,13 +3153,13 @@ namespace ts { AssertJsx = Jsx | ContainsJsx, AssertES2017 = ES2017 | ContainsES2017, AssertES2016 = ES2016 | ContainsES2016, - AssertES6 = ES6 | ContainsES6, + AssertES2015 = ES2015 | ContainsES2015, AssertGenerator = Generator | ContainsGenerator, // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - NodeExcludes = TypeScript | Jsx | ES2017 | ES2016 | ES6 | DestructuringAssignment | Generator | HasComputedFlags, + NodeExcludes = TypeScript | Jsx | ES2017 | ES2016 | ES2015 | DestructuringAssignment | Generator | HasComputedFlags, ArrowFunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, FunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsCapturedLexicalThis | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, ConstructorExcludes = NodeExcludes | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, @@ -3175,7 +3175,7 @@ namespace ts { // Masks // - Additional bitmasks TypeScriptClassSyntaxMask = ContainsParameterPropertyAssignments | ContainsPropertyInitializer | ContainsDecorators, - ES6FunctionSyntaxMask = ContainsCapturedLexicalThis | ContainsDefaultValueAssignments, + ES2015FunctionSyntaxMask = ContainsCapturedLexicalThis | ContainsDefaultValueAssignments, } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 92ce6ecc6a475..e10ab6a8add9c 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -337,7 +337,7 @@ namespace ts { export function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, languageVersion: ScriptTarget) { // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. - if (languageVersion < ScriptTarget.ES6 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + if (languageVersion < ScriptTarget.ES2015 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { return getQuotedEscapedLiteralText('"', node.text, '"'); } @@ -345,7 +345,7 @@ namespace ts { // the node's parent reference, then simply get the text as it was originally written. if (!nodeIsSynthesized(node) && node.parent) { const text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < ScriptTarget.ES6 && isBinaryOrOctalIntegerLiteral(node, text)) { + if (languageVersion < ScriptTarget.ES2015 && isBinaryOrOctalIntegerLiteral(node, text)) { return node.text; } return text; @@ -4146,7 +4146,7 @@ namespace ts { return "lib.es2017.d.ts"; case ScriptTarget.ES2016: return "lib.es2016.d.ts"; - case ScriptTarget.ES6: + case ScriptTarget.ES2015: return "lib.es2015.d.ts"; default: diff --git a/src/harness/harness.ts b/src/harness/harness.ts index c50f33a74c332..3b45d6d61e5f8 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -946,7 +946,7 @@ namespace Harness { return "lib.es2017.d.ts"; case ts.ScriptTarget.ES2016: return "lib.es2016.d.ts"; - case ts.ScriptTarget.ES6: + case ts.ScriptTarget.ES2015: return es2015DefaultLibFileName; default: diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index c8b90645ce24f..5d7a81d1a7447 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -28,12 +28,12 @@ "../compiler/transformers/jsx.ts", "../compiler/transformers/es2017.ts", "../compiler/transformers/es2016.ts", - "../compiler/transformers/es6.ts", + "../compiler/transformers/es2015.ts", "../compiler/transformers/generators.ts", "../compiler/transformers/destructuring.ts", "../compiler/transformers/module/module.ts", "../compiler/transformers/module/system.ts", - "../compiler/transformers/module/es6.ts", + "../compiler/transformers/module/es2015.ts", "../compiler/transformer.ts", "../compiler/comments.ts", "../compiler/sourcemap.ts", diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 3e1ac171216e0..b2f7d0c224d3d 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -1017,7 +1017,7 @@ import b = require("./moduleB"); const files = [f1, f2, f3, f4]; const names = map(files, f => f.name); - const sourceFiles = arrayToMap(map(files, f => createSourceFile(f.name, f.content, ScriptTarget.ES6)), f => f.fileName); + const sourceFiles = arrayToMap(map(files, f => createSourceFile(f.name, f.content, ScriptTarget.ES2015)), f => f.fileName); const compilerHost: CompilerHost = { fileExists : fileName => fileName in sourceFiles, getSourceFile: fileName => sourceFiles[fileName], diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 45e3c9036e0cd..c9428d9a0823a 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -27,12 +27,12 @@ "../compiler/transformers/jsx.ts", "../compiler/transformers/es2017.ts", "../compiler/transformers/es2016.ts", - "../compiler/transformers/es6.ts", + "../compiler/transformers/es2015.ts", "../compiler/transformers/generators.ts", "../compiler/transformers/destructuring.ts", "../compiler/transformers/module/module.ts", "../compiler/transformers/module/system.ts", - "../compiler/transformers/module/es6.ts", + "../compiler/transformers/module/es2015.ts", "../compiler/transformer.ts", "../compiler/comments.ts", "../compiler/sourcemap.ts", diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 829048fc08193..e61906b4f098f 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1339,7 +1339,7 @@ namespace ts { const options: TranspileOptions = { fileName: "config.js", compilerOptions: { - target: ScriptTarget.ES6, + target: ScriptTarget.ES2015, removeComments: true }, reportDiagnostics: true From 86784a5eef6c9d4e5fbb68e5c7a1eedfc23ed8a8 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Fri, 14 Oct 2016 10:54:54 +0200 Subject: [PATCH 12/13] Get rid of ES6 completely --- src/compiler/commandLineParser.ts | 4 ++-- src/compiler/types.ts | 6 ++---- tests/baselines/reference/APISample_linter.js | 4 ++-- tests/cases/compiler/APISample_linter.ts | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 553efa9e3af37..545c7f3e70871 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -101,7 +101,7 @@ namespace ts { "amd": ModuleKind.AMD, "system": ModuleKind.System, "umd": ModuleKind.UMD, - "es6": ModuleKind.ES6, + "es6": ModuleKind.ES2015, "es2015": ModuleKind.ES2015, }), description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, @@ -261,7 +261,7 @@ namespace ts { type: createMap({ "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, - "es6": ScriptTarget.ES6, + "es6": ScriptTarget.ES2015, "es2015": ScriptTarget.ES2015, "es2016": ScriptTarget.ES2016, "es2017": ScriptTarget.ES2017, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ae9502c21d2a7..68bda608238a9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3019,8 +3019,7 @@ namespace ts { AMD = 2, UMD = 3, System = 4, - ES6 = 5, - ES2015 = ES6, + ES2015 = 5, } export const enum JsxEmit { @@ -3053,8 +3052,7 @@ namespace ts { export const enum ScriptTarget { ES3 = 0, ES5 = 1, - ES6 = 2, - ES2015 = ES6, + ES2015 = 2, ES2016 = 3, ES2017 = 4, Latest = ES2017, diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 4e563c7cac336..1421b53a00caf 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -58,7 +58,7 @@ export function delint(sourceFile: ts.SourceFile) { const fileNames: string[] = process.argv.slice(2); fileNames.forEach(fileName => { // Parse a file - let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); + let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES2015, /*setParentNodes */ true); // delint it delint(sourceFile); @@ -113,7 +113,7 @@ exports.delint = delint; var fileNames = process.argv.slice(2); fileNames.forEach(function (fileName) { // Parse a file - var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); + var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES2015, /*setParentNodes */ true); // delint it delint(sourceFile); }); diff --git a/tests/cases/compiler/APISample_linter.ts b/tests/cases/compiler/APISample_linter.ts index 89f0be7a0f553..dc5e2644b4ff1 100644 --- a/tests/cases/compiler/APISample_linter.ts +++ b/tests/cases/compiler/APISample_linter.ts @@ -61,7 +61,7 @@ export function delint(sourceFile: ts.SourceFile) { const fileNames: string[] = process.argv.slice(2); fileNames.forEach(fileName => { // Parse a file - let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); + let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES2015, /*setParentNodes */ true); // delint it delint(sourceFile); From 7352e971215a07026c8f7ab7786ed2c9a900e70b Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Sat, 15 Oct 2016 01:16:11 +0200 Subject: [PATCH 13/13] Cleanup ES2017 async tests --- .../reference/asyncAliasReturnType_es2017.js | 9 --- .../asyncAliasReturnType_es2017.symbols | 11 ---- .../asyncAliasReturnType_es2017.types | 11 ---- .../reference/asyncClass_es2017.errors.txt | 8 --- .../baselines/reference/asyncClass_es2017.js | 7 -- .../asyncConstructor_es2017.errors.txt | 10 --- .../reference/asyncConstructor_es2017.js | 11 ---- .../reference/asyncDeclare_es2017.errors.txt | 7 -- .../reference/asyncDeclare_es2017.js | 4 -- .../reference/asyncEnum_es2017.errors.txt | 9 --- tests/baselines/reference/asyncEnum_es2017.js | 10 --- ...yncFunctionDeclaration15_es2017.errors.txt | 48 -------------- .../asyncFunctionDeclaration15_es2017.js | 64 ------------------- .../reference/asyncGetter_es2017.errors.txt | 13 ---- .../baselines/reference/asyncGetter_es2017.js | 11 ---- .../asyncImportedPromise_es2017.errors.txt | 13 ---- .../reference/asyncImportedPromise_es2017.js | 21 ------ .../asyncInterface_es2017.errors.txt | 8 --- .../reference/asyncInterface_es2017.js | 5 -- .../reference/asyncModule_es2017.errors.txt | 8 --- .../baselines/reference/asyncModule_es2017.js | 5 -- .../reference/asyncMultiFile_es2017.js | 11 ---- .../reference/asyncMultiFile_es2017.symbols | 8 --- .../reference/asyncMultiFile_es2017.types | 8 --- ...asyncQualifiedReturnType_es2017.errors.txt | 13 ---- .../asyncQualifiedReturnType_es2017.js | 18 ------ .../reference/asyncSetter_es2017.errors.txt | 10 --- .../baselines/reference/asyncSetter_es2017.js | 11 ---- .../baselines/reference/awaitUnion_es2017.js | 22 ------- .../reference/awaitUnion_es2017.symbols | 44 ------------- .../reference/awaitUnion_es2017.types | 49 -------------- tests/baselines/reference/es2017basicAsync.js | 4 +- .../reference/es2017basicAsync.symbols | 4 +- .../reference/es2017basicAsync.types | 4 +- tests/cases/compiler/es2017basicAsync.ts | 2 +- .../es2017/asyncAliasReturnType_es2017.ts | 6 -- .../async/es2017/asyncClass_es2017.ts | 4 -- .../async/es2017/asyncConstructor_es2017.ts | 6 -- .../async/es2017/asyncDeclare_es2017.ts | 3 - .../async/es2017/asyncEnum_es2017.ts | 5 -- .../async/es2017/asyncGetter_es2017.ts | 6 -- .../es2017/asyncImportedPromise_es2017.ts | 10 --- .../async/es2017/asyncInterface_es2017.ts | 4 -- .../async/es2017/asyncModule_es2017.ts | 4 -- .../async/es2017/asyncMultiFile_es2017.ts | 5 -- .../es2017/asyncQualifiedReturnType_es2017.ts | 9 --- .../async/es2017/asyncSetter_es2017.ts | 6 -- .../async/es2017/awaitUnion_es2017.ts | 14 ---- .../asyncFunctionDeclaration15_es2017.ts | 25 -------- 49 files changed, 7 insertions(+), 601 deletions(-) delete mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.js delete mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.symbols delete mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.types delete mode 100644 tests/baselines/reference/asyncClass_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncClass_es2017.js delete mode 100644 tests/baselines/reference/asyncConstructor_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncConstructor_es2017.js delete mode 100644 tests/baselines/reference/asyncDeclare_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncDeclare_es2017.js delete mode 100644 tests/baselines/reference/asyncEnum_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncEnum_es2017.js delete mode 100644 tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncFunctionDeclaration15_es2017.js delete mode 100644 tests/baselines/reference/asyncGetter_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncGetter_es2017.js delete mode 100644 tests/baselines/reference/asyncImportedPromise_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncImportedPromise_es2017.js delete mode 100644 tests/baselines/reference/asyncInterface_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncInterface_es2017.js delete mode 100644 tests/baselines/reference/asyncModule_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncModule_es2017.js delete mode 100644 tests/baselines/reference/asyncMultiFile_es2017.js delete mode 100644 tests/baselines/reference/asyncMultiFile_es2017.symbols delete mode 100644 tests/baselines/reference/asyncMultiFile_es2017.types delete mode 100644 tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncQualifiedReturnType_es2017.js delete mode 100644 tests/baselines/reference/asyncSetter_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncSetter_es2017.js delete mode 100644 tests/baselines/reference/awaitUnion_es2017.js delete mode 100644 tests/baselines/reference/awaitUnion_es2017.symbols delete mode 100644 tests/baselines/reference/awaitUnion_es2017.types delete mode 100644 tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncClass_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncEnum_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncGetter_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncInterface_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncModule_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncSetter_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/awaitUnion_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.js b/tests/baselines/reference/asyncAliasReturnType_es2017.js deleted file mode 100644 index f76f2b13b458b..0000000000000 --- a/tests/baselines/reference/asyncAliasReturnType_es2017.js +++ /dev/null @@ -1,9 +0,0 @@ -//// [asyncAliasReturnType_es2017.ts] -type PromiseAlias = Promise; - -async function f(): PromiseAlias { -} - -//// [asyncAliasReturnType_es2017.js] -async function f() { -} diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.symbols b/tests/baselines/reference/asyncAliasReturnType_es2017.symbols deleted file mode 100644 index cc4fc5b809627..0000000000000 --- a/tests/baselines/reference/asyncAliasReturnType_es2017.symbols +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts === -type PromiseAlias = Promise; ->PromiseAlias : Symbol(PromiseAlias, Decl(asyncAliasReturnType_es2017.ts, 0, 0)) ->T : Symbol(T, Decl(asyncAliasReturnType_es2017.ts, 0, 18)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->T : Symbol(T, Decl(asyncAliasReturnType_es2017.ts, 0, 18)) - -async function f(): PromiseAlias { ->f : Symbol(f, Decl(asyncAliasReturnType_es2017.ts, 0, 34)) ->PromiseAlias : Symbol(PromiseAlias, Decl(asyncAliasReturnType_es2017.ts, 0, 0)) -} diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.types b/tests/baselines/reference/asyncAliasReturnType_es2017.types deleted file mode 100644 index 67c521b77fa4b..0000000000000 --- a/tests/baselines/reference/asyncAliasReturnType_es2017.types +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts === -type PromiseAlias = Promise; ->PromiseAlias : Promise ->T : T ->Promise : Promise ->T : T - -async function f(): PromiseAlias { ->f : () => Promise ->PromiseAlias : Promise -} diff --git a/tests/baselines/reference/asyncClass_es2017.errors.txt b/tests/baselines/reference/asyncClass_es2017.errors.txt deleted file mode 100644 index 37612b0b0f2d2..0000000000000 --- a/tests/baselines/reference/asyncClass_es2017.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/async/es2017/asyncClass_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. - - -==== tests/cases/conformance/async/es2017/asyncClass_es2017.ts (1 errors) ==== - async class C { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncClass_es2017.js b/tests/baselines/reference/asyncClass_es2017.js deleted file mode 100644 index e619bd50b9735..0000000000000 --- a/tests/baselines/reference/asyncClass_es2017.js +++ /dev/null @@ -1,7 +0,0 @@ -//// [asyncClass_es2017.ts] -async class C { -} - -//// [asyncClass_es2017.js] -async class C { -} diff --git a/tests/baselines/reference/asyncConstructor_es2017.errors.txt b/tests/baselines/reference/asyncConstructor_es2017.errors.txt deleted file mode 100644 index 3b0c1b42fa90c..0000000000000 --- a/tests/baselines/reference/asyncConstructor_es2017.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts(2,3): error TS1089: 'async' modifier cannot appear on a constructor declaration. - - -==== tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts (1 errors) ==== - class C { - async constructor() { - ~~~~~ -!!! error TS1089: 'async' modifier cannot appear on a constructor declaration. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncConstructor_es2017.js b/tests/baselines/reference/asyncConstructor_es2017.js deleted file mode 100644 index 7dcd6ec694364..0000000000000 --- a/tests/baselines/reference/asyncConstructor_es2017.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [asyncConstructor_es2017.ts] -class C { - async constructor() { - } -} - -//// [asyncConstructor_es2017.js] -class C { - async constructor() { - } -} diff --git a/tests/baselines/reference/asyncDeclare_es2017.errors.txt b/tests/baselines/reference/asyncDeclare_es2017.errors.txt deleted file mode 100644 index bb74a3865d5c4..0000000000000 --- a/tests/baselines/reference/asyncDeclare_es2017.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts(1,9): error TS1040: 'async' modifier cannot be used in an ambient context. - - -==== tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts (1 errors) ==== - declare async function foo(): Promise; - ~~~~~ -!!! error TS1040: 'async' modifier cannot be used in an ambient context. \ No newline at end of file diff --git a/tests/baselines/reference/asyncDeclare_es2017.js b/tests/baselines/reference/asyncDeclare_es2017.js deleted file mode 100644 index 2ff588b285158..0000000000000 --- a/tests/baselines/reference/asyncDeclare_es2017.js +++ /dev/null @@ -1,4 +0,0 @@ -//// [asyncDeclare_es2017.ts] -declare async function foo(): Promise; - -//// [asyncDeclare_es2017.js] diff --git a/tests/baselines/reference/asyncEnum_es2017.errors.txt b/tests/baselines/reference/asyncEnum_es2017.errors.txt deleted file mode 100644 index 8e0015d0b24a0..0000000000000 --- a/tests/baselines/reference/asyncEnum_es2017.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/async/es2017/asyncEnum_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. - - -==== tests/cases/conformance/async/es2017/asyncEnum_es2017.ts (1 errors) ==== - async enum E { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - Value - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncEnum_es2017.js b/tests/baselines/reference/asyncEnum_es2017.js deleted file mode 100644 index df1f846c2f9af..0000000000000 --- a/tests/baselines/reference/asyncEnum_es2017.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [asyncEnum_es2017.ts] -async enum E { - Value -} - -//// [asyncEnum_es2017.js] -var E; -(function (E) { - E[E["Value"] = 0] = "Value"; -})(E || (E = {})); diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt deleted file mode 100644 index efc1e2440bf3a..0000000000000 --- a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt +++ /dev/null @@ -1,48 +0,0 @@ -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(6,23): error TS1064: The return type of an async function or method must be the global Promise type. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(7,23): error TS1064: The return type of an async function or method must be the global Promise type. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(8,23): error TS1064: The return type of an async function or method must be the global Promise type. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(9,23): error TS1064: The return type of an async function or method must be the global Promise type. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(10,23): error TS1064: The return type of an async function or method must be the global Promise type. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(17,16): error TS1059: Return expression in async function does not have a valid callable 'then' member. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(23,25): error TS1058: Operand for 'await' does not have a valid callable 'then' member. - - -==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts (7 errors) ==== - declare class Thenable { then(): void; } - declare let a: any; - declare let obj: { then: string; }; - declare let thenable: Thenable; - async function fn1() { } // valid: Promise - async function fn2(): { } { } // error - ~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - async function fn3(): any { } // error - ~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - async function fn4(): number { } // error - ~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - async function fn5(): PromiseLike { } // error - ~~~~~~~~~~~~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - async function fn6(): Thenable { } // error - ~~~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - async function fn7() { return; } // valid: Promise - async function fn8() { return 1; } // valid: Promise - async function fn9() { return null; } // valid: Promise - async function fn10() { return undefined; } // valid: Promise - async function fn11() { return a; } // valid: Promise - async function fn12() { return obj; } // valid: Promise<{ then: string; }> - async function fn13() { return thenable; } // error - ~~~~ -!!! error TS1059: Return expression in async function does not have a valid callable 'then' member. - async function fn14() { await 1; } // valid: Promise - async function fn15() { await null; } // valid: Promise - async function fn16() { await undefined; } // valid: Promise - async function fn17() { await a; } // valid: Promise - async function fn18() { await obj; } // valid: Promise - async function fn19() { await thenable; } // error - ~~~~~~~~~~~~~~ -!!! error TS1058: Operand for 'await' does not have a valid callable 'then' member. - \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js deleted file mode 100644 index 5704366025efe..0000000000000 --- a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js +++ /dev/null @@ -1,64 +0,0 @@ -//// [asyncFunctionDeclaration15_es2017.ts] -declare class Thenable { then(): void; } -declare let a: any; -declare let obj: { then: string; }; -declare let thenable: Thenable; -async function fn1() { } // valid: Promise -async function fn2(): { } { } // error -async function fn3(): any { } // error -async function fn4(): number { } // error -async function fn5(): PromiseLike { } // error -async function fn6(): Thenable { } // error -async function fn7() { return; } // valid: Promise -async function fn8() { return 1; } // valid: Promise -async function fn9() { return null; } // valid: Promise -async function fn10() { return undefined; } // valid: Promise -async function fn11() { return a; } // valid: Promise -async function fn12() { return obj; } // valid: Promise<{ then: string; }> -async function fn13() { return thenable; } // error -async function fn14() { await 1; } // valid: Promise -async function fn15() { await null; } // valid: Promise -async function fn16() { await undefined; } // valid: Promise -async function fn17() { await a; } // valid: Promise -async function fn18() { await obj; } // valid: Promise -async function fn19() { await thenable; } // error - - -//// [asyncFunctionDeclaration15_es2017.js] -async function fn1() { } // valid: Promise -// valid: Promise -async function fn2() { } // error -// error -async function fn3() { } // error -// error -async function fn4() { } // error -// error -async function fn5() { } // error -// error -async function fn6() { } // error -// error -async function fn7() { return; } // valid: Promise -// valid: Promise -async function fn8() { return 1; } // valid: Promise -// valid: Promise -async function fn9() { return null; } // valid: Promise -// valid: Promise -async function fn10() { return undefined; } // valid: Promise -// valid: Promise -async function fn11() { return a; } // valid: Promise -// valid: Promise -async function fn12() { return obj; } // valid: Promise<{ then: string; }> -// valid: Promise<{ then: string; }> -async function fn13() { return thenable; } // error -// error -async function fn14() { await 1; } // valid: Promise -// valid: Promise -async function fn15() { await null; } // valid: Promise -// valid: Promise -async function fn16() { await undefined; } // valid: Promise -// valid: Promise -async function fn17() { await a; } // valid: Promise -// valid: Promise -async function fn18() { await obj; } // valid: Promise -// valid: Promise -async function fn19() { await thenable; } // error diff --git a/tests/baselines/reference/asyncGetter_es2017.errors.txt b/tests/baselines/reference/asyncGetter_es2017.errors.txt deleted file mode 100644 index 386e95d59771d..0000000000000 --- a/tests/baselines/reference/asyncGetter_es2017.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/conformance/async/es2017/asyncGetter_es2017.ts(2,3): error TS1042: 'async' modifier cannot be used here. -tests/cases/conformance/async/es2017/asyncGetter_es2017.ts(2,13): error TS2378: A 'get' accessor must return a value. - - -==== tests/cases/conformance/async/es2017/asyncGetter_es2017.ts (2 errors) ==== - class C { - async get foo() { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - ~~~ -!!! error TS2378: A 'get' accessor must return a value. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncGetter_es2017.js b/tests/baselines/reference/asyncGetter_es2017.js deleted file mode 100644 index ad8fa347cb5ee..0000000000000 --- a/tests/baselines/reference/asyncGetter_es2017.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [asyncGetter_es2017.ts] -class C { - async get foo() { - } -} - -//// [asyncGetter_es2017.js] -class C { - async get foo() { - } -} diff --git a/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt b/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt deleted file mode 100644 index a0348b2e691a1..0000000000000 --- a/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/conformance/async/es2017/test.ts(3,25): error TS1064: The return type of an async function or method must be the global Promise type. - - -==== tests/cases/conformance/async/es2017/task.ts (0 errors) ==== - export class Task extends Promise { } - -==== tests/cases/conformance/async/es2017/test.ts (1 errors) ==== - import { Task } from "./task"; - class Test { - async example(): Task { return; } - ~~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncImportedPromise_es2017.js b/tests/baselines/reference/asyncImportedPromise_es2017.js deleted file mode 100644 index a48c58c17077a..0000000000000 --- a/tests/baselines/reference/asyncImportedPromise_es2017.js +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts] //// - -//// [task.ts] -export class Task extends Promise { } - -//// [test.ts] -import { Task } from "./task"; -class Test { - async example(): Task { return; } -} - -//// [task.js] -"use strict"; -class Task extends Promise { -} -exports.Task = Task; -//// [test.js] -"use strict"; -class Test { - async example() { return; } -} diff --git a/tests/baselines/reference/asyncInterface_es2017.errors.txt b/tests/baselines/reference/asyncInterface_es2017.errors.txt deleted file mode 100644 index dfbc87897972e..0000000000000 --- a/tests/baselines/reference/asyncInterface_es2017.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/async/es2017/asyncInterface_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. - - -==== tests/cases/conformance/async/es2017/asyncInterface_es2017.ts (1 errors) ==== - async interface I { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncInterface_es2017.js b/tests/baselines/reference/asyncInterface_es2017.js deleted file mode 100644 index 4d897389538e0..0000000000000 --- a/tests/baselines/reference/asyncInterface_es2017.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [asyncInterface_es2017.ts] -async interface I { -} - -//// [asyncInterface_es2017.js] diff --git a/tests/baselines/reference/asyncModule_es2017.errors.txt b/tests/baselines/reference/asyncModule_es2017.errors.txt deleted file mode 100644 index 8b6a4c3dc66af..0000000000000 --- a/tests/baselines/reference/asyncModule_es2017.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/async/es2017/asyncModule_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. - - -==== tests/cases/conformance/async/es2017/asyncModule_es2017.ts (1 errors) ==== - async module M { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncModule_es2017.js b/tests/baselines/reference/asyncModule_es2017.js deleted file mode 100644 index fe3e17d5e7410..0000000000000 --- a/tests/baselines/reference/asyncModule_es2017.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [asyncModule_es2017.ts] -async module M { -} - -//// [asyncModule_es2017.js] diff --git a/tests/baselines/reference/asyncMultiFile_es2017.js b/tests/baselines/reference/asyncMultiFile_es2017.js deleted file mode 100644 index 804a58e4b4c9b..0000000000000 --- a/tests/baselines/reference/asyncMultiFile_es2017.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts] //// - -//// [a.ts] -async function f() {} -//// [b.ts] -function g() { } - -//// [a.js] -async function f() { } -//// [b.js] -function g() { } diff --git a/tests/baselines/reference/asyncMultiFile_es2017.symbols b/tests/baselines/reference/asyncMultiFile_es2017.symbols deleted file mode 100644 index 9d8ff6dbe85c5..0000000000000 --- a/tests/baselines/reference/asyncMultiFile_es2017.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/conformance/async/es2017/a.ts === -async function f() {} ->f : Symbol(f, Decl(a.ts, 0, 0)) - -=== tests/cases/conformance/async/es2017/b.ts === -function g() { } ->g : Symbol(g, Decl(b.ts, 0, 0)) - diff --git a/tests/baselines/reference/asyncMultiFile_es2017.types b/tests/baselines/reference/asyncMultiFile_es2017.types deleted file mode 100644 index e1f8da34c94db..0000000000000 --- a/tests/baselines/reference/asyncMultiFile_es2017.types +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/conformance/async/es2017/a.ts === -async function f() {} ->f : () => Promise - -=== tests/cases/conformance/async/es2017/b.ts === -function g() { } ->g : () => void - diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt b/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt deleted file mode 100644 index b9027c365396c..0000000000000 --- a/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts(6,21): error TS1064: The return type of an async function or method must be the global Promise type. - - -==== tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts (1 errors) ==== - namespace X { - export class MyPromise extends Promise { - } - } - - async function f(): X.MyPromise { - ~~~~~~~~~~~~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es2017.js b/tests/baselines/reference/asyncQualifiedReturnType_es2017.js deleted file mode 100644 index 164a4fef61057..0000000000000 --- a/tests/baselines/reference/asyncQualifiedReturnType_es2017.js +++ /dev/null @@ -1,18 +0,0 @@ -//// [asyncQualifiedReturnType_es2017.ts] -namespace X { - export class MyPromise extends Promise { - } -} - -async function f(): X.MyPromise { -} - -//// [asyncQualifiedReturnType_es2017.js] -var X; -(function (X) { - class MyPromise extends Promise { - } - X.MyPromise = MyPromise; -})(X || (X = {})); -async function f() { -} diff --git a/tests/baselines/reference/asyncSetter_es2017.errors.txt b/tests/baselines/reference/asyncSetter_es2017.errors.txt deleted file mode 100644 index 0acd8538f2017..0000000000000 --- a/tests/baselines/reference/asyncSetter_es2017.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/conformance/async/es2017/asyncSetter_es2017.ts(2,3): error TS1042: 'async' modifier cannot be used here. - - -==== tests/cases/conformance/async/es2017/asyncSetter_es2017.ts (1 errors) ==== - class C { - async set foo(value) { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncSetter_es2017.js b/tests/baselines/reference/asyncSetter_es2017.js deleted file mode 100644 index 8260c5232a243..0000000000000 --- a/tests/baselines/reference/asyncSetter_es2017.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [asyncSetter_es2017.ts] -class C { - async set foo(value) { - } -} - -//// [asyncSetter_es2017.js] -class C { - async set foo(value) { - } -} diff --git a/tests/baselines/reference/awaitUnion_es2017.js b/tests/baselines/reference/awaitUnion_es2017.js deleted file mode 100644 index 12f8b95a65269..0000000000000 --- a/tests/baselines/reference/awaitUnion_es2017.js +++ /dev/null @@ -1,22 +0,0 @@ -//// [awaitUnion_es2017.ts] -declare let a: number | string; -declare let b: PromiseLike | PromiseLike; -declare let c: PromiseLike; -declare let d: number | PromiseLike; -declare let e: number | PromiseLike; -async function f() { - let await_a = await a; - let await_b = await b; - let await_c = await c; - let await_d = await d; - let await_e = await e; -} - -//// [awaitUnion_es2017.js] -async function f() { - let await_a = await a; - let await_b = await b; - let await_c = await c; - let await_d = await d; - let await_e = await e; -} diff --git a/tests/baselines/reference/awaitUnion_es2017.symbols b/tests/baselines/reference/awaitUnion_es2017.symbols deleted file mode 100644 index e70abce4f0b6f..0000000000000 --- a/tests/baselines/reference/awaitUnion_es2017.symbols +++ /dev/null @@ -1,44 +0,0 @@ -=== tests/cases/conformance/async/es2017/awaitUnion_es2017.ts === -declare let a: number | string; ->a : Symbol(a, Decl(awaitUnion_es2017.ts, 0, 11)) - -declare let b: PromiseLike | PromiseLike; ->b : Symbol(b, Decl(awaitUnion_es2017.ts, 1, 11)) ->PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) ->PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) - -declare let c: PromiseLike; ->c : Symbol(c, Decl(awaitUnion_es2017.ts, 2, 11)) ->PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) - -declare let d: number | PromiseLike; ->d : Symbol(d, Decl(awaitUnion_es2017.ts, 3, 11)) ->PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) - -declare let e: number | PromiseLike; ->e : Symbol(e, Decl(awaitUnion_es2017.ts, 4, 11)) ->PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) - -async function f() { ->f : Symbol(f, Decl(awaitUnion_es2017.ts, 4, 53)) - - let await_a = await a; ->await_a : Symbol(await_a, Decl(awaitUnion_es2017.ts, 6, 4)) ->a : Symbol(a, Decl(awaitUnion_es2017.ts, 0, 11)) - - let await_b = await b; ->await_b : Symbol(await_b, Decl(awaitUnion_es2017.ts, 7, 4)) ->b : Symbol(b, Decl(awaitUnion_es2017.ts, 1, 11)) - - let await_c = await c; ->await_c : Symbol(await_c, Decl(awaitUnion_es2017.ts, 8, 4)) ->c : Symbol(c, Decl(awaitUnion_es2017.ts, 2, 11)) - - let await_d = await d; ->await_d : Symbol(await_d, Decl(awaitUnion_es2017.ts, 9, 4)) ->d : Symbol(d, Decl(awaitUnion_es2017.ts, 3, 11)) - - let await_e = await e; ->await_e : Symbol(await_e, Decl(awaitUnion_es2017.ts, 10, 4)) ->e : Symbol(e, Decl(awaitUnion_es2017.ts, 4, 11)) -} diff --git a/tests/baselines/reference/awaitUnion_es2017.types b/tests/baselines/reference/awaitUnion_es2017.types deleted file mode 100644 index 58f8a4ec4b4aa..0000000000000 --- a/tests/baselines/reference/awaitUnion_es2017.types +++ /dev/null @@ -1,49 +0,0 @@ -=== tests/cases/conformance/async/es2017/awaitUnion_es2017.ts === -declare let a: number | string; ->a : string | number - -declare let b: PromiseLike | PromiseLike; ->b : PromiseLike | PromiseLike ->PromiseLike : PromiseLike ->PromiseLike : PromiseLike - -declare let c: PromiseLike; ->c : PromiseLike ->PromiseLike : PromiseLike - -declare let d: number | PromiseLike; ->d : number | PromiseLike ->PromiseLike : PromiseLike - -declare let e: number | PromiseLike; ->e : number | PromiseLike ->PromiseLike : PromiseLike - -async function f() { ->f : () => Promise - - let await_a = await a; ->await_a : string | number ->await a : string | number ->a : string | number - - let await_b = await b; ->await_b : string | number ->await b : string | number ->b : PromiseLike | PromiseLike - - let await_c = await c; ->await_c : string | number ->await c : string | number ->c : PromiseLike - - let await_d = await d; ->await_d : string | number ->await d : string | number ->d : number | PromiseLike - - let await_e = await e; ->await_e : string | number ->await e : string | number ->e : number | PromiseLike -} diff --git a/tests/baselines/reference/es2017basicAsync.js b/tests/baselines/reference/es2017basicAsync.js index b19eaa4b0ba0e..d0443c1899c70 100644 --- a/tests/baselines/reference/es2017basicAsync.js +++ b/tests/baselines/reference/es2017basicAsync.js @@ -8,7 +8,7 @@ async function asyncFunc() { await 0; } -const asycnArrowFunc = async (): Promise => { +const asyncArrowFunc = async (): Promise => { await 0; } @@ -54,7 +54,7 @@ async () => { async function asyncFunc() { await 0; } -const asycnArrowFunc = async () => { +const asyncArrowFunc = async () => { await 0; }; async function asyncIIFE() { diff --git a/tests/baselines/reference/es2017basicAsync.symbols b/tests/baselines/reference/es2017basicAsync.symbols index 75f4d2cfa761d..d79faf1502af2 100644 --- a/tests/baselines/reference/es2017basicAsync.symbols +++ b/tests/baselines/reference/es2017basicAsync.symbols @@ -12,8 +12,8 @@ async function asyncFunc() { await 0; } -const asycnArrowFunc = async (): Promise => { ->asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es2017basicAsync.ts, 9, 5)) +const asyncArrowFunc = async (): Promise => { +>asyncArrowFunc : Symbol(asyncArrowFunc, Decl(es2017basicAsync.ts, 9, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 0; diff --git a/tests/baselines/reference/es2017basicAsync.types b/tests/baselines/reference/es2017basicAsync.types index 71c2dbe50f312..30d19cb4dfe7f 100644 --- a/tests/baselines/reference/es2017basicAsync.types +++ b/tests/baselines/reference/es2017basicAsync.types @@ -17,8 +17,8 @@ async function asyncFunc() { >0 : 0 } -const asycnArrowFunc = async (): Promise => { ->asycnArrowFunc : () => Promise +const asyncArrowFunc = async (): Promise => { +>asyncArrowFunc : () => Promise >async (): Promise => { await 0;} : () => Promise >Promise : Promise diff --git a/tests/cases/compiler/es2017basicAsync.ts b/tests/cases/compiler/es2017basicAsync.ts index b13a5d29bc0c0..b08ee6a18ae55 100644 --- a/tests/cases/compiler/es2017basicAsync.ts +++ b/tests/cases/compiler/es2017basicAsync.ts @@ -10,7 +10,7 @@ async function asyncFunc() { await 0; } -const asycnArrowFunc = async (): Promise => { +const asyncArrowFunc = async (): Promise => { await 0; } diff --git a/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts b/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts deleted file mode 100644 index 87bbc42e1668c..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts +++ /dev/null @@ -1,6 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -type PromiseAlias = Promise; - -async function f(): PromiseAlias { -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncClass_es2017.ts b/tests/cases/conformance/async/es2017/asyncClass_es2017.ts deleted file mode 100644 index 78746c972d09e..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncClass_es2017.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -async class C { -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts b/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts deleted file mode 100644 index 874c0b99239d2..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts +++ /dev/null @@ -1,6 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -class C { - async constructor() { - } -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts b/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts deleted file mode 100644 index d7fd4888fed55..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts +++ /dev/null @@ -1,3 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -declare async function foo(): Promise; \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts b/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts deleted file mode 100644 index dc995206e847b..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -async enum E { - Value -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts b/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts deleted file mode 100644 index 340c33138cf52..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts +++ /dev/null @@ -1,6 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -class C { - async get foo() { - } -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts b/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts deleted file mode 100644 index 81f5b690edd47..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @target: es2017 -// @module: commonjs -// @filename: task.ts -export class Task extends Promise { } - -// @filename: test.ts -import { Task } from "./task"; -class Test { - async example(): Task { return; } -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts b/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts deleted file mode 100644 index 252730f9ff6f0..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -async interface I { -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncModule_es2017.ts b/tests/cases/conformance/async/es2017/asyncModule_es2017.ts deleted file mode 100644 index 7c577e27fb901..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncModule_es2017.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -async module M { -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts b/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts deleted file mode 100644 index 920bdfb8bdadb..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @target: es2017 -// @filename: a.ts -async function f() {} -// @filename: b.ts -function g() { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts b/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts deleted file mode 100644 index 95695168cea0f..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts +++ /dev/null @@ -1,9 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -namespace X { - export class MyPromise extends Promise { - } -} - -async function f(): X.MyPromise { -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts b/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts deleted file mode 100644 index 658c07d42e843..0000000000000 --- a/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts +++ /dev/null @@ -1,6 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -class C { - async set foo(value) { - } -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts b/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts deleted file mode 100644 index 493aa838ffec1..0000000000000 --- a/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts +++ /dev/null @@ -1,14 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -declare let a: number | string; -declare let b: PromiseLike | PromiseLike; -declare let c: PromiseLike; -declare let d: number | PromiseLike; -declare let e: number | PromiseLike; -async function f() { - let await_a = await a; - let await_b = await b; - let await_c = await c; - let await_d = await d; - let await_e = await e; -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts deleted file mode 100644 index 2585dc666f4fe..0000000000000 --- a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts +++ /dev/null @@ -1,25 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -declare class Thenable { then(): void; } -declare let a: any; -declare let obj: { then: string; }; -declare let thenable: Thenable; -async function fn1() { } // valid: Promise -async function fn2(): { } { } // error -async function fn3(): any { } // error -async function fn4(): number { } // error -async function fn5(): PromiseLike { } // error -async function fn6(): Thenable { } // error -async function fn7() { return; } // valid: Promise -async function fn8() { return 1; } // valid: Promise -async function fn9() { return null; } // valid: Promise -async function fn10() { return undefined; } // valid: Promise -async function fn11() { return a; } // valid: Promise -async function fn12() { return obj; } // valid: Promise<{ then: string; }> -async function fn13() { return thenable; } // error -async function fn14() { await 1; } // valid: Promise -async function fn15() { await null; } // valid: Promise -async function fn16() { await undefined; } // valid: Promise -async function fn17() { await a; } // valid: Promise -async function fn18() { await obj; } // valid: Promise -async function fn19() { await thenable; } // error