Rename strictOptionalProperties -> exactOptionalPropertyTypes and remove from strict family (#44626)

This commit is contained in:
Ryan Cavanaugh authored and GitHub committed 2021-06-17 15:12:19 -07:00
1 parent fad9122872
commit 5afe42e14e
88 files changed
+751 -1373

No files matched your search

+8 -8
View File
@@ -343,12 +343,12 @@ namespace ts {
const strictFunctionTypes = getStrictOptionValue(compilerOptions, "strictFunctionTypes");
const strictBindCallApply = getStrictOptionValue(compilerOptions, "strictBindCallApply");
const strictPropertyInitialization = getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
const strictOptionalProperties = getStrictOptionValue(compilerOptions, "strictOptionalProperties");
const noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
const noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
const useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
const keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral;
const exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes;
const checkBinaryExpression = createCheckBinaryExpression();
const emitResolver = createResolver();
@@ -740,7 +740,7 @@ namespace ts {
const undefinedType = createIntrinsicType(TypeFlags.Undefined, "undefined");
const undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(TypeFlags.Undefined, "undefined", ObjectFlags.ContainsWideningType);
const optionalType = createIntrinsicType(TypeFlags.Undefined, "undefined");
const missingType = strictOptionalProperties ? createIntrinsicType(TypeFlags.Undefined, "undefined") : undefinedType;
const missingType = exactOptionalPropertyTypes ? createIntrinsicType(TypeFlags.Undefined, "undefined") : undefinedType;
const nullType = createIntrinsicType(TypeFlags.Null, "null");
const nullWideningType = strictNullChecks ? nullType : createIntrinsicType(TypeFlags.Null, "null", ObjectFlags.ContainsWideningType);
const stringType = createIntrinsicType(TypeFlags.String, "string");
@@ -13886,7 +13886,7 @@ namespace ts {
if (includes & TypeFlags.AnyOrUnknown) {
return includes & TypeFlags.Any ? includes & TypeFlags.IncludesWildcard ? wildcardType : anyType : unknownType;
}
if (strictOptionalProperties && includes & TypeFlags.Undefined) {
if (exactOptionalPropertyTypes && includes & TypeFlags.Undefined) {
const missingIndex = binarySearch(typeSet, missingType, getTypeId, compareValues);
if (missingIndex >= 0 && containsType(typeSet, undefinedType)) {
orderedRemoveItemAt(typeSet, missingIndex);
@@ -20358,15 +20358,15 @@ namespace ts {
}
function removeMissingType(type: Type, isOptional: boolean) {
return strictOptionalProperties && isOptional ? removeType(type, missingType) : type;
return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type;
}
function containsMissingType(type: Type) {
return strictOptionalProperties && (type === missingType || type.flags & TypeFlags.Union && containsType((type as UnionType).types, missingType));
return exactOptionalPropertyTypes && (type === missingType || type.flags & TypeFlags.Union && containsType((type as UnionType).types, missingType));
}
function removeMissingOrUndefinedType(type: Type): Type {
return strictOptionalProperties ? removeType(type, missingType) : getTypeWithFacts(type, TypeFacts.NEUndefined);
return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, TypeFacts.NEUndefined);
}
/**
@@ -21752,7 +21752,7 @@ namespace ts {
}
function isTypeOrBaseIdenticalTo(s: Type, t: Type) {
return strictOptionalProperties && t === missingType ? s === t :
return exactOptionalPropertyTypes && t === missingType ? s === t :
(isTypeIdenticalTo(s, t) || !!(t.flags & TypeFlags.String && s.flags & TypeFlags.StringLiteral || t.flags & TypeFlags.Number && s.flags & TypeFlags.NumberLiteral));
}
@@ -26084,7 +26084,7 @@ namespace ts {
elementFlags.push(ElementFlags.Rest);
}
}
else if (strictOptionalProperties && e.kind === SyntaxKind.OmittedExpression) {
else if (exactOptionalPropertyTypes && e.kind === SyntaxKind.OmittedExpression) {
hasOmittedExpression = true;
elementTypes.push(missingType);
elementFlags.push(ElementFlags.Optional);
+7 -8
View File
@@ -648,14 +648,6 @@ namespace ts {
description: Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
defaultValueDescription: Diagnostics.false_unless_strict_is_set
},
{
name: "strictOptionalProperties",
type: "boolean",
affectsSemanticDiagnostics: true,
strictFlag: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Enable_strict_checking_of_optional_properties
},
{
name: "noImplicitThis",
type: "boolean",
@@ -700,6 +692,13 @@ namespace ts {
description: Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read,
defaultValueDescription: "false"
},
{
name: "exactOptionalPropertyTypes",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined
},
{
name: "noImplicitReturns",
type: "boolean",
+1 -1
View File
@@ -4853,7 +4853,7 @@
"category": "Message",
"code": 6242
},
"Enable strict checking of optional properties.": {
"Interpret optional property types as written, rather than adding 'undefined'.": {
"category": "Message",
"code": 6243
},
+2 -2
View File
@@ -3043,8 +3043,8 @@ namespace ts {
if (options.strictPropertyInitialization && !getStrictOptionValue(options, "strictNullChecks")) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
}
if (options.strictOptionalProperties && !getStrictOptionValue(options, "strictNullChecks")) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictOptionalProperties", "strictNullChecks");
if (options.exactOptionalPropertyTypes && !getStrictOptionValue(options, "strictNullChecks")) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "exactOptionalPropertyTypes", "strictNullChecks");
}
if (options.isolatedModules) {
+1 -1
View File
@@ -5972,6 +5972,7 @@ namespace ts {
downlevelIteration?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
exactOptionalPropertyTypes?: boolean;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
/*@internal*/generateCpuProfile?: string;
@@ -6046,7 +6047,6 @@ namespace ts {
strictBindCallApply?: boolean; // Always combine with strict property
strictNullChecks?: boolean; // Always combine with strict property
strictPropertyInitialization?: boolean; // Always combine with strict property
strictOptionalProperties?: boolean; // Always combine with strict property
stripInternal?: boolean;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
-1
View File
@@ -6098,7 +6098,6 @@ namespace ts {
| "strictFunctionTypes"
| "strictBindCallApply"
| "strictPropertyInitialization"
| "strictOptionalProperties"
| "alwaysStrict"
| "useUnknownInCatchVariables"
;