Adds an --experimentalThrowExpressions flag

This commit is contained in:
Ron Buckton 2017-09-27 14:22:11 -04:00
parent 043e7e9e02
commit 3a96b18910
6 changed files with 22 additions and 0 deletions

View File

@ -17179,6 +17179,10 @@ namespace ts {
}
function checkThrowExpression(node: ThrowExpression): Type {
if (!compilerOptions.experimentalThrowExpressions) {
error(node, Diagnostics.Experimental_support_for_throw_expressions_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalThrowExpressions_option_to_remove_this_warning);
}
checkExpression(node.expression);
return neverType;
}

View File

@ -433,6 +433,12 @@ namespace ts {
category: Diagnostics.Experimental_Options,
description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
},
{
name: "experimentalThrowExpressions",
type: "boolean",
category: Diagnostics.Experimental_Options,
description: Diagnostics.Enables_experimental_support_for_ECMAScript_Stage_2_throw_expressions
},
// Advanced
{

View File

@ -907,6 +907,10 @@
"category": "Error",
"code": 1328
},
"Experimental support for 'throw' expressions is a feature that is subject to change in a future release. Set the 'experimentalThrowExpressions' option to remove this warning.": {
"category": "Error",
"code": 1329
},
"Duplicate identifier '{0}'.": {
"category": "Error",
@ -3314,6 +3318,11 @@
"category": "Message",
"code": 6185
},
"Enables experimental support for ECMAScript Stage-2 'throw' expressions.": {
"category": "Message",
"code": 6186
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
"code": 7005

View File

@ -3658,6 +3658,7 @@ namespace ts {
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
experimentalDecorators?: boolean;
experimentalThrowExpressions?: boolean;
forceConsistentCasingInFileNames?: boolean;
/*@internal*/help?: boolean;
importHelpers?: boolean;

View File

@ -1,4 +1,5 @@
// @target: es2015
// @experimentalThrowExpressions: true
declare const condition: boolean;
const a = condition ? 1 : throw new Error();
const b = condition || throw new Error();

View File

@ -1,4 +1,5 @@
// @target: esnext
// @experimentalThrowExpressions: true
declare const condition: boolean;
const a = condition ? 1 : throw new Error();
const b = condition || throw new Error();