mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Added experiment flag.
This commit is contained in:
@@ -13183,6 +13183,10 @@ namespace ts {
|
||||
|
||||
function checkPropertyAccessExpressionOrQualifiedName(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, right: Identifier) {
|
||||
const propagateNull = node.flags & NodeFlags.PropagateNull;
|
||||
if (propagateNull && !compilerOptions.experimentalNullPropagation) {
|
||||
error(node, Diagnostics.Experimental_support_for_null_propagation_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalNullPropagation_option_to_remove_this_warning);
|
||||
}
|
||||
|
||||
const objectType = propagateNull ? checkExpression(left) : checkNonNullExpression(left);
|
||||
const type = propagateNull ? getNonNullableType(objectType) : objectType;
|
||||
const propagatingType = propagateNull ? getNullPropagatingType(objectType) : neverType;
|
||||
@@ -13310,6 +13314,10 @@ namespace ts {
|
||||
checkGrammarNullPropagation(node);
|
||||
|
||||
const propagateNull = node.flags & NodeFlags.PropagateNull;
|
||||
if (propagateNull && !compilerOptions.experimentalNullPropagation) {
|
||||
error(node, Diagnostics.Experimental_support_for_null_propagation_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalNullPropagation_option_to_remove_this_warning);
|
||||
}
|
||||
|
||||
const objectType = propagateNull ? checkExpression(node.expression) : checkNonNullExpression(node.expression);
|
||||
const type = propagateNull ? getNonNullableType(objectType) : objectType;
|
||||
const propagatingType = propagateNull ? getNullPropagatingType(objectType) : neverType;
|
||||
@@ -14344,6 +14352,10 @@ namespace ts {
|
||||
|
||||
|
||||
const propagateNull = node.flags & NodeFlags.PropagateNull;
|
||||
if (propagateNull && !compilerOptions.experimentalNullPropagation) {
|
||||
error(node, Diagnostics.Experimental_support_for_null_propagation_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalNullPropagation_option_to_remove_this_warning);
|
||||
}
|
||||
|
||||
const funcType = propagateNull ? checkExpression(node.expression) : checkNonNullExpression(node.expression);
|
||||
const type = propagateNull ? getNonNullableType(funcType) : funcType;
|
||||
if (type === silentNeverType) {
|
||||
@@ -14423,6 +14435,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
const propagateNull = node.flags & NodeFlags.PropagateNull;
|
||||
if (propagateNull && !compilerOptions.experimentalNullPropagation) {
|
||||
error(node, Diagnostics.Experimental_support_for_null_propagation_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalNullPropagation_option_to_remove_this_warning);
|
||||
}
|
||||
|
||||
const funcType = propagateNull ? checkExpression(node.expression) : checkNonNullExpression(node.expression);
|
||||
const type = propagateNull ? getNonNullableType(funcType) : funcType;
|
||||
if (type === silentNeverType) {
|
||||
|
||||
@@ -299,6 +299,12 @@ namespace ts {
|
||||
experimental: true,
|
||||
description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
|
||||
},
|
||||
{
|
||||
name: "experimentalNullPropagation",
|
||||
type: "boolean",
|
||||
experimental: true,
|
||||
description: Diagnostics.Enables_experimental_support_for_null_propagation
|
||||
},
|
||||
{
|
||||
name: "moduleResolution",
|
||||
type: createMapFromTemplate({
|
||||
|
||||
@@ -827,6 +827,10 @@
|
||||
"category": "Error",
|
||||
"code": 1254
|
||||
},
|
||||
"Experimental support for null propagation is a feature that is subject to change in a future release. Set the 'experimentalNullPropagation' option to remove this warning.": {
|
||||
"category": "Error",
|
||||
"code": 1255
|
||||
},
|
||||
"'with' statements are not allowed in an async function block.": {
|
||||
"category": "Error",
|
||||
"code": 1300
|
||||
@@ -2721,10 +2725,6 @@
|
||||
"category": "Message",
|
||||
"code": 6066
|
||||
},
|
||||
"Enables experimental support for ES7 async functions.": {
|
||||
"category": "Message",
|
||||
"code": 6068
|
||||
},
|
||||
"Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6).": {
|
||||
"category": "Message",
|
||||
"code": 6069
|
||||
@@ -3045,6 +3045,10 @@
|
||||
"category": "Message",
|
||||
"code": 6149
|
||||
},
|
||||
"Enables experimental support for 'null propagation'.": {
|
||||
"category": "Message",
|
||||
"code": 6150
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
||||
@@ -986,6 +986,14 @@ namespace ts {
|
||||
const typeAssertionExpression = <TypeAssertion>node;
|
||||
diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file));
|
||||
return;
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
if (node.flags & NodeFlags.PropagateNull && !options.experimentalNullPropagation) {
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.Experimental_support_for_null_propagation_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalNullPropagation_option_to_remove_this_warning));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
const prevParent = parent;
|
||||
|
||||
@@ -3294,6 +3294,7 @@
|
||||
emitBOM?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
experimentalNullPropagation?: boolean;
|
||||
forceConsistentCasingInFileNames?: boolean;
|
||||
/*@internal*/help?: boolean;
|
||||
importHelpers?: boolean;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @lib: esnext
|
||||
// @module: commonjs
|
||||
// @experimentalDecorators: true
|
||||
// @experimentalNullPropagation: true
|
||||
// @filename: declarations.d.ts
|
||||
declare var x: any;
|
||||
declare var y: any;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @lib: esnext
|
||||
// @module: commonjs
|
||||
// @experimentalDecorators: true
|
||||
// @experimentalNullPropagation: true
|
||||
// @filename: declarations.d.ts
|
||||
declare var x: any;
|
||||
declare var y: any;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @lib: esnext
|
||||
// @module: commonjs
|
||||
// @experimentalDecorators: true
|
||||
// @experimentalNullPropagation: true
|
||||
// @filename: declarations.d.ts
|
||||
declare var x: any;
|
||||
declare var y: any;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @lib: esnext
|
||||
// @module: commonjs
|
||||
// @experimentalDecorators: true
|
||||
// @experimentalNullPropagation: true
|
||||
// @filename: declarations.d.ts
|
||||
declare var x: any;
|
||||
declare var y: any;
|
||||
|
||||
+1
@@ -3,6 +3,7 @@
|
||||
// @noEmit: true
|
||||
// @module: commonjs
|
||||
// @experimentalDecorators: true
|
||||
// @experimentalNullPropagation: true
|
||||
// @filename: declarations.d.ts
|
||||
declare var x: any;
|
||||
declare var y: any;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// @noEmit: true
|
||||
// @module: commonjs
|
||||
// @strictNullChecks: false
|
||||
// @experimentalNullPropagation: true
|
||||
declare const x1: (() => number) | undefined | null;
|
||||
declare const x2: { y: (() => number) | undefined | null; };
|
||||
declare const x3: { y: (() => number) | undefined | null; } | undefined | null;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// @noEmit: true
|
||||
// @module: commonjs
|
||||
// @strictNullChecks: true
|
||||
// @experimentalNullPropagation: true
|
||||
declare const x1: (() => number) | undefined | null;
|
||||
declare const x2: { y: (() => number) | undefined | null; };
|
||||
declare const x3: { y: (() => number) | undefined | null; } | undefined | null;
|
||||
|
||||
Reference in New Issue
Block a user