Moved async functions for ES6 behind experimental flag

This commit is contained in:
Ron Buckton
2015-06-19 18:05:43 -07:00
parent 5b32903ab4
commit 76c0d32f9d
57 changed files with 85 additions and 1 deletions
+4
View File
@@ -9863,6 +9863,10 @@ namespace ts {
checkSignatureDeclaration(node);
let isAsync = isAsyncFunctionLike(node);
if (isAsync) {
if (!compilerOptions.experimentalAsyncFunctions) {
error(node, Diagnostics.Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning);
}
emitAwaiter = true;
}
+5
View File
@@ -192,6 +192,11 @@ namespace ts {
type: "boolean",
description: Diagnostics.Watch_input_files,
},
{
name: "experimentalAsyncFunctions",
type: "boolean",
description: Diagnostics.Enables_experimental_support_for_ES7_async_functions
},
{
name: "experimentalDecorators",
type: "boolean",
@@ -201,6 +201,7 @@ namespace ts {
An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: DiagnosticCategory.Error, key: "An export declaration can only be used in a module." },
An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." },
A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." },
Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." },
with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." },
await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." },
Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." },
@@ -547,6 +548,8 @@ namespace ts {
Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." },
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." },
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." },
Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
+12
View File
@@ -791,6 +791,10 @@
"category": "Error",
"code": 1235
},
"Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning.": {
"category": "Error",
"code": 1236
},
"'with' statements are not allowed in an async function block.": {
@@ -2180,6 +2184,14 @@
"category": "Message",
"code": 6066
},
"Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower.": {
"category": "Message",
"code": 6067
},
"Enables experimental support for ES7 async functions.": {
"category": "Message",
"code": 6068
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
+6 -1
View File
@@ -144,7 +144,7 @@ namespace ts {
let program: Program;
let files: SourceFile[] = [];
let diagnostics = createDiagnosticCollection();
let commonSourceDirectory: string;
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;
@@ -676,6 +676,11 @@ namespace ts {
!options.experimentalDecorators) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified));
}
if (options.experimentalAsyncFunctions &&
options.target !== ScriptTarget.ES6) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
}
}
}
}
+1
View File
@@ -1878,6 +1878,7 @@ namespace ts {
watch?: boolean;
isolatedModules?: boolean;
experimentalDecorators?: boolean;
experimentalAsyncFunctions?: boolean;
emitDecoratorMetadata?: boolean;
/* @internal */ stripInternal?: boolean;
+4
View File
@@ -1055,6 +1055,10 @@ module Harness {
case 'emitdecoratormetadata':
options.emitDecoratorMetadata = setting.value === 'true';
break;
case 'experimentalasyncfunctions':
options.experimentalAsyncFunctions = setting.value === 'true';
break;
case 'noemithelpers':
options.noEmitHelpers = setting.value === 'true';
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
var foo = async foo(): Promise<void> => {
// Legal to use 'await' in a type context.
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
var foo = async (): Promise<void> => {
};
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
var f = (await) => {
}
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
function f(await = await) {
}
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
var await = () => {
}
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
var foo = async (await): Promise<void> => {
}
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
var foo = async (a = await): Promise<void> => {
}
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
var bar = async (): Promise<void> => {
// 'await' here is an identifier, and not an await expression.
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
var foo = async (): Promise<void> => {
var v = { [await]: foo }
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
var foo = async (a = await => await): Promise<void> => {
}
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
class C {
method() {
function other() {}
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
class C {
method() {
var fn = async () => await this;
@@ -1,5 +1,6 @@
// @target: ES6
// @isolatedModules: true
// @experimentalAsyncFunctions: true
import { MyPromise } from "missing";
declare var p: Promise<number>;
@@ -1,4 +1,5 @@
// @target: ES6
// @experimentalAsyncFunctions: true
type MyPromise<T> = Promise<T>;
declare var MyPromise: typeof Promise;
declare var p: Promise<number>;
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async class C {
}
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
class C {
async constructor() {
}
@@ -1,3 +1,4 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare async function foo(): Promise<void>;
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async enum E {
Value
}
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
class C {
async get foo() {
}
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async interface I {
}
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async module M {
}
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
class C {
async set foo(value) {
}
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
async function func(): Promise<void> {
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
async function func(): Promise<void> {
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: number;
declare var p: Promise<number>;
async function func(): Promise<void> {
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
async function func(): Promise<void> {
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
async function func(): Promise<void> {
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare var a: boolean;
declare var p: Promise<boolean>;
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
declare let a: number | string;
declare let b: PromiseLike<number> | PromiseLike<string>;
declare let c: PromiseLike<number | string>;
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async function foo(a = await => await): Promise<void> {
}
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async function await(): Promise<void> {
}
@@ -1,3 +1,4 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
var v = async function await(): Promise<void> { }
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async function foo(): Promise<void> {
// Legal to use 'await' in a type context.
var v: await;
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async function foo(): Promise<void> {
return;
}
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async function foo(): Promise<void> {
}
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
function f(await) {
}
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
function f(await = await) {
}
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
function await() {
}
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async function foo(await): Promise<void> {
}
@@ -1,4 +1,5 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async function foo(a = await): Promise<void> {
}
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async function bar(): Promise<void> {
// 'await' here is an identifier, and not a yield expression.
async function foo(a = await): Promise<void> {
@@ -1,3 +1,4 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
var v = { [await]: foo }
@@ -1,5 +1,6 @@
// @target: ES6
// @noEmitHelpers: true
// @experimentalAsyncFunctions: true
async function foo(): Promise<void> {
var v = { [await]: foo }
}