diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index 067b0e000309c..d24b629e51b01 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -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();
@@ -739,7 +739,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");
@@ -13884,7 +13884,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);
@@ -20356,15 +20356,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);
}
/**
@@ -21750,7 +21750,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));
}
@@ -26079,7 +26079,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);
diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts
index e9ac5fa8011f7..08215b5bcfe8a 100644
--- a/src/compiler/commandLineParser.ts
+++ b/src/compiler/commandLineParser.ts
@@ -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",
diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json
index c7dd23fb11e57..3298b57061e96 100644
--- a/src/compiler/diagnosticMessages.json
+++ b/src/compiler/diagnosticMessages.json
@@ -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
},
diff --git a/src/compiler/program.ts b/src/compiler/program.ts
index c7a259b92cb1f..ff4de30607a61 100644
--- a/src/compiler/program.ts
+++ b/src/compiler/program.ts
@@ -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) {
diff --git a/src/compiler/types.ts b/src/compiler/types.ts
index 6379c8a558b99..be7b9c70a2841 100644
--- a/src/compiler/types.ts
+++ b/src/compiler/types.ts
@@ -5971,6 +5971,7 @@ namespace ts {
downlevelIteration?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
+ exactOptionalPropertyTypes?: boolean;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
/*@internal*/generateCpuProfile?: string;
@@ -6045,7 +6046,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;
diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts
index 83ee8d9da3606..52377e1f3dc26 100644
--- a/src/compiler/utilities.ts
+++ b/src/compiler/utilities.ts
@@ -6086,7 +6086,6 @@ namespace ts {
| "strictFunctionTypes"
| "strictBindCallApply"
| "strictPropertyInitialization"
- | "strictOptionalProperties"
| "alwaysStrict"
| "useUnknownInCatchVariables"
;
diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts
index 4289acd54ebc1..c1621a6358e0a 100644
--- a/tests/baselines/reference/api/tsserverlibrary.d.ts
+++ b/tests/baselines/reference/api/tsserverlibrary.d.ts
@@ -2853,6 +2853,7 @@ declare namespace ts {
downlevelIteration?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
+ exactOptionalPropertyTypes?: boolean;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
importHelpers?: boolean;
@@ -2913,7 +2914,6 @@ declare namespace ts {
strictBindCallApply?: boolean;
strictNullChecks?: boolean;
strictPropertyInitialization?: boolean;
- strictOptionalProperties?: boolean;
stripInternal?: boolean;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts
index d3afe0978cf70..a39955570cdf6 100644
--- a/tests/baselines/reference/api/typescript.d.ts
+++ b/tests/baselines/reference/api/typescript.d.ts
@@ -2853,6 +2853,7 @@ declare namespace ts {
downlevelIteration?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
+ exactOptionalPropertyTypes?: boolean;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
importHelpers?: boolean;
@@ -2913,7 +2914,6 @@ declare namespace ts {
strictBindCallApply?: boolean;
strictNullChecks?: boolean;
strictPropertyInitialization?: boolean;
- strictOptionalProperties?: boolean;
stripInternal?: boolean;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
diff --git a/tests/baselines/reference/checkJsxIntersectionElementPropsType.types b/tests/baselines/reference/checkJsxIntersectionElementPropsType.types
index efaa22d38c6e4..187d0f274a409 100644
--- a/tests/baselines/reference/checkJsxIntersectionElementPropsType.types
+++ b/tests/baselines/reference/checkJsxIntersectionElementPropsType.types
@@ -16,7 +16,7 @@ declare class Component
{
class C extends Component<{ x?: boolean; } & T> {}
>C : C
->Component : Component<{ x?: boolean; } & T>
+>Component : Component<{ x?: boolean | undefined; } & T>
>x : boolean | undefined
const y = new C({foobar: "example"});
diff --git a/tests/baselines/reference/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.types b/tests/baselines/reference/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.types
index 8f5250d3e4789..babef6106a169 100644
--- a/tests/baselines/reference/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.types
+++ b/tests/baselines/reference/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.types
@@ -10,7 +10,7 @@ declare class Component {
>context : any
readonly props: Readonly
& Readonly<{ children?: {} }>;
->props : Readonly
& Readonly<{ children?: {}; }>
+>props : Readonly
& Readonly<{ children?: {} | undefined; }>
>children : {} | undefined
}
interface ComponentClass
{
@@ -29,7 +29,7 @@ interface ComponentClass
{
}
interface FunctionComponent
{
(props: P & { children?: {} }, context?: any): {} | null;
->props : P & { children?: {}; }
+>props : P & { children?: {} | undefined; }
>children : {} | undefined
>context : any
>null : null
diff --git a/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types b/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types
index b49c5d763304c..db65878b320d3 100644
--- a/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types
+++ b/tests/baselines/reference/contextuallyTypedParametersWithInitializers.types
@@ -16,7 +16,7 @@ declare function id3 any>(input: T): T;
declare function id4 any>(input: T): T;
>id4 : any>(input: T) => T
->x : { foo?: number; }
+>x : { foo?: number | undefined; }
>foo : number | undefined
>input : T
@@ -60,10 +60,10 @@ const f13 = id3(function ({ foo = 42 }) { return foo });
>foo : any
const f14 = id4(function ({ foo = 42 }) { return foo });
->f14 : ({ foo }: { foo?: number; }) => number
->id4(function ({ foo = 42 }) { return foo }) : ({ foo }: { foo?: number; }) => number
->id4 : any>(input: T) => T
->function ({ foo = 42 }) { return foo } : ({ foo }: { foo?: number; }) => number
+>f14 : ({ foo }: { foo?: number | undefined; }) => number
+>id4(function ({ foo = 42 }) { return foo }) : ({ foo }: { foo?: number | undefined; }) => number
+>id4 : any>(input: T) => T
+>function ({ foo = 42 }) { return foo } : ({ foo }: { foo?: number | undefined; }) => number
>foo : number
>42 : 42
>foo : number
diff --git a/tests/baselines/reference/controlFlowOptionalChain.types b/tests/baselines/reference/controlFlowOptionalChain.types
index 4fc4faf8fce59..4e335fca6d287 100644
--- a/tests/baselines/reference/controlFlowOptionalChain.types
+++ b/tests/baselines/reference/controlFlowOptionalChain.types
@@ -249,256 +249,256 @@ o3.x;
>x : 1 | 2
declare const o4: { x?: { y: boolean } };
->o4 : { x?: { y: boolean;}; }
+>o4 : { x?: { y: boolean; } | undefined; }
>x : { y: boolean; } | undefined
>y : boolean
if (o4.x?.y) {
>o4.x?.y : boolean | undefined
>o4.x : { y: boolean; } | undefined
->o4 : { x?: { y: boolean; }; }
+>o4 : { x?: { y: boolean; } | undefined; }
>x : { y: boolean; } | undefined
>y : boolean | undefined
o4.x; // { y: boolean }
>o4.x : { y: boolean; }
->o4 : { x?: { y: boolean; }; }
+>o4 : { x?: { y: boolean; } | undefined; }
>x : { y: boolean; }
o4.x.y; // true
>o4.x.y : true
>o4.x : { y: boolean; }
->o4 : { x?: { y: boolean; }; }
+>o4 : { x?: { y: boolean; } | undefined; }
>x : { y: boolean; }
>y : true
o4.x?.y; // true
>o4.x?.y : true
>o4.x : { y: boolean; }
->o4 : { x?: { y: boolean; }; }
+>o4 : { x?: { y: boolean; } | undefined; }
>x : { y: boolean; }
>y : true
}
else {
o4.x;
>o4.x : { y: boolean; } | undefined
->o4 : { x?: { y: boolean; }; }
+>o4 : { x?: { y: boolean; } | undefined; }
>x : { y: boolean; } | undefined
o4.x?.y;
>o4.x?.y : boolean | undefined
>o4.x : { y: boolean; } | undefined
->o4 : { x?: { y: boolean; }; }
+>o4 : { x?: { y: boolean; } | undefined; }
>x : { y: boolean; } | undefined
>y : boolean | undefined
o4.x.y;
>o4.x.y : boolean
>o4.x : { y: boolean; } | undefined
->o4 : { x?: { y: boolean; }; }
+>o4 : { x?: { y: boolean; } | undefined; }
>x : { y: boolean; } | undefined
>y : boolean
}
o4.x;
>o4.x : { y: boolean; } | undefined
->o4 : { x?: { y: boolean; }; }
+>o4 : { x?: { y: boolean; } | undefined; }
>x : { y: boolean; } | undefined
o4.x?.y;
>o4.x?.y : boolean | undefined
>o4.x : { y: boolean; } | undefined
->o4 : { x?: { y: boolean; }; }
+>o4 : { x?: { y: boolean; } | undefined; }
>x : { y: boolean; } | undefined
>y : boolean | undefined
o4.x.y;
>o4.x.y : boolean
>o4.x : { y: boolean; } | undefined
->o4 : { x?: { y: boolean; }; }
+>o4 : { x?: { y: boolean; } | undefined; }
>x : { y: boolean; } | undefined
>y : boolean
declare const o5: { x?: { y: { z?: { w: boolean } } } };
->o5 : { x?: { y: { z?: { w: boolean; }; };}; }
+>o5 : { x?: { y: { z?: { w: boolean; };}; } | undefined; }
>x : { y: { z?: { w: boolean; };}; } | undefined
->y : { z?: { w: boolean;}; }
+>y : { z?: { w: boolean; } | undefined; }
>z : { w: boolean; } | undefined
>w : boolean
if (o5.x?.y.z?.w) {
>o5.x?.y.z?.w : boolean | undefined
>o5.x?.y.z : { w: boolean; } | undefined
->o5.x?.y : { z?: { w: boolean; }; } | undefined
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
->y : { z?: { w: boolean; }; } | undefined
+>o5.x?.y : { z?: { w: boolean; } | undefined; } | undefined
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>y : { z?: { w: boolean; } | undefined; } | undefined
>z : { w: boolean; } | undefined
>w : boolean | undefined
o5.x;
->o5.x : { y: { z?: { w: boolean; }; }; }
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; }
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; }
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; }
o5.x.y;
->o5.x.y : { z?: { w: boolean; }; }
->o5.x : { y: { z?: { w: boolean; }; }; }
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; }
->y : { z?: { w: boolean; }; }
+>o5.x.y : { z?: { w: boolean; } | undefined; }
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; }
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; }
+>y : { z?: { w: boolean; } | undefined; }
o5.x.y.z;
>o5.x.y.z : { w: boolean; }
->o5.x.y : { z?: { w: boolean; }; }
->o5.x : { y: { z?: { w: boolean; }; }; }
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; }
->y : { z?: { w: boolean; }; }
+>o5.x.y : { z?: { w: boolean; } | undefined; }
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; }
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; }
+>y : { z?: { w: boolean; } | undefined; }
>z : { w: boolean; }
o5.x.y.z.w; // true
>o5.x.y.z.w : true
>o5.x.y.z : { w: boolean; }
->o5.x.y : { z?: { w: boolean; }; }
->o5.x : { y: { z?: { w: boolean; }; }; }
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; }
->y : { z?: { w: boolean; }; }
+>o5.x.y : { z?: { w: boolean; } | undefined; }
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; }
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; }
+>y : { z?: { w: boolean; } | undefined; }
>z : { w: boolean; }
>w : true
o5.x.y.z?.w; // true
>o5.x.y.z?.w : true
>o5.x.y.z : { w: boolean; }
->o5.x.y : { z?: { w: boolean; }; }
->o5.x : { y: { z?: { w: boolean; }; }; }
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; }
->y : { z?: { w: boolean; }; }
+>o5.x.y : { z?: { w: boolean; } | undefined; }
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; }
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; }
+>y : { z?: { w: boolean; } | undefined; }
>z : { w: boolean; }
>w : true
o5.x?.y.z.w; // true
>o5.x?.y.z.w : true
>o5.x?.y.z : { w: boolean; }
->o5.x?.y : { z?: { w: boolean; }; }
->o5.x : { y: { z?: { w: boolean; }; }; }
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; }
->y : { z?: { w: boolean; }; }
+>o5.x?.y : { z?: { w: boolean; } | undefined; }
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; }
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; }
+>y : { z?: { w: boolean; } | undefined; }
>z : { w: boolean; }
>w : true
o5.x?.y.z?.w; // true
>o5.x?.y.z?.w : true
>o5.x?.y.z : { w: boolean; }
->o5.x?.y : { z?: { w: boolean; }; }
->o5.x : { y: { z?: { w: boolean; }; }; }
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; }
->y : { z?: { w: boolean; }; }
+>o5.x?.y : { z?: { w: boolean; } | undefined; }
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; }
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; }
+>y : { z?: { w: boolean; } | undefined; }
>z : { w: boolean; }
>w : true
}
else {
o5.x;
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
o5.x?.y;
->o5.x?.y : { z?: { w: boolean; }; } | undefined
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
->y : { z?: { w: boolean; }; } | undefined
+>o5.x?.y : { z?: { w: boolean; } | undefined; } | undefined
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>y : { z?: { w: boolean; } | undefined; } | undefined
o5.x?.y.z;
>o5.x?.y.z : { w: boolean; } | undefined
->o5.x?.y : { z?: { w: boolean; }; } | undefined
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
->y : { z?: { w: boolean; }; } | undefined
+>o5.x?.y : { z?: { w: boolean; } | undefined; } | undefined
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>y : { z?: { w: boolean; } | undefined; } | undefined
>z : { w: boolean; } | undefined
o5.x?.y.z?.w;
>o5.x?.y.z?.w : boolean | undefined
>o5.x?.y.z : { w: boolean; } | undefined
->o5.x?.y : { z?: { w: boolean; }; } | undefined
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
->y : { z?: { w: boolean; }; } | undefined
+>o5.x?.y : { z?: { w: boolean; } | undefined; } | undefined
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>y : { z?: { w: boolean; } | undefined; } | undefined
>z : { w: boolean; } | undefined
>w : boolean | undefined
o5.x.y;
->o5.x.y : { z?: { w: boolean; }; }
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
->y : { z?: { w: boolean; }; }
+>o5.x.y : { z?: { w: boolean; } | undefined; }
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>y : { z?: { w: boolean; } | undefined; }
o5.x.y.z.w;
>o5.x.y.z.w : boolean
>o5.x.y.z : { w: boolean; } | undefined
->o5.x.y : { z?: { w: boolean; }; }
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
->y : { z?: { w: boolean; }; }
+>o5.x.y : { z?: { w: boolean; } | undefined; }
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>y : { z?: { w: boolean; } | undefined; }
>z : { w: boolean; } | undefined
>w : boolean
}
o5.x;
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
o5.x?.y;
->o5.x?.y : { z?: { w: boolean; }; } | undefined
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
->y : { z?: { w: boolean; }; } | undefined
+>o5.x?.y : { z?: { w: boolean; } | undefined; } | undefined
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>y : { z?: { w: boolean; } | undefined; } | undefined
o5.x?.y.z;
>o5.x?.y.z : { w: boolean; } | undefined
->o5.x?.y : { z?: { w: boolean; }; } | undefined
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
->y : { z?: { w: boolean; }; } | undefined
+>o5.x?.y : { z?: { w: boolean; } | undefined; } | undefined
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>y : { z?: { w: boolean; } | undefined; } | undefined
>z : { w: boolean; } | undefined
o5.x?.y.z?.w;
>o5.x?.y.z?.w : boolean | undefined
>o5.x?.y.z : { w: boolean; } | undefined
->o5.x?.y : { z?: { w: boolean; }; } | undefined
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
->y : { z?: { w: boolean; }; } | undefined
+>o5.x?.y : { z?: { w: boolean; } | undefined; } | undefined
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>y : { z?: { w: boolean; } | undefined; } | undefined
>z : { w: boolean; } | undefined
>w : boolean | undefined
o5.x.y;
->o5.x.y : { z?: { w: boolean; }; }
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
->y : { z?: { w: boolean; }; }
+>o5.x.y : { z?: { w: boolean; } | undefined; }
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>y : { z?: { w: boolean; } | undefined; }
o5.x.y.z.w;
>o5.x.y.z.w : boolean
>o5.x.y.z : { w: boolean; } | undefined
->o5.x.y : { z?: { w: boolean; }; }
->o5.x : { y: { z?: { w: boolean; }; }; } | undefined
->o5 : { x?: { y: { z?: { w: boolean; }; }; }; }
->x : { y: { z?: { w: boolean; }; }; } | undefined
->y : { z?: { w: boolean; }; }
+>o5.x.y : { z?: { w: boolean; } | undefined; }
+>o5.x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>o5 : { x?: { y: { z?: { w: boolean; } | undefined; }; } | undefined; }
+>x : { y: { z?: { w: boolean; } | undefined; }; } | undefined
+>y : { z?: { w: boolean; } | undefined; }
>z : { w: boolean; } | undefined
>w : boolean
diff --git a/tests/baselines/reference/deleteChain.types b/tests/baselines/reference/deleteChain.types
index a2f3f7ce4c36c..2e5f7fedd3135 100644
--- a/tests/baselines/reference/deleteChain.types
+++ b/tests/baselines/reference/deleteChain.types
@@ -61,9 +61,9 @@ delete (o3.b?.c);
>c : string | undefined
declare const o4: { b?: { c: { d?: { e: string } } } };
->o4 : { b?: { c: { d?: { e: string; }; };}; }
+>o4 : { b?: { c: { d?: { e: string; };}; } | undefined; }
>b : { c: { d?: { e: string; };}; } | undefined
->c : { d?: { e: string;}; }
+>c : { d?: { e: string; } | undefined; }
>d : { e: string; } | undefined
>e : string
@@ -71,11 +71,11 @@ delete o4.b?.c.d?.e;
>delete o4.b?.c.d?.e : boolean
>o4.b?.c.d?.e : string | undefined
>o4.b?.c.d : { e: string; } | undefined
->o4.b?.c : { d?: { e: string; }; } | undefined
->o4.b : { c: { d?: { e: string; }; }; } | undefined
->o4 : { b?: { c: { d?: { e: string; }; }; }; }
->b : { c: { d?: { e: string; }; }; } | undefined
->c : { d?: { e: string; }; } | undefined
+>o4.b?.c : { d?: { e: string; } | undefined; } | undefined
+>o4.b : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o4 : { b?: { c: { d?: { e: string; } | undefined; }; } | undefined; }
+>b : { c: { d?: { e: string; } | undefined; }; } | undefined
+>c : { d?: { e: string; } | undefined; } | undefined
>d : { e: string; } | undefined
>e : string | undefined
@@ -84,11 +84,11 @@ delete (o4.b?.c.d)?.e;
>(o4.b?.c.d)?.e : string | undefined
>(o4.b?.c.d) : { e: string; } | undefined
>o4.b?.c.d : { e: string; } | undefined
->o4.b?.c : { d?: { e: string; }; } | undefined
->o4.b : { c: { d?: { e: string; }; }; } | undefined
->o4 : { b?: { c: { d?: { e: string; }; }; }; }
->b : { c: { d?: { e: string; }; }; } | undefined
->c : { d?: { e: string; }; } | undefined
+>o4.b?.c : { d?: { e: string; } | undefined; } | undefined
+>o4.b : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o4 : { b?: { c: { d?: { e: string; } | undefined; }; } | undefined; }
+>b : { c: { d?: { e: string; } | undefined; }; } | undefined
+>c : { d?: { e: string; } | undefined; } | undefined
>d : { e: string; } | undefined
>e : string | undefined
@@ -97,18 +97,18 @@ delete (o4.b?.c.d?.e);
>(o4.b?.c.d?.e) : string | undefined
>o4.b?.c.d?.e : string | undefined
>o4.b?.c.d : { e: string; } | undefined
->o4.b?.c : { d?: { e: string; }; } | undefined
->o4.b : { c: { d?: { e: string; }; }; } | undefined
->o4 : { b?: { c: { d?: { e: string; }; }; }; }
->b : { c: { d?: { e: string; }; }; } | undefined
->c : { d?: { e: string; }; } | undefined
+>o4.b?.c : { d?: { e: string; } | undefined; } | undefined
+>o4.b : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o4 : { b?: { c: { d?: { e: string; } | undefined; }; } | undefined; }
+>b : { c: { d?: { e: string; } | undefined; }; } | undefined
+>c : { d?: { e: string; } | undefined; } | undefined
>d : { e: string; } | undefined
>e : string | undefined
declare const o5: { b?(): { c: { d?: { e: string } } } };
>o5 : { b?(): { c: { d?: { e: string; }; };}; }
>b : (() => { c: { d?: { e: string; }; };}) | undefined
->c : { d?: { e: string;}; }
+>c : { d?: { e: string; } | undefined; }
>d : { e: string; } | undefined
>e : string
@@ -116,12 +116,12 @@ delete o5.b?.().c.d?.e;
>delete o5.b?.().c.d?.e : boolean
>o5.b?.().c.d?.e : string | undefined
>o5.b?.().c.d : { e: string; } | undefined
->o5.b?.().c : { d?: { e: string; }; } | undefined
->o5.b?.() : { c: { d?: { e: string; }; }; } | undefined
->o5.b : (() => { c: { d?: { e: string; }; }; }) | undefined
->o5 : { b?(): { c: { d?: { e: string; }; }; }; }
->b : (() => { c: { d?: { e: string; }; }; }) | undefined
->c : { d?: { e: string; }; } | undefined
+>o5.b?.().c : { d?: { e: string; } | undefined; } | undefined
+>o5.b?.() : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o5.b : (() => { c: { d?: { e: string; } | undefined; }; }) | undefined
+>o5 : { b?(): { c: { d?: { e: string; } | undefined; }; }; }
+>b : (() => { c: { d?: { e: string; } | undefined; }; }) | undefined
+>c : { d?: { e: string; } | undefined; } | undefined
>d : { e: string; } | undefined
>e : string | undefined
@@ -130,19 +130,19 @@ delete (o5.b?.().c.d?.e);
>(o5.b?.().c.d?.e) : string | undefined
>o5.b?.().c.d?.e : string | undefined
>o5.b?.().c.d : { e: string; } | undefined
->o5.b?.().c : { d?: { e: string; }; } | undefined
->o5.b?.() : { c: { d?: { e: string; }; }; } | undefined
->o5.b : (() => { c: { d?: { e: string; }; }; }) | undefined
->o5 : { b?(): { c: { d?: { e: string; }; }; }; }
->b : (() => { c: { d?: { e: string; }; }; }) | undefined
->c : { d?: { e: string; }; } | undefined
+>o5.b?.().c : { d?: { e: string; } | undefined; } | undefined
+>o5.b?.() : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o5.b : (() => { c: { d?: { e: string; } | undefined; }; }) | undefined
+>o5 : { b?(): { c: { d?: { e: string; } | undefined; }; }; }
+>b : (() => { c: { d?: { e: string; } | undefined; }; }) | undefined
+>c : { d?: { e: string; } | undefined; } | undefined
>d : { e: string; } | undefined
>e : string | undefined
declare const o6: { b?: { c: { d?: { e: string } } } };
->o6 : { b?: { c: { d?: { e: string; }; };}; }
+>o6 : { b?: { c: { d?: { e: string; };}; } | undefined; }
>b : { c: { d?: { e: string; };}; } | undefined
->c : { d?: { e: string;}; }
+>c : { d?: { e: string; } | undefined; }
>d : { e: string; } | undefined
>e : string
@@ -150,10 +150,10 @@ delete o6.b?.['c'].d?.['e'];
>delete o6.b?.['c'].d?.['e'] : boolean
>o6.b?.['c'].d?.['e'] : string | undefined
>o6.b?.['c'].d : { e: string; } | undefined
->o6.b?.['c'] : { d?: { e: string; }; } | undefined
->o6.b : { c: { d?: { e: string; }; }; } | undefined
->o6 : { b?: { c: { d?: { e: string; }; }; }; }
->b : { c: { d?: { e: string; }; }; } | undefined
+>o6.b?.['c'] : { d?: { e: string; } | undefined; } | undefined
+>o6.b : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o6 : { b?: { c: { d?: { e: string; } | undefined; }; } | undefined; }
+>b : { c: { d?: { e: string; } | undefined; }; } | undefined
>'c' : "c"
>d : { e: string; } | undefined
>'e' : "e"
@@ -163,10 +163,10 @@ delete (o6.b?.['c'].d?.['e']);
>(o6.b?.['c'].d?.['e']) : string | undefined
>o6.b?.['c'].d?.['e'] : string | undefined
>o6.b?.['c'].d : { e: string; } | undefined
->o6.b?.['c'] : { d?: { e: string; }; } | undefined
->o6.b : { c: { d?: { e: string; }; }; } | undefined
->o6 : { b?: { c: { d?: { e: string; }; }; }; }
->b : { c: { d?: { e: string; }; }; } | undefined
+>o6.b?.['c'] : { d?: { e: string; } | undefined; } | undefined
+>o6.b : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o6 : { b?: { c: { d?: { e: string; } | undefined; }; } | undefined; }
+>b : { c: { d?: { e: string; } | undefined; }; } | undefined
>'c' : "c"
>d : { e: string; } | undefined
>'e' : "e"
diff --git a/tests/baselines/reference/destructuringControlFlow.types b/tests/baselines/reference/destructuringControlFlow.types
index 6c04cfd193c5a..02deb39200688 100644
--- a/tests/baselines/reference/destructuringControlFlow.types
+++ b/tests/baselines/reference/destructuringControlFlow.types
@@ -1,29 +1,29 @@
=== tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts ===
function f1(obj: { a?: string }) {
>f1 : (obj: { a?: string;}) => void
->obj : { a?: string; }
+>obj : { a?: string | undefined; }
>a : string | undefined
if (obj.a) {
>obj.a : string | undefined
->obj : { a?: string; }
+>obj : { a?: string | undefined; }
>a : string | undefined
obj = {};
>obj = {} : {}
->obj : { a?: string; }
+>obj : { a?: string | undefined; }
>{} : {}
let a1 = obj["a"]; // string | undefined
>a1 : string | undefined
>obj["a"] : string | undefined
->obj : { a?: string; }
+>obj : { a?: string | undefined; }
>"a" : "a"
let a2 = obj.a; // string | undefined
>a2 : string | undefined
>obj.a : string | undefined
->obj : { a?: string; }
+>obj : { a?: string | undefined; }
>a : string | undefined
}
}
@@ -96,31 +96,31 @@ function f2(obj: [number, string] | null[]) {
function f3(obj: { a?: number, b?: string }) {
>f3 : (obj: { a?: number; b?: string;}) => void
->obj : { a?: number; b?: string; }
+>obj : { a?: number | undefined; b?: string | undefined; }
>a : number | undefined
>b : string | undefined
if (obj.a && obj.b) {
>obj.a && obj.b : string | 0 | undefined
>obj.a : number | undefined
->obj : { a?: number; b?: string; }
+>obj : { a?: number | undefined; b?: string | undefined; }
>a : number | undefined
>obj.b : string | undefined
->obj : { a?: number; b?: string; }
+>obj : { a?: number | undefined; b?: string | undefined; }
>b : string | undefined
let { a, b } = obj; // number, string
>a : number
>b : string
->obj : { a?: number; b?: string; }
+>obj : { a?: number | undefined; b?: string | undefined; }
({ a, b } = obj);
->({ a, b } = obj) : { a?: number; b?: string; }
->{ a, b } = obj : { a?: number; b?: string; }
+>({ a, b } = obj) : { a?: number | undefined; b?: string | undefined; }
+>{ a, b } = obj : { a?: number | undefined; b?: string | undefined; }
>{ a, b } : { a: number; b: string; }
>a : number
>b : string
->obj : { a?: number; b?: string; }
+>obj : { a?: number | undefined; b?: string | undefined; }
}
}
diff --git a/tests/baselines/reference/elementAccessChain.types b/tests/baselines/reference/elementAccessChain.types
index 681312b515cb6..ccb7d97460464 100644
--- a/tests/baselines/reference/elementAccessChain.types
+++ b/tests/baselines/reference/elementAccessChain.types
@@ -47,19 +47,19 @@ o3.b?.["c"];
>"c" : "c"
declare const o4: { b?: { c: { d?: { e: string } } } };
->o4 : { b?: { c: { d?: { e: string; }; };}; }
+>o4 : { b?: { c: { d?: { e: string; };}; } | undefined; }
>b : { c: { d?: { e: string; };}; } | undefined
->c : { d?: { e: string;}; }
+>c : { d?: { e: string; } | undefined; }
>d : { e: string; } | undefined
>e : string
o4.b?.["c"].d?.e;
>o4.b?.["c"].d?.e : string | undefined
>o4.b?.["c"].d : { e: string; } | undefined
->o4.b?.["c"] : { d?: { e: string; }; } | undefined
->o4.b : { c: { d?: { e: string; }; }; } | undefined
->o4 : { b?: { c: { d?: { e: string; }; }; }; }
->b : { c: { d?: { e: string; }; }; } | undefined
+>o4.b?.["c"] : { d?: { e: string; } | undefined; } | undefined
+>o4.b : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o4 : { b?: { c: { d?: { e: string; } | undefined; }; } | undefined; }
+>b : { c: { d?: { e: string; } | undefined; }; } | undefined
>"c" : "c"
>d : { e: string; } | undefined
>e : string | undefined
@@ -67,10 +67,10 @@ o4.b?.["c"].d?.e;
o4.b?.["c"].d?.["e"];
>o4.b?.["c"].d?.["e"] : string | undefined
>o4.b?.["c"].d : { e: string; } | undefined
->o4.b?.["c"] : { d?: { e: string; }; } | undefined
->o4.b : { c: { d?: { e: string; }; }; } | undefined
->o4 : { b?: { c: { d?: { e: string; }; }; }; }
->b : { c: { d?: { e: string; }; }; } | undefined
+>o4.b?.["c"] : { d?: { e: string; } | undefined; } | undefined
+>o4.b : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o4 : { b?: { c: { d?: { e: string; } | undefined; }; } | undefined; }
+>b : { c: { d?: { e: string; } | undefined; }; } | undefined
>"c" : "c"
>d : { e: string; } | undefined
>"e" : "e"
@@ -78,18 +78,18 @@ o4.b?.["c"].d?.["e"];
declare const o5: { b?(): { c: { d?: { e: string } } } };
>o5 : { b?(): { c: { d?: { e: string; }; };}; }
>b : (() => { c: { d?: { e: string; }; };}) | undefined
->c : { d?: { e: string;}; }
+>c : { d?: { e: string; } | undefined; }
>d : { e: string; } | undefined
>e : string
o5.b?.()["c"].d?.e;
>o5.b?.()["c"].d?.e : string | undefined
>o5.b?.()["c"].d : { e: string; } | undefined
->o5.b?.()["c"] : { d?: { e: string; }; } | undefined
->o5.b?.() : { c: { d?: { e: string; }; }; } | undefined
->o5.b : (() => { c: { d?: { e: string; }; }; }) | undefined
->o5 : { b?(): { c: { d?: { e: string; }; }; }; }
->b : (() => { c: { d?: { e: string; }; }; }) | undefined
+>o5.b?.()["c"] : { d?: { e: string; } | undefined; } | undefined
+>o5.b?.() : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o5.b : (() => { c: { d?: { e: string; } | undefined; }; }) | undefined
+>o5 : { b?(): { c: { d?: { e: string; } | undefined; }; }; }
+>b : (() => { c: { d?: { e: string; } | undefined; }; }) | undefined
>"c" : "c"
>d : { e: string; } | undefined
>e : string | undefined
@@ -97,11 +97,11 @@ o5.b?.()["c"].d?.e;
o5.b?.()["c"].d?.["e"];
>o5.b?.()["c"].d?.["e"] : string | undefined
>o5.b?.()["c"].d : { e: string; } | undefined
->o5.b?.()["c"] : { d?: { e: string; }; } | undefined
->o5.b?.() : { c: { d?: { e: string; }; }; } | undefined
->o5.b : (() => { c: { d?: { e: string; }; }; }) | undefined
->o5 : { b?(): { c: { d?: { e: string; }; }; }; }
->b : (() => { c: { d?: { e: string; }; }; }) | undefined
+>o5.b?.()["c"] : { d?: { e: string; } | undefined; } | undefined
+>o5.b?.() : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o5.b : (() => { c: { d?: { e: string; } | undefined; }; }) | undefined
+>o5 : { b?(): { c: { d?: { e: string; } | undefined; }; }; }
+>b : (() => { c: { d?: { e: string; } | undefined; }; }) | undefined
>"c" : "c"
>d : { e: string; } | undefined
>"e" : "e"
@@ -109,10 +109,10 @@ o5.b?.()["c"].d?.["e"];
o5["b"]?.()["c"].d?.e;
>o5["b"]?.()["c"].d?.e : string | undefined
>o5["b"]?.()["c"].d : { e: string; } | undefined
->o5["b"]?.()["c"] : { d?: { e: string; }; } | undefined
->o5["b"]?.() : { c: { d?: { e: string; }; }; } | undefined
->o5["b"] : (() => { c: { d?: { e: string; }; }; }) | undefined
->o5 : { b?(): { c: { d?: { e: string; }; }; }; }
+>o5["b"]?.()["c"] : { d?: { e: string; } | undefined; } | undefined
+>o5["b"]?.() : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o5["b"] : (() => { c: { d?: { e: string; } | undefined; }; }) | undefined
+>o5 : { b?(): { c: { d?: { e: string; } | undefined; }; }; }
>"b" : "b"
>"c" : "c"
>d : { e: string; } | undefined
@@ -121,10 +121,10 @@ o5["b"]?.()["c"].d?.e;
o5["b"]?.()["c"].d?.["e"];
>o5["b"]?.()["c"].d?.["e"] : string | undefined
>o5["b"]?.()["c"].d : { e: string; } | undefined
->o5["b"]?.()["c"] : { d?: { e: string; }; } | undefined
->o5["b"]?.() : { c: { d?: { e: string; }; }; } | undefined
->o5["b"] : (() => { c: { d?: { e: string; }; }; }) | undefined
->o5 : { b?(): { c: { d?: { e: string; }; }; }; }
+>o5["b"]?.()["c"] : { d?: { e: string; } | undefined; } | undefined
+>o5["b"]?.() : { c: { d?: { e: string; } | undefined; }; } | undefined
+>o5["b"] : (() => { c: { d?: { e: string; } | undefined; }; }) | undefined
+>o5 : { b?(): { c: { d?: { e: string; } | undefined; }; }; }
>"b" : "b"
>"c" : "c"
>d : { e: string; } | undefined
diff --git a/tests/baselines/reference/homomorphicMappedTypeIntersectionAssignability.types b/tests/baselines/reference/homomorphicMappedTypeIntersectionAssignability.types
index bf10a7f1585d1..f89f132dcc875 100644
--- a/tests/baselines/reference/homomorphicMappedTypeIntersectionAssignability.types
+++ b/tests/baselines/reference/homomorphicMappedTypeIntersectionAssignability.types
@@ -3,7 +3,7 @@ function f(
>f : (a: { weak?: string;} & Readonly & { name: "ok";}, b: Readonly, c: Readonly & { name: string;}) => void
a: { weak?: string } & Readonly & { name: "ok" },
->a : { weak?: string; } & Readonly & { name: "ok"; }
+>a : { weak?: string | undefined; } & Readonly & { name: "ok"; }
>weak : string | undefined
>name : "ok"
@@ -16,13 +16,13 @@ function f(
>name : string
c = a; // Works
->c = a : { weak?: string; } & Readonly & { name: "ok"; }
+>c = a : { weak?: string | undefined; } & Readonly & { name: "ok"; }
>c : Readonly & { name: string; }
->a : { weak?: string; } & Readonly & { name: "ok"; }
+>a : { weak?: string | undefined; } & Readonly & { name: "ok"; }
b = a; // Should also work
->b = a : { weak?: string; } & Readonly & { name: "ok"; }
+>b = a : { weak?: string | undefined; } & Readonly & { name: "ok"; }
>b : Readonly
->a : { weak?: string; } & Readonly & { name: "ok"; }
+>a : { weak?: string | undefined; } & Readonly & { name: "ok"; }
}
diff --git a/tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.types b/tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.types
index 0d8e4bda7c53d..b707b156b2ea2 100644
--- a/tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.types
+++ b/tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.types
@@ -15,7 +15,7 @@ declare const x2: { a: string, b: number | undefined };
>b : number | undefined
declare const x3: { a: string, b?: number };
->x3 : { a: string; b?: number; }
+>x3 : { a: string; b?: number | undefined; }
>a : string
>b : number | undefined
@@ -40,11 +40,11 @@ let a3 = foo(x3); // string | number
>a3 : string | number
>foo(x3) : string | number
>foo : (obj: { [x: string]: T; }) => T
->x3 : { a: string; b?: number; }
+>x3 : { a: string; b?: number | undefined; }
let a4 = foo(x4); // string | number
->a4 : string | number | undefined
->foo(x4) : string | number | undefined
+>a4 : string | number
+>foo(x4) : string | number
>foo : (obj: { [x: string]: T; }) => T
>x4 : { a: string; b?: number | undefined; }
@@ -63,8 +63,8 @@ const param2 = Math.random() < 0.5 ? 'value2' : null;
>null : null
const obj = {
->obj : { param2?: string; param1: string; }
->{ param1: 'value1', ...(param2 ? {param2} : {})} : { param2?: string; param1: string; }
+>obj : { param2?: string | undefined; param1: string; }
+>{ param1: 'value1', ...(param2 ? {param2} : {})} : { param2?: string | undefined; param1: string; }
param1: 'value1',
>param1 : string
@@ -90,7 +90,7 @@ const query = Object.entries(obj).map(
>Object.entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; }
>Object : ObjectConstructor
>entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; }
->obj : { param2?: string; param1: string; }
+>obj : { param2?: string | undefined; param1: string; }
>map : (callbackfn: (value: [string, string], index: number, array: [string, string][]) => U, thisArg?: any) => U[]
([k, v]) => `${k}=${encodeURIComponent(v)}`
diff --git a/tests/baselines/reference/initializedParameterBeforeNonoptionalNotOptional.types b/tests/baselines/reference/initializedParameterBeforeNonoptionalNotOptional.types
index f6eb1f4f8107b..5035da7bcef17 100644
--- a/tests/baselines/reference/initializedParameterBeforeNonoptionalNotOptional.types
+++ b/tests/baselines/reference/initializedParameterBeforeNonoptionalNotOptional.types
@@ -1,6 +1,6 @@
=== tests/cases/compiler/index.d.ts ===
export declare function foo({a}?: {
->foo : ({ a }?: { a?: string; } | undefined) => void
+>foo : ({ a }?: { a?: string | undefined; } | undefined) => void
>a : string | undefined
a?: string;
diff --git a/tests/baselines/reference/instantiateContextualTypes.types b/tests/baselines/reference/instantiateContextualTypes.types
index 902114916c494..ff6154c78589c 100644
--- a/tests/baselines/reference/instantiateContextualTypes.types
+++ b/tests/baselines/reference/instantiateContextualTypes.types
@@ -221,7 +221,7 @@ interface ComponentClass {
}
type CreateElementChildren
=
->CreateElementChildren : P extends { children?: infer C; } ? C extends any[] ? C : C[] : unknown
+>CreateElementChildren : P extends { children?: infer C | undefined; } ? C extends any[] ? C : C[] : unknown
P extends { children?: infer C }
>children : C | undefined
@@ -232,24 +232,24 @@ type CreateElementChildren
=
: unknown;
declare function createElement
(
->createElement :
(type: ComponentClass
, ...children: P extends { children?: infer C; } ? C extends any[] ? C : C[] : unknown) => any
+>createElement :
(type: ComponentClass
, ...children: P extends { children?: infer C | undefined; } ? C extends any[] ? C : C[] : unknown) => any
type: ComponentClass
,
>type : ComponentClass
...children: CreateElementChildren
->children : P extends { children?: infer C; } ? C extends any[] ? C : C[] : unknown
+>children : P extends { children?: infer C | undefined; } ? C extends any[] ? C : C[] : unknown
): any;
declare function createElement2
(
->createElement2 :
(type: ComponentClass
, child: P extends { children?: infer C; } ? C extends any[] ? C : C[] : unknown) => any
+>createElement2 :
(type: ComponentClass
, child: P extends { children?: infer C | undefined; } ? C extends any[] ? C : C[] : unknown) => any
type: ComponentClass
,
>type : ComponentClass
child: CreateElementChildren
->child : P extends { children?: infer C; } ? C extends any[] ? C : C[] : unknown
+>child : P extends { children?: infer C | undefined; } ? C extends any[] ? C : C[] : unknown
): any;
@@ -261,7 +261,7 @@ class InferFunctionTypes extends Component<{children: (foo: number) => string}>
createElement(InferFunctionTypes, (foo) => "" + foo);
>createElement(InferFunctionTypes, (foo) => "" + foo) : any
->createElement :
(type: ComponentClass
, ...children: P extends { children?: infer C; } ? C extends any[] ? C : C[] : unknown) => any
+>createElement :
(type: ComponentClass
, ...children: P extends { children?: infer C | undefined; } ? C extends any[] ? C : C[] : unknown) => any
>InferFunctionTypes : typeof InferFunctionTypes
>(foo) => "" + foo : (foo: number) => string
>foo : number
@@ -271,7 +271,7 @@ createElement(InferFunctionTypes, (foo) => "" + foo);
createElement2(InferFunctionTypes, [(foo) => "" + foo]);
>createElement2(InferFunctionTypes, [(foo) => "" + foo]) : any
->createElement2 :
(type: ComponentClass
, child: P extends { children?: infer C; } ? C extends any[] ? C : C[] : unknown) => any
+>createElement2 :
(type: ComponentClass
, child: P extends { children?: infer C | undefined; } ? C extends any[] ? C : C[] : unknown) => any
>InferFunctionTypes : typeof InferFunctionTypes
>[(foo) => "" + foo] : ((foo: number) => string)[]
>(foo) => "" + foo : (foo: number) => string
diff --git a/tests/baselines/reference/intersectionPropertyCheck.errors.txt b/tests/baselines/reference/intersectionPropertyCheck.errors.txt
index 494832fec8123..7c74c3512eaf1 100644
--- a/tests/baselines/reference/intersectionPropertyCheck.errors.txt
+++ b/tests/baselines/reference/intersectionPropertyCheck.errors.txt
@@ -1,12 +1,12 @@
tests/cases/compiler/intersectionPropertyCheck.ts(1,68): error TS2322: Type '{ x: string; y: number; }' is not assignable to type '{ x: string; }'.
Object literal may only specify known properties, and 'y' does not exist in type '{ x: string; }'.
-tests/cases/compiler/intersectionPropertyCheck.ts(4,5): error TS2322: Type '{ a: { y: string; }; }' is not assignable to type '{ a?: { x?: number; }; } & { c?: string; }'.
+tests/cases/compiler/intersectionPropertyCheck.ts(4,5): error TS2322: Type '{ a: { y: string; }; }' is not assignable to type '{ a?: { x?: number | undefined; } | undefined; } & { c?: string | undefined; }'.
Types of property 'a' are incompatible.
- Type '{ y: string; }' has no properties in common with type '{ x?: number; }'.
-tests/cases/compiler/intersectionPropertyCheck.ts(7,3): error TS2322: Type 'T & { a: boolean; }' is not assignable to type '{ a?: string; }'.
+ Type '{ y: string; }' has no properties in common with type '{ x?: number | undefined; }'.
+tests/cases/compiler/intersectionPropertyCheck.ts(7,3): error TS2322: Type 'T & { a: boolean; }' is not assignable to type '{ a?: string | undefined; }'.
Types of property 'a' are incompatible.
- Type 'boolean' is not assignable to type 'string'.
-tests/cases/compiler/intersectionPropertyCheck.ts(17,22): error TS2322: Type 'boolean' is not assignable to type 'string[]'.
+ Type 'boolean' is not assignable to type 'string | undefined'.
+tests/cases/compiler/intersectionPropertyCheck.ts(17,22): error TS2322: Type 'true' is not assignable to type 'string[] | undefined'.
==== tests/cases/compiler/intersectionPropertyCheck.ts (4 errors) ====
@@ -19,16 +19,16 @@ tests/cases/compiler/intersectionPropertyCheck.ts(17,22): error TS2322: Type 'bo
declare let wrong: { a: { y: string } };
let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
~~~~
-!!! error TS2322: Type '{ a: { y: string; }; }' is not assignable to type '{ a?: { x?: number; }; } & { c?: string; }'.
+!!! error TS2322: Type '{ a: { y: string; }; }' is not assignable to type '{ a?: { x?: number | undefined; } | undefined; } & { c?: string | undefined; }'.
!!! error TS2322: Types of property 'a' are incompatible.
-!!! error TS2322: Type '{ y: string; }' has no properties in common with type '{ x?: number; }'.
+!!! error TS2322: Type '{ y: string; }' has no properties in common with type '{ x?: number | undefined; }'.
function foo(x: { a?: string }, y: T & { a: boolean }) {
x = y; // Mismatched property in source intersection
~
-!!! error TS2322: Type 'T & { a: boolean; }' is not assignable to type '{ a?: string; }'.
+!!! error TS2322: Type 'T & { a: boolean; }' is not assignable to type '{ a?: string | undefined; }'.
!!! error TS2322: Types of property 'a' are incompatible.
-!!! error TS2322: Type 'boolean' is not assignable to type 'string'.
+!!! error TS2322: Type 'boolean' is not assignable to type 'string | undefined'.
}
// Repro from #36637
@@ -40,7 +40,7 @@ tests/cases/compiler/intersectionPropertyCheck.ts(17,22): error TS2322: Type 'bo
function test(value: T): Test {
return { ...value, hi: true }
~~
-!!! error TS2322: Type 'boolean' is not assignable to type 'string[]'.
+!!! error TS2322: Type 'true' is not assignable to type 'string[] | undefined'.
!!! related TS6500 tests/cases/compiler/intersectionPropertyCheck.ts:13:12: The expected type comes from property 'hi' which is declared here on type 'Test'
}
\ No newline at end of file
diff --git a/tests/baselines/reference/intersectionPropertyCheck.types b/tests/baselines/reference/intersectionPropertyCheck.types
index 5b37490ea88cf..515d5009732fd 100644
--- a/tests/baselines/reference/intersectionPropertyCheck.types
+++ b/tests/baselines/reference/intersectionPropertyCheck.types
@@ -20,22 +20,22 @@ declare let wrong: { a: { y: string } };
>y : string
let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
->weak : { a?: { x?: number;}; } & { c?: string; }
->a : { x?: number; } | undefined
+>weak : { a?: { x?: number | undefined; } | undefined; } & { c?: string | undefined; }
+>a : { x?: number | undefined; } | undefined
>x : number | undefined
>c : string | undefined
>wrong : { a: { y: string; }; }
function foo(x: { a?: string }, y: T & { a: boolean }) {
>foo : (x: { a?: string;}, y: T & { a: boolean;}) => void
->x : { a?: string; }
+>x : { a?: string | undefined; }
>a : string | undefined
>y : T & { a: boolean; }
>a : boolean
x = y; // Mismatched property in source intersection
>x = y : T & { a: boolean; }
->x : { a?: string; }
+>x : { a?: string | undefined; }
>y : T & { a: boolean; }
}
diff --git a/tests/baselines/reference/intersectionsAndOptionalProperties.errors.txt b/tests/baselines/reference/intersectionsAndOptionalProperties.errors.txt
index 2bd15c04d42d6..faa8b067b1ac3 100644
--- a/tests/baselines/reference/intersectionsAndOptionalProperties.errors.txt
+++ b/tests/baselines/reference/intersectionsAndOptionalProperties.errors.txt
@@ -1,13 +1,13 @@
-tests/cases/compiler/intersectionsAndOptionalProperties.ts(5,1): error TS2322: Type '{ a: null; b: string; }' is not assignable to type '{ a?: number; b: string; }'.
+tests/cases/compiler/intersectionsAndOptionalProperties.ts(5,1): error TS2322: Type '{ a: null; b: string; }' is not assignable to type '{ a?: number | undefined; b: string; }'.
Types of property 'a' are incompatible.
- Type 'null' is not assignable to type 'number'.
-tests/cases/compiler/intersectionsAndOptionalProperties.ts(6,1): error TS2322: Type '{ a: null; } & { b: string; }' is not assignable to type '{ a?: number; b: string; }'.
+ Type 'null' is not assignable to type 'number | undefined'.
+tests/cases/compiler/intersectionsAndOptionalProperties.ts(6,1): error TS2322: Type '{ a: null; } & { b: string; }' is not assignable to type '{ a?: number | undefined; b: string; }'.
Types of property 'a' are incompatible.
- Type 'null' is not assignable to type 'number'.
+ Type 'null' is not assignable to type 'number | undefined'.
tests/cases/compiler/intersectionsAndOptionalProperties.ts(19,5): error TS2322: Type 'From' is not assignable to type 'To'.
Types of property 'field' are incompatible.
- Type 'null' is not assignable to type 'number'.
-tests/cases/compiler/intersectionsAndOptionalProperties.ts(20,5): error TS2322: Type 'null' is not assignable to type 'number'.
+ Type 'null' is not assignable to type 'number | undefined'.
+tests/cases/compiler/intersectionsAndOptionalProperties.ts(20,5): error TS2322: Type 'null' is not assignable to type 'number | undefined'.
==== tests/cases/compiler/intersectionsAndOptionalProperties.ts (4 errors) ====
@@ -17,14 +17,14 @@ tests/cases/compiler/intersectionsAndOptionalProperties.ts(20,5): error TS2322:
x = y; // Error
~
-!!! error TS2322: Type '{ a: null; b: string; }' is not assignable to type '{ a?: number; b: string; }'.
+!!! error TS2322: Type '{ a: null; b: string; }' is not assignable to type '{ a?: number | undefined; b: string; }'.
!!! error TS2322: Types of property 'a' are incompatible.
-!!! error TS2322: Type 'null' is not assignable to type 'number'.
+!!! error TS2322: Type 'null' is not assignable to type 'number | undefined'.
x = z; // Error
~
-!!! error TS2322: Type '{ a: null; } & { b: string; }' is not assignable to type '{ a?: number; b: string; }'.
+!!! error TS2322: Type '{ a: null; } & { b: string; }' is not assignable to type '{ a?: number | undefined; b: string; }'.
!!! error TS2322: Types of property 'a' are incompatible.
-!!! error TS2322: Type 'null' is not assignable to type 'number'.
+!!! error TS2322: Type 'null' is not assignable to type 'number | undefined'.
// Repro from #36604
@@ -41,10 +41,10 @@ tests/cases/compiler/intersectionsAndOptionalProperties.ts(20,5): error TS2322:
~
!!! error TS2322: Type 'From' is not assignable to type 'To'.
!!! error TS2322: Types of property 'field' are incompatible.
-!!! error TS2322: Type 'null' is not assignable to type 'number'.
+!!! error TS2322: Type 'null' is not assignable to type 'number | undefined'.
x.field = v.field; // Error
~~~~~~~
-!!! error TS2322: Type 'null' is not assignable to type 'number'.
+!!! error TS2322: Type 'null' is not assignable to type 'number | undefined'.
}
// Repro from #38348
diff --git a/tests/baselines/reference/intersectionsAndOptionalProperties.types b/tests/baselines/reference/intersectionsAndOptionalProperties.types
index 655cdc513839f..98bc85c7e4299 100644
--- a/tests/baselines/reference/intersectionsAndOptionalProperties.types
+++ b/tests/baselines/reference/intersectionsAndOptionalProperties.types
@@ -1,6 +1,6 @@
=== tests/cases/compiler/intersectionsAndOptionalProperties.ts ===
declare let x: { a?: number, b: string };
->x : { a?: number; b: string; }
+>x : { a?: number | undefined; b: string; }
>a : number | undefined
>b : string
@@ -18,12 +18,12 @@ declare let z: { a: null } & { b: string };
x = y; // Error
>x = y : { a: null; b: string; }
->x : { a?: number; b: string; }
+>x : { a?: number | undefined; b: string; }
>y : { a: null; b: string; }
x = z; // Error
>x = z : { a: null; } & { b: string; }
->x : { a?: number; b: string; }
+>x : { a?: number | undefined; b: string; }
>z : { a: null; } & { b: string; }
// Repro from #36604
@@ -55,9 +55,9 @@ function foo(v: From) {
x.field = v.field; // Error
>x.field = v.field : null
->x.field : number
+>x.field : number | undefined
>x : To
->field : number
+>field : number | undefined
>v.field : null
>v : From
>field : null
diff --git a/tests/baselines/reference/jsDeclarationsReactComponents.types b/tests/baselines/reference/jsDeclarationsReactComponents.types
index 17a63894fddf4..4934a173b935b 100644
--- a/tests/baselines/reference/jsDeclarationsReactComponents.types
+++ b/tests/baselines/reference/jsDeclarationsReactComponents.types
@@ -61,7 +61,7 @@ import React from "react";
*/
const TabbedShowLayout = () => {
>TabbedShowLayout : React.SFC<{}>
->() => { return ( ok
);} : { (): JSX.Element; defaultProps: Partial<{}>; }
+>() => { return ( ok
);} : { (): JSX.Element; defaultProps: Partial<{}> | undefined; }
return (
>( ok
) : JSX.Element
@@ -81,9 +81,9 @@ const TabbedShowLayout = () => {
TabbedShowLayout.defaultProps = {
>TabbedShowLayout.defaultProps = { tabs: "default value"} : { tabs: string; }
->TabbedShowLayout.defaultProps : Partial<{}>
+>TabbedShowLayout.defaultProps : Partial<{}> | undefined
>TabbedShowLayout : React.SFC<{}>
->defaultProps : Partial<{}>
+>defaultProps : Partial<{}> | undefined
>{ tabs: "default value"} : { tabs: string; }
tabs: "default value"
diff --git a/tests/baselines/reference/jsxComplexSignatureHasApplicabilityError.errors.txt b/tests/baselines/reference/jsxComplexSignatureHasApplicabilityError.errors.txt
deleted file mode 100644
index a10ae139e0381..0000000000000
--- a/tests/baselines/reference/jsxComplexSignatureHasApplicabilityError.errors.txt
+++ /dev/null
@@ -1,626 +0,0 @@
-tests/cases/compiler/jsxComplexSignatureHasApplicabilityError.tsx(31,17): error TS2769: No overload matches this call.
- Overload 1 of 2, '(props: Readonly>>): ReactSelectClass>', gave the following error.
- Type 'ExtractValueType | Option> | undefined' is not assignable to type 'string | number | boolean | string[] | number[] | Option> | Options>'.
- Type 'undefined' is not assignable to type 'string | number | boolean | string[] | number[] | Option> | Options>'.
- Overload 2 of 2, '(props: ReactSelectProps>, context?: any): ReactSelectClass>', gave the following error.
- Type 'ExtractValueType | Option> | undefined' is not assignable to type 'string | number | boolean | string[] | number[] | Option> | Options>'.
-
-
-==== tests/cases/compiler/jsxComplexSignatureHasApplicabilityError.tsx (1 errors) ====
- ///
-
- import * as React from "react";
-
-
- interface Props {
- value?: Option | T;
- onChange?(value: Option | undefined): void;
- }
-
- type ExtractValueType = T extends ReactSelectProps ? U : never;
-
- export type ReactSingleSelectProps<
- WrappedProps extends ReactSelectProps
- > = Overwrite<
- Omit,
- Props>
- >;
-
- export function createReactSingleSelect<
- WrappedProps extends ReactSelectProps
- >(
- WrappedComponent: React.ComponentType
- ): React.ComponentType> {
- return (props) => {
- return (
- >
- {...props}
- multi={false}
- autosize={false}
- value={props.value}
- ~~~~~
-!!! error TS2769: No overload matches this call.
-!!! error TS2769: Overload 1 of 2, '(props: Readonly>>): ReactSelectClass>', gave the following error.
-!!! error TS2769: Type 'ExtractValueType | Option> | undefined' is not assignable to type 'string | number | boolean | string[] | number[] | Option> | Options>'.
-!!! error TS2769: Type 'undefined' is not assignable to type 'string | number | boolean | string[] | number[] | Option> | Options>'.
-!!! error TS2769: Overload 2 of 2, '(props: ReactSelectProps>, context?: any): ReactSelectClass>', gave the following error.
-!!! error TS2769: Type 'ExtractValueType | Option> | undefined' is not assignable to type 'string | number | boolean | string[] | number[] | Option> | Options>'.
-!!! related TS6500 tests/cases/compiler/jsxComplexSignatureHasApplicabilityError.tsx:567:5: The expected type comes from property 'value' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes>> & Readonly<{ children?: ReactNode; }> & Readonly>>'
-!!! related TS6500 tests/cases/compiler/jsxComplexSignatureHasApplicabilityError.tsx:567:5: The expected type comes from property 'value' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes>> & Readonly<{ children?: ReactNode; }> & Readonly>>'
- onChange={(value) => {
- if (props.onChange) {
- props.onChange(value === null ? undefined : value);
- }
- }}
- />
- );
- };
- }
-
-
- // Copied from "type-zoo" version 3.4.0
- export type Omit = T extends any ? Pick> : never;
- export type Overwrite = Omit & U;
-
- // Everything below here copied from "@types/react-select" version 1.3.4
- declare class ReactSelectClass extends React.Component> {
- focus(): void;
- setValue(value: Option): void;
- }
-
- export type OptionComponentType = React.ComponentType>;
- export type ValueComponentType = React.ComponentType>;
-
- export type HandlerRendererResult = JSX.Element | null | false;
-
- // Handlers
- export type FocusOptionHandler = (option: Option) => void;
- export type SelectValueHandler = (option: Option) => void;
- export type ArrowRendererHandler = (props: ArrowRendererProps) => HandlerRendererResult;
- export type ClearRendererHandler = () => HandlerRendererResult;
- export type FilterOptionHandler = (option: Option, filter: string) => boolean;
- export type FilterOptionsHandler = (options: Options, filter: string, currentValues: Options) => Options;
- export type InputRendererHandler = (props: { [key: string]: any }) => HandlerRendererResult;
- export type MenuRendererHandler = (props: MenuRendererProps) => HandlerRendererResult;
- export type OnCloseHandler = () => void;
- export type OnInputChangeHandler = (inputValue: string) => string;
- export type OnInputKeyDownHandler = React.KeyboardEventHandler;
- export type OnMenuScrollToBottomHandler = () => void;
- export type OnOpenHandler = () => void;
- export type OnFocusHandler = React.FocusEventHandler;
- export type OnBlurHandler = React.FocusEventHandler;
- export type OptionRendererHandler = (option: Option) => HandlerRendererResult;
- export type ValueRendererHandler = (option: Option, index?: number) => HandlerRendererResult;
- export type OnValueClickHandler = (option: Option, event: React.MouseEvent) => void;
- export type IsOptionUniqueHandler = (arg: { option: Option, options: Options, labelKey: string, valueKey: string }) => boolean;
- export type IsValidNewOptionHandler = (arg: { label: string }) => boolean;
- export type NewOptionCreatorHandler = (arg: { label: string, labelKey: string, valueKey: string }) => Option;
- export type PromptTextCreatorHandler = (filterText: string) => string;
- export type ShouldKeyDownEventCreateNewOptionHandler = (arg: { keyCode: number }) => boolean;
-
- export type OnChangeSingleHandler = OnChangeHandler>;
- export type OnChangeMultipleHandler = OnChangeHandler>;
- export type OnChangeHandler | Options> = (newValue: TOption | null) => void;
- export type OnNewOptionClickHandler = (option: Option) => void;
-
- export type LoadOptionsHandler = LoadOptionsAsyncHandler | LoadOptionsLegacyHandler;
- export type LoadOptionsAsyncHandler = (input: string) => Promise>;
- export type LoadOptionsLegacyHandler = (input: string, callback: (err: any, result: AutocompleteResult) => void) => void;
-
- export interface AutocompleteResult {
- /** The search-results to be displayed */
- options: Options;
- /**
- * Should be set to true, if and only if a longer query with the same prefix
- * would return a subset of the results
- * If set to true, more specific queries will not be sent to the server.
- */
- complete: boolean;
- }
-
- export type Options = Array>;
-
- export interface Option {
- /** Text for rendering */
- label?: string;
- /** Value for searching */
- value?: TValue;
- /**
- * Allow this option to be cleared
- * @default true
- */
- clearableValue?: boolean;
- /**
- * Do not allow this option to be selected
- * @default false
- */
- disabled?: boolean;
- /**
- * In the event that a custom menuRenderer is provided, Option should be able
- * to accept arbitrary key-value pairs. See react-virtualized-select.
- */
- [property: string]: any;
- }
-
- export type OptionValues = string | number | boolean;
-
- export interface MenuRendererProps {
- /**
- * The currently focused option; should be visible in the menu by default.
- * default {}
- */
- focusedOption: Option;
-
- /**
- * Callback to focus a new option; receives the option as a parameter.
- */
- focusOption: FocusOptionHandler;
-
- /**
- * Option labels are accessible with this string key.
- */
- labelKey: string;
-
- /**
- * Ordered array of options to render.
- */
- options: Options;
-
- /**
- * Callback to select a new option; receives the option as a parameter.
- */
- selectValue: SelectValueHandler;
-
- /**
- * Array of currently selected options.
- */
- valueArray: Options;
-
- /**
- * Callback to remove selection from option; receives the option as a parameter.
- */
- removeValue: SelectValueHandler;
-
- /**
- * function which returns a custom way to render the options in the menu
- */
- optionRenderer: OptionRendererHandler;
- }
-
- export interface OptionComponentProps {
- /**
- * Classname(s) to apply to the option component.
- */
- className?: string;
-
- /**
- * Currently focused option.
- */
- focusOption?: Option;
-
- inputValue?: string;
- instancePrefix?: string;
-
- /**
- * True if this option is disabled.
- */
- isDisabled?: boolean;
-
- /**
- * True if this option is focused.
- */
- isFocused?: boolean;
-
- /**
- * True if this option is selected.
- */
- isSelected?: boolean;
-
- /**
- * Callback to be invoked when this option is focused.
- */
- onFocus?: (option: Option, event: any) => void;
-
- /**
- * Callback to be invoked when this option is selected.
- */
- onSelect?: (option: Option, event: any) => void;
-
- /**
- * Option to be rendered by this component.
- */
- option: Option;
-
- /**
- * Index of the option being rendered in the list
- */
- optionIndex?: number;
-
- /**
- * Callback to invoke when removing an option from a multi-selection. (Not necessarily the one
- * being rendered)
- */
- removeValue?: (value: TValue | TValue[]) => void;
-
- /**
- * Callback to invoke to select an option. (Not necessarily the one being rendered)
- */
- selectValue?: (value: TValue | TValue[]) => void;
- }
-
- export interface ArrowRendererProps {
- /**
- * Arrow mouse down event handler.
- */
- onMouseDown: React.MouseEventHandler;
-
- /**
- * whether the Select is open or not.
- */
- isOpen: boolean;
- }
-
- export interface ValueComponentProps {
- disabled: ReactSelectProps['disabled'];
- id: string;
- instancePrefix: string;
- onClick: OnValueClickHandler | null;
- onRemove?: SelectValueHandler;
- placeholder: ReactSelectProps['placeholder'];
- value: Option;
- values?: Array>;
- }
-
- export interface ReactSelectProps extends React.Props> {
- /**
- * text to display when `allowCreate` is true.
- * @default 'Add "{label}"?'
- */
- addLabelText?: string;
- /**
- * renders a custom drop-down arrow to be shown in the right-hand side of the select.
- * @default undefined
- */
- arrowRenderer?: ArrowRendererHandler | null;
- /**
- * blurs the input element after a selection has been made. Handy for lowering the keyboard on mobile devices.
- * @default false
- */
- autoBlur?: boolean;
- /**
- * autofocus the component on mount
- * @deprecated. Use autoFocus instead
- * @default false
- */
- autofocus?: boolean;
- /**
- * autofocus the component on mount
- * @default false
- */
- autoFocus?: boolean;
- /**
- * If enabled, the input will expand as the length of its value increases
- */
- autosize?: boolean;
- /**
- * whether pressing backspace removes the last item when there is no input value
- * @default true
- */
- backspaceRemoves?: boolean;
- /**
- * Message to use for screenreaders to press backspace to remove the current item
- * {label} is replaced with the item label
- * @default "Press backspace to remove..."
- */
- backspaceToRemoveMessage?: string;
- /**
- * CSS className for the outer element
- */
- className?: string;
- /**
- * Prefix prepended to element default className if no className is defined
- */
- classNamePrefix?: string;
- /**
- * title for the "clear" control when `multi` is true
- * @default "Clear all"
- */
- clearAllText?: string;
- /**
- * Renders a custom clear to be shown in the right-hand side of the select when clearable true
- * @default undefined
- */
- clearRenderer?: ClearRendererHandler;
- /**
- * title for the "clear" control
- * @default "Clear value"
- */
- clearValueText?: string;
- /**
- * whether to close the menu when a value is selected
- * @default true
- */
- closeOnSelect?: boolean;
- /**
- * whether it is possible to reset value. if enabled, an X button will appear at the right side.
- * @default true
- */
- clearable?: boolean;
- /**
- * whether backspace removes an item if there is no text input
- * @default true
- */
- deleteRemoves?: boolean;
- /**
- * delimiter to use to join multiple values
- * @default ","
- */
- delimiter?: string;
- /**
- * whether the Select is disabled or not
- * @default false
- */
- disabled?: boolean;
- /**
- * whether escape clears the value when the menu is closed
- * @default true
- */
- escapeClearsValue?: boolean;
- /**
- * method to filter a single option
- */
- filterOption?: FilterOptionHandler;
- /**
- * method to filter the options array
- */
- filterOptions?: FilterOptionsHandler;
- /**
- * id for the underlying HTML input element
- * @default undefined
- */
- id?: string;
- /**
- * whether to strip diacritics when filtering
- * @default true
- */
- ignoreAccents?: boolean;
- /**
- * whether to perform case-insensitive filtering
- * @default true
- */
- ignoreCase?: boolean;
- /**
- * custom attributes for the Input (in the Select-control) e.g: {'data-foo': 'bar'}
- * @default {}
- */
- inputProps?: { [key: string]: any };
- /**
- * renders a custom input
- */
- inputRenderer?: InputRendererHandler;
- /**
- * allows for synchronization of component id's on server and client.
- * @see https://github.com/JedWatson/react-select/pull/1105
- */
- instanceId?: string;
- /**
- * whether the Select is loading externally or not (such as options being loaded).
- * if true, a loading spinner will be shown at the right side.
- * @default false
- */
- isLoading?: boolean;
- /**
- * (legacy mode) joins multiple values into a single form field with the delimiter
- * @default false
- */
- joinValues?: boolean;
- /**
- * the option property to use for the label
- * @default "label"
- */
- labelKey?: string;
- /**
- * (any, start) match the start or entire string when filtering
- * @default "any"
- */
- matchPos?: string;
- /**
- * (any, label, value) which option property to filter on
- * @default "any"
- */
- matchProp?: string;
- /**
- * buffer of px between the base of the dropdown and the viewport to shift if menu doesnt fit in viewport
- * @default 0
- */
- menuBuffer?: number;
- /**
- * optional style to apply to the menu container
- */
- menuContainerStyle?: React.CSSProperties;
- /**
- * renders a custom menu with options
- */
- menuRenderer?: MenuRendererHandler;
- /**
- * optional style to apply to the menu
- */
- menuStyle?: React.CSSProperties;
- /**
- * multi-value input
- * @default false
- */
- multi?: boolean;
- /**
- * field name, for hidden ` ` tag
- */
- name?: string;
- /**
- * placeholder displayed when there are no matching search results or a falsy value to hide it
- * @default "No results found"
- */
- noResultsText?: string | JSX.Element;
- /**
- * onBlur handler: function (event) {}
- */
- onBlur?: OnBlurHandler;
- /**
- * whether to clear input on blur or not
- * @default true
- */
- onBlurResetsInput?: boolean;
- /**
- * whether the input value should be reset when options are selected.
- * Also input value will be set to empty if 'onSelectResetsInput=true' and
- * Select will get new value that not equal previous value.
- * @default true
- */
- onSelectResetsInput?: boolean;
- /**
- * whether to clear input when closing the menu through the arrow
- * @default true
- */
- onCloseResetsInput?: boolean;
- /**
- * onChange handler: function (newValue) {}
- */
- onChange?: OnChangeHandler;
- /**
- * fires when the menu is closed
- */
- onClose?: OnCloseHandler;
- /**
- * onFocus handler: function (event) {}
- */
- onFocus?: OnFocusHandler;
- /**
- * onInputChange handler: function (inputValue) {}
- */
- onInputChange?: OnInputChangeHandler;
- /**
- * onInputKeyDown handler: function (keyboardEvent) {}
- */
- onInputKeyDown?: OnInputKeyDownHandler;
- /**
- * fires when the menu is scrolled to the bottom; can be used to paginate options
- */
- onMenuScrollToBottom?: OnMenuScrollToBottomHandler;
- /**
- * fires when the menu is opened
- */
- onOpen?: OnOpenHandler;
- /**
- * boolean to enable opening dropdown when focused
- * @default false
- */
- openOnClick?: boolean;
- /**
- * open the options menu when the input gets focus (requires searchable = true)
- * @default true
- */
- openOnFocus?: boolean;
- /**
- * className to add to each option component
- */
- optionClassName?: string;
- /**
- * option component to render in dropdown
- */
- optionComponent?: OptionComponentType;
- /**
- * function which returns a custom way to render the options in the menu
- */
- optionRenderer?: OptionRendererHandler;
- /**
- * array of Select options
- * @default false
- */
- options?: Options;
- /**
- * number of options to jump when using page up/down keys
- * @default 5
- */
- pageSize?: number;
- /**
- * field placeholder, displayed when there's no value
- * @default "Select..."
- */
- placeholder?: string | JSX.Element;
- /**
- * whether the selected option is removed from the dropdown on multi selects
- * @default true
- */
- removeSelected?: boolean;
- /**
- * applies HTML5 required attribute when needed
- * @default false
- */
- required?: boolean;
- /**
- * value to use when you clear the control
- */
- resetValue?: any;
- /**
- * use react-select in right-to-left direction
- * @default false
- */
- rtl?: boolean;
- /**
- * whether the viewport will shift to display the entire menu when engaged
- * @default true
- */
- scrollMenuIntoView?: boolean;
- /**
- * whether to enable searching feature or not
- * @default true;
- */
- searchable?: boolean;
- /**
- * whether to select the currently focused value when the [tab] key is pressed
- */
- tabSelectsValue?: boolean;
- /**
- * initial field value
- */
- value?: Option | Options | string | string[] | number | number[] | boolean;
- /**
- * the option property to use for the value
- * @default "value"
- */
- valueKey?: string;
- /**
- * function which returns a custom way to render the value selected
- * @default false
- */
- valueRenderer?: ValueRendererHandler;
- /**
- * optional style to apply to the control
- */
- style?: React.CSSProperties;
-
- /**
- * optional tab index of the control
- */
- tabIndex?: string | number;
-
- /**
- * value component to render
- */
- valueComponent?: ValueComponentType;
-
- /**
- * optional style to apply to the component wrapper
- */
- wrapperStyle?: React.CSSProperties;
-
- /**
- * onClick handler for value labels: function (value, event) {}
- */
- onValueClick?: OnValueClickHandler;
-
- /**
- * pass the value to onChange as a simple value (legacy pre 1.0 mode), defaults to false
- */
- simpleValue?: boolean;
- }
-
\ No newline at end of file
diff --git a/tests/baselines/reference/jsxNamespaceGlobalReexport.types b/tests/baselines/reference/jsxNamespaceGlobalReexport.types
index 19acd72ebfed1..85fc07e3497e3 100644
--- a/tests/baselines/reference/jsxNamespaceGlobalReexport.types
+++ b/tests/baselines/reference/jsxNamespaceGlobalReexport.types
@@ -90,13 +90,13 @@ import { JSXInternal } from '..';
>JSXInternal : any
export function jsx(
->jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild;}, key?: string | undefined): VNode; (type: ComponentType
, props: P & { children?: ComponentChild; }, key?: string | undefined): VNode; }
+>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild;}, key?: string | undefined): VNode; (type: ComponentType
, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode; }
type: string,
>type : string
props: JSXInternal.HTMLAttributes &
->props : JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild; }
+>props : JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild | undefined; }
>JSXInternal : any
JSXInternal.SVGAttributes &
@@ -110,13 +110,13 @@ export function jsx(
): VNode;
export function jsx(
->jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild; }, key?: string | undefined): VNode; (type: ComponentType
, props: Attributes & P & { children?: ComponentChild;}, key?: string | undefined): VNode; }
+>jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode; (type: ComponentType
, props: Attributes & P & { children?: ComponentChild;}, key?: string | undefined): VNode; }
type: ComponentType,
>type : ComponentType
props: Attributes & P & { children?: ComponentChild },
->props : P & { children?: ComponentChild; }
+>props : P & { children?: ComponentChild | undefined; }
>children : ComponentChild | undefined
key?: string
@@ -125,13 +125,13 @@ export function jsx
(
): VNode;
export function jsxs(
->jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild[];}, key?: string | undefined): VNode; (type: ComponentType
, props: P & { children?: ComponentChild[]; }, key?: string | undefined): VNode; }
+>jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild[];}, key?: string | undefined): VNode; (type: ComponentType
, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode; }
type: string,
>type : string
props: JSXInternal.HTMLAttributes &
->props : JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild[]; }
+>props : JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild[] | undefined; }
>JSXInternal : any
JSXInternal.SVGAttributes &
@@ -145,13 +145,13 @@ export function jsxs(
): VNode;
export function jsxs(
->jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild[]; }, key?: string | undefined): VNode; (type: ComponentType
, props: Attributes & P & { children?: ComponentChild[];}, key?: string | undefined): VNode; }
+>jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode; (type: ComponentType
, props: Attributes & P & { children?: ComponentChild[];}, key?: string | undefined): VNode; }
type: ComponentType,
>type : ComponentType
props: Attributes & P & { children?: ComponentChild[] },
->props : P & { children?: ComponentChild[]; }
+>props : P & { children?: ComponentChild[] | undefined; }
>children : ComponentChild[] | undefined
key?: string
@@ -160,13 +160,13 @@ export function jsxs
(
): VNode;
export function jsxDEV(
->jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChildren;}, key?: string | undefined): VNode; (type: ComponentType
, props: P & { children?: ComponentChildren; }, key?: string | undefined): VNode; }
+>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChildren;}, key?: string | undefined): VNode; (type: ComponentType
, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode; }
type: string,
>type : string
props: JSXInternal.HTMLAttributes &
->props : JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChildren; }
+>props : JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChildren | undefined; }
>JSXInternal : any
JSXInternal.SVGAttributes &
@@ -180,13 +180,13 @@ export function jsxDEV(
): VNode;
export function jsxDEV(
->jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChildren; }, key?: string | undefined): VNode; (type: ComponentType
, props: Attributes & P & { children?: ComponentChildren;}, key?: string | undefined): VNode; }
+>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode; (type: ComponentType
, props: Attributes & P & { children?: ComponentChildren;}, key?: string | undefined): VNode; }
type: ComponentType,
>type : ComponentType
props: Attributes & P & { children?: ComponentChildren },
->props : P & { children?: ComponentChildren; }
+>props : P & { children?: ComponentChildren | undefined; }
>children : ComponentChildren | undefined
key?: string
diff --git a/tests/baselines/reference/jsxNamespaceGlobalReexportMissingAliasTarget.types b/tests/baselines/reference/jsxNamespaceGlobalReexportMissingAliasTarget.types
index 0262ca9dfafd1..7cc6f7937322c 100644
--- a/tests/baselines/reference/jsxNamespaceGlobalReexportMissingAliasTarget.types
+++ b/tests/baselines/reference/jsxNamespaceGlobalReexportMissingAliasTarget.types
@@ -90,13 +90,13 @@ import { JSXInternal } from '..';
>JSXInternal : any
export function jsx(
->jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild;}, key?: string | undefined): VNode; (type: ComponentType
, props: P & { children?: ComponentChild; }, key?: string | undefined): VNode; }
+>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record & { children?: ComponentChild;}, key?: string | undefined): VNode; (type: ComponentType
, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode; }
type: string,
>type : string
props: JSXInternal.HTMLAttributes &
->props : JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild; }
+>props : JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record & { children?: ComponentChild | undefined; }
>JSXInternal : any
JSXInternal.SVGAttributes &
@@ -110,13 +110,13 @@ export function jsx(
): VNode;
export function jsx(
->jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record