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 & { 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/jsxNamespaceImplicitImportJSXNamespace.types b/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespace.types index ee59395483c48..8869f10731bb5 100644 --- a/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespace.types +++ b/tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespace.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 @@ -126,13 +126,13 @@ export function jsx

( 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 & @@ -146,13 +146,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 @@ -162,13 +162,13 @@ export function jsxs

( 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 & @@ -182,13 +182,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/logicalAssignment8(target=es2015).types b/tests/baselines/reference/logicalAssignment8(target=es2015).types index 468be31f07b9b..ad2740ed3442d 100644 --- a/tests/baselines/reference/logicalAssignment8(target=es2015).types +++ b/tests/baselines/reference/logicalAssignment8(target=es2015).types @@ -1,6 +1,6 @@ === tests/cases/conformance/es2021/logicalAssignment/logicalAssignment8.ts === declare const bar: { value?: number[] } | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined function foo1(results: number[] | undefined) { @@ -15,7 +15,7 @@ function foo1(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number @@ -34,7 +34,7 @@ function foo2(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number @@ -53,7 +53,7 @@ function foo3(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number diff --git a/tests/baselines/reference/logicalAssignment8(target=es2020).types b/tests/baselines/reference/logicalAssignment8(target=es2020).types index 468be31f07b9b..ad2740ed3442d 100644 --- a/tests/baselines/reference/logicalAssignment8(target=es2020).types +++ b/tests/baselines/reference/logicalAssignment8(target=es2020).types @@ -1,6 +1,6 @@ === tests/cases/conformance/es2021/logicalAssignment/logicalAssignment8.ts === declare const bar: { value?: number[] } | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined function foo1(results: number[] | undefined) { @@ -15,7 +15,7 @@ function foo1(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number @@ -34,7 +34,7 @@ function foo2(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number @@ -53,7 +53,7 @@ function foo3(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number diff --git a/tests/baselines/reference/logicalAssignment8(target=es2021).types b/tests/baselines/reference/logicalAssignment8(target=es2021).types index 468be31f07b9b..ad2740ed3442d 100644 --- a/tests/baselines/reference/logicalAssignment8(target=es2021).types +++ b/tests/baselines/reference/logicalAssignment8(target=es2021).types @@ -1,6 +1,6 @@ === tests/cases/conformance/es2021/logicalAssignment/logicalAssignment8.ts === declare const bar: { value?: number[] } | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined function foo1(results: number[] | undefined) { @@ -15,7 +15,7 @@ function foo1(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number @@ -34,7 +34,7 @@ function foo2(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number @@ -53,7 +53,7 @@ function foo3(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number diff --git a/tests/baselines/reference/logicalAssignment8(target=esnext).types b/tests/baselines/reference/logicalAssignment8(target=esnext).types index 468be31f07b9b..ad2740ed3442d 100644 --- a/tests/baselines/reference/logicalAssignment8(target=esnext).types +++ b/tests/baselines/reference/logicalAssignment8(target=esnext).types @@ -1,6 +1,6 @@ === tests/cases/conformance/es2021/logicalAssignment/logicalAssignment8.ts === declare const bar: { value?: number[] } | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined function foo1(results: number[] | undefined) { @@ -15,7 +15,7 @@ function foo1(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number @@ -34,7 +34,7 @@ function foo2(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number @@ -53,7 +53,7 @@ function foo3(results: number[] | undefined) { >results : number[] | undefined >bar?.value ?? [] : number[] >bar?.value : number[] | undefined ->bar : { value?: number[]; } | undefined +>bar : { value?: number[] | undefined; } | undefined >value : number[] | undefined >[] : never[] >push : (...items: number[]) => number diff --git a/tests/baselines/reference/logicalAssignment9.types b/tests/baselines/reference/logicalAssignment9.types index f502dc93b4a03..76062618efb9e 100644 --- a/tests/baselines/reference/logicalAssignment9.types +++ b/tests/baselines/reference/logicalAssignment9.types @@ -1,19 +1,19 @@ === tests/cases/conformance/es2021/logicalAssignment/logicalAssignment9.ts === declare let x: { a?: boolean }; ->x : { a?: boolean; } +>x : { a?: boolean | undefined; } >a : boolean | undefined x.a ??= true; >x.a ??= true : boolean ->x.a : boolean ->x : { a?: boolean; } ->a : boolean +>x.a : boolean | undefined +>x : { a?: boolean | undefined; } +>a : boolean | undefined >true : true x.a &&= false; ->x.a &&= false : false ->x.a : boolean ->x : { a?: boolean; } ->a : boolean +>x.a &&= false : false | undefined +>x.a : boolean | undefined +>x : { a?: boolean | undefined; } +>a : boolean | undefined >false : false diff --git a/tests/baselines/reference/mappedTypesArraysTuples.js b/tests/baselines/reference/mappedTypesArraysTuples.js index d1255fb2e500f..7bd4b03a6e54f 100644 --- a/tests/baselines/reference/mappedTypesArraysTuples.js +++ b/tests/baselines/reference/mappedTypesArraysTuples.js @@ -178,15 +178,15 @@ declare let y12: { }; declare function nonpartial(x: Partial): T; declare let x20: [number | undefined, string?, ...boolean[]]; -declare let y20: [number | undefined, string, ...boolean[]]; +declare let y20: [number, string, ...boolean[]]; declare let x21: (number | undefined)[]; -declare let y21: (number | undefined)[]; +declare let y21: number[]; declare let x22: { a: number | undefined; b?: string[]; }; declare let y22: { - a: number | undefined; + a: number; b: string[]; }; declare type Awaited = T extends PromiseLike ? U : T; diff --git a/tests/baselines/reference/mappedTypesArraysTuples.types b/tests/baselines/reference/mappedTypesArraysTuples.types index b7ebbbec36765..daa27b7958d07 100644 --- a/tests/baselines/reference/mappedTypesArraysTuples.types +++ b/tests/baselines/reference/mappedTypesArraysTuples.types @@ -10,7 +10,7 @@ type T00 = Boxified<[number, string?, ...boolean[]]>; >T00 : [Box, Box?, ...Box[]] type T01 = Partial<[number, string?, ...boolean[]]>; ->T01 : [number?, string?, ...(boolean | undefined)[]] +>T01 : [(number | undefined)?, (string | undefined)?, ...(boolean | undefined)[]] type T02 = Required<[number, string?, ...boolean[]]>; >T02 : [number, string, ...boolean[]] @@ -124,33 +124,33 @@ declare function nonpartial(x: Partial): T; >x : Partial declare let x20: [number | undefined, string?, ...boolean[]]; ->x20 : [number | undefined, string?, ...boolean[]] +>x20 : [number | undefined, (string | undefined)?, ...boolean[]] let y20 = nonpartial(x20); ->y20 : [number | undefined, string, ...boolean[]] ->nonpartial(x20) : [number | undefined, string, ...boolean[]] +>y20 : [number, string, ...boolean[]] +>nonpartial(x20) : [number, string, ...boolean[]] >nonpartial : (x: Partial) => T ->x20 : [number | undefined, string?, ...boolean[]] +>x20 : [number | undefined, (string | undefined)?, ...boolean[]] declare let x21: (number | undefined)[]; >x21 : (number | undefined)[] let y21 = nonpartial(x21); ->y21 : (number | undefined)[] ->nonpartial(x21) : (number | undefined)[] +>y21 : number[] +>nonpartial(x21) : number[] >nonpartial : (x: Partial) => T >x21 : (number | undefined)[] declare let x22: { a: number | undefined, b?: string[] }; ->x22 : { a: number | undefined; b?: string[]; } +>x22 : { a: number | undefined; b?: string[] | undefined; } >a : number | undefined >b : string[] | undefined let y22 = nonpartial(x22); ->y22 : { a: number | undefined; b: string[]; } ->nonpartial(x22) : { a: number | undefined; b: string[]; } +>y22 : { a: number; b: string[]; } +>nonpartial(x22) : { a: number; b: string[]; } >nonpartial : (x: Partial) => T ->x22 : { a: number | undefined; b?: string[]; } +>x22 : { a: number | undefined; b?: string[] | undefined; } type Awaited = T extends PromiseLike ? U : T; >Awaited : Awaited diff --git a/tests/baselines/reference/narrowingOfQualifiedNames.types b/tests/baselines/reference/narrowingOfQualifiedNames.types index 17208fb24aa1d..f9ec86f075ae8 100644 --- a/tests/baselines/reference/narrowingOfQualifiedNames.types +++ b/tests/baselines/reference/narrowingOfQualifiedNames.types @@ -56,10 +56,10 @@ function init(properties: IProperties) { interface DeepOptional { a?: { ->a : { b?: { c?: string;}; } | undefined +>a : { b?: { c?: string | undefined; } | undefined; } | undefined b?: { ->b : { c?: string; } | undefined +>b : { c?: string | undefined; } | undefined c?: string >c : string | undefined @@ -72,32 +72,32 @@ function init2(foo: DeepOptional) { >foo : DeepOptional if (foo.a) { ->foo.a : { b?: { c?: string; }; } | undefined +>foo.a : { b?: { c?: string | undefined; } | undefined; } | undefined >foo : DeepOptional ->a : { b?: { c?: string; }; } | undefined +>a : { b?: { c?: string | undefined; } | undefined; } | undefined type A = typeof foo.a; ->A : { b?: { c?: string; }; } ->foo.a : { b?: { c?: string; }; } +>A : { b?: { c?: string | undefined; } | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } +>a : { b?: { c?: string | undefined; } | undefined; } type B = typeof foo.a.b; ->B : { c?: string; } | undefined ->foo.a.b : { c?: string; } | undefined ->foo.a : { b?: { c?: string; }; } +>B : { c?: string | undefined; } | undefined +>foo.a.b : { c?: string | undefined; } | undefined +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } | undefined +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } | undefined type C = typeof foo.a.b.c; >C : string | undefined >foo.a.b.c : string | undefined ->foo.a.b : { c?: string; } | undefined ->foo.a : { b?: { c?: string; }; } +>foo.a.b : { c?: string | undefined; } | undefined +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } | undefined +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } | undefined >c : string | undefined for(const _ of [1]) { @@ -106,58 +106,58 @@ function init2(foo: DeepOptional) { >1 : 1 type A = typeof foo.a; ->A : { b?: { c?: string; }; } ->foo.a : { b?: { c?: string; }; } +>A : { b?: { c?: string | undefined; } | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } +>a : { b?: { c?: string | undefined; } | undefined; } type B = typeof foo.a.b; ->B : { c?: string; } | undefined ->foo.a.b : { c?: string; } | undefined ->foo.a : { b?: { c?: string; }; } +>B : { c?: string | undefined; } | undefined +>foo.a.b : { c?: string | undefined; } | undefined +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } | undefined +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } | undefined type C = typeof foo.a.b.c; >C : string | undefined >foo.a.b.c : string | undefined ->foo.a.b : { c?: string; } | undefined ->foo.a : { b?: { c?: string; }; } +>foo.a.b : { c?: string | undefined; } | undefined +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } | undefined +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } | undefined >c : string | undefined if (foo.a.b) { ->foo.a.b : { c?: string; } | undefined ->foo.a : { b?: { c?: string; }; } +>foo.a.b : { c?: string | undefined; } | undefined +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } | undefined +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } | undefined type A = typeof foo.a; ->A : { b?: { c?: string; }; } ->foo.a : { b?: { c?: string; }; } +>A : { b?: { c?: string | undefined; } | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } +>a : { b?: { c?: string | undefined; } | undefined; } type B = typeof foo.a.b; ->B : { c?: string; } ->foo.a.b : { c?: string; } ->foo.a : { b?: { c?: string; }; } +>B : { c?: string | undefined; } +>foo.a.b : { c?: string | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } type C = typeof foo.a.b.c; >C : string | undefined >foo.a.b.c : string | undefined ->foo.a.b : { c?: string; } ->foo.a : { b?: { c?: string; }; } +>foo.a.b : { c?: string | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } >c : string | undefined for(const _ of [1]) { @@ -166,60 +166,60 @@ function init2(foo: DeepOptional) { >1 : 1 type A = typeof foo.a; ->A : { b?: { c?: string; }; } ->foo.a : { b?: { c?: string; }; } +>A : { b?: { c?: string | undefined; } | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } +>a : { b?: { c?: string | undefined; } | undefined; } type B = typeof foo.a.b; ->B : { c?: string; } ->foo.a.b : { c?: string; } ->foo.a : { b?: { c?: string; }; } +>B : { c?: string | undefined; } +>foo.a.b : { c?: string | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } type C = typeof foo.a.b.c; >C : string | undefined >foo.a.b.c : string | undefined ->foo.a.b : { c?: string; } ->foo.a : { b?: { c?: string; }; } +>foo.a.b : { c?: string | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } >c : string | undefined if (foo.a.b.c) { >foo.a.b.c : string | undefined ->foo.a.b : { c?: string; } ->foo.a : { b?: { c?: string; }; } +>foo.a.b : { c?: string | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } >c : string | undefined type A = typeof foo.a; ->A : { b?: { c?: string; }; } ->foo.a : { b?: { c?: string; }; } +>A : { b?: { c?: string | undefined; } | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } +>a : { b?: { c?: string | undefined; } | undefined; } type B = typeof foo.a.b; ->B : { c?: string; } ->foo.a.b : { c?: string; } ->foo.a : { b?: { c?: string; }; } +>B : { c?: string | undefined; } +>foo.a.b : { c?: string | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } type C = typeof foo.a.b.c; >C : string >foo.a.b.c : string ->foo.a.b : { c?: string; } ->foo.a : { b?: { c?: string; }; } +>foo.a.b : { c?: string | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } >c : string for(const _ of [1]) { @@ -228,27 +228,27 @@ function init2(foo: DeepOptional) { >1 : 1 type A = typeof foo.a; ->A : { b?: { c?: string; }; } ->foo.a : { b?: { c?: string; }; } +>A : { b?: { c?: string | undefined; } | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } +>a : { b?: { c?: string | undefined; } | undefined; } type B = typeof foo.a.b; ->B : { c?: string; } ->foo.a.b : { c?: string; } ->foo.a : { b?: { c?: string; }; } +>B : { c?: string | undefined; } +>foo.a.b : { c?: string | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } type C = typeof foo.a.b.c; >C : string >foo.a.b.c : string ->foo.a.b : { c?: string; } ->foo.a : { b?: { c?: string; }; } +>foo.a.b : { c?: string | undefined; } +>foo.a : { b?: { c?: string | undefined; } | undefined; } >foo : DeepOptional ->a : { b?: { c?: string; }; } ->b : { c?: string; } +>a : { b?: { c?: string | undefined; } | undefined; } +>b : { c?: string | undefined; } >c : string } } diff --git a/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.types b/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.types index 228e7c80e4795..8e923b5c82a24 100644 --- a/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.types +++ b/tests/baselines/reference/noUncheckedIndexedAccessDestructuring.types @@ -158,7 +158,7 @@ declare let target_string_arr: string[]; [,,, ...target_string_arr] = strArray; // Should OK >[,,, ...target_string_arr] = strArray : string[] ->[,,, ...target_string_arr] : [never?, never?, never?, ...string[]] +>[,,, ...target_string_arr] : [undefined, undefined, undefined, ...string[]] > : undefined > : undefined > : undefined diff --git a/tests/baselines/reference/normalizedIntersectionTooComplex.types b/tests/baselines/reference/normalizedIntersectionTooComplex.types index 369b087cf8d24..e7a49a5058317 100644 --- a/tests/baselines/reference/normalizedIntersectionTooComplex.types +++ b/tests/baselines/reference/normalizedIntersectionTooComplex.types @@ -20,112 +20,112 @@ type CtorOf = (arg: UnionToIntersection) => T; interface Big { "0": { common?: string; "0"?: number, ref?: Obj | Func; } ->"0" : { common?: string; "0"?: number; ref?: Obj | Func; } +>"0" : { common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"0" : number | undefined ->ref : Obj<{ common?: string; "0"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "0"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "1": { common?: string; "1"?: number, ref?: Obj | Func; } ->"1" : { common?: string; "1"?: number; ref?: Obj | Func; } +>"1" : { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"1" : number | undefined ->ref : Obj<{ common?: string; "1"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "1"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "2": { common?: string; "2"?: number, ref?: Obj | Func; } ->"2" : { common?: string; "2"?: number; ref?: Obj | Func; } +>"2" : { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"2" : number | undefined ->ref : Obj<{ common?: string; "2"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "2"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "3": { common?: string; "3"?: number, ref?: Obj | Func; } ->"3" : { common?: string; "3"?: number; ref?: Obj | Func; } +>"3" : { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"3" : number | undefined ->ref : Obj<{ common?: string; "3"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "3"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "4": { common?: string; "4"?: number, ref?: Obj | Func; } ->"4" : { common?: string; "4"?: number; ref?: Obj | Func; } +>"4" : { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"4" : number | undefined ->ref : Obj<{ common?: string; "4"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "4"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "5": { common?: string; "5"?: number, ref?: Obj | Func; } ->"5" : { common?: string; "5"?: number; ref?: Obj | Func; } +>"5" : { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"5" : number | undefined ->ref : Obj<{ common?: string; "5"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "5"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "6": { common?: string; "6"?: number, ref?: Obj | Func; } ->"6" : { common?: string; "6"?: number; ref?: Obj | Func; } +>"6" : { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"6" : number | undefined ->ref : Obj<{ common?: string; "6"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "6"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "7": { common?: string; "7"?: number, ref?: Obj | Func; } ->"7" : { common?: string; "7"?: number; ref?: Obj | Func; } +>"7" : { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"7" : number | undefined ->ref : Obj<{ common?: string; "7"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "7"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "8": { common?: string; "8"?: number, ref?: Obj | Func; } ->"8" : { common?: string; "8"?: number; ref?: Obj | Func; } +>"8" : { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"8" : number | undefined ->ref : Obj<{ common?: string; "8"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "8"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "9": { common?: string; "9"?: number, ref?: Obj | Func; } ->"9" : { common?: string; "9"?: number; ref?: Obj | Func; } +>"9" : { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"9" : number | undefined ->ref : Obj<{ common?: string; "9"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "9"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "10": { common?: string; "10"?: number, ref?: Obj | Func; } ->"10" : { common?: string; "10"?: number; ref?: Obj | Func; } +>"10" : { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"10" : number | undefined ->ref : Obj<{ common?: string; "10"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "10"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "11": { common?: string; "11"?: number, ref?: Obj | Func; } ->"11" : { common?: string; "11"?: number; ref?: Obj | Func; } +>"11" : { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"11" : number | undefined ->ref : Obj<{ common?: string; "11"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "11"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "12": { common?: string; "12"?: number, ref?: Obj | Func; } ->"12" : { common?: string; "12"?: number; ref?: Obj | Func; } +>"12" : { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"12" : number | undefined ->ref : Obj<{ common?: string; "12"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "12"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "13": { common?: string; "13"?: number, ref?: Obj | Func; } ->"13" : { common?: string; "13"?: number; ref?: Obj | Func; } +>"13" : { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"13" : number | undefined ->ref : Obj<{ common?: string; "13"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "13"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "14": { common?: string; "14"?: number, ref?: Obj | Func; } ->"14" : { common?: string; "14"?: number; ref?: Obj | Func; } +>"14" : { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"14" : number | undefined ->ref : Obj<{ common?: string; "14"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "14"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "15": { common?: string; "15"?: number, ref?: Obj | Func; } ->"15" : { common?: string; "15"?: number; ref?: Obj | Func; } +>"15" : { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"15" : number | undefined ->ref : Obj<{ common?: string; "15"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "15"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "16": { common?: string; "16"?: number, ref?: Obj | Func; } ->"16" : { common?: string; "16"?: number; ref?: Obj | Func; } +>"16" : { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"16" : number | undefined ->ref : Obj<{ common?: string; "16"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "16"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined "17": { common?: string; "17"?: number, ref?: Obj | Func; } ->"17" : { common?: string; "17"?: number; ref?: Obj | Func; } +>"17" : { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; } >common : string | undefined >"17" : number | undefined ->ref : Obj<{ common?: string; "17"?: number; ref?: Obj | Func; }> | Func<{ common?: string; "17"?: number; ref?: Obj | Func; }> | undefined +>ref : Obj<{ common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> | Func<{ common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> | undefined } declare function getCtor(comp: T): CtorOf >getCtor : (comp: T) => CtorOf @@ -135,15 +135,15 @@ declare var all: keyof Big; >all : keyof Big const ctor = getCtor(all); ->ctor : CtorOf<{ common?: string; "0"?: number; ref?: Obj | Func; } | { common?: string; "1"?: number; ref?: Obj | Func; } | { common?: string; "2"?: number; ref?: Obj | Func; } | { common?: string; "3"?: number; ref?: Obj | Func; } | { common?: string; "4"?: number; ref?: Obj | Func; } | { common?: string; "5"?: number; ref?: Obj | Func; } | { common?: string; "6"?: number; ref?: Obj | Func; } | { common?: string; "7"?: number; ref?: Obj | Func; } | { common?: string; "8"?: number; ref?: Obj | Func; } | { common?: string; "9"?: number; ref?: Obj | Func; } | { common?: string; "10"?: number; ref?: Obj | Func; } | { common?: string; "11"?: number; ref?: Obj | Func; } | { common?: string; "12"?: number; ref?: Obj | Func; } | { common?: string; "13"?: number; ref?: Obj | Func; } | { common?: string; "14"?: number; ref?: Obj | Func; } | { common?: string; "15"?: number; ref?: Obj | Func; } | { common?: string; "16"?: number; ref?: Obj | Func; } | { common?: string; "17"?: number; ref?: Obj | Func; }> ->getCtor(all) : CtorOf<{ common?: string; "0"?: number; ref?: Obj | Func; } | { common?: string; "1"?: number; ref?: Obj | Func; } | { common?: string; "2"?: number; ref?: Obj | Func; } | { common?: string; "3"?: number; ref?: Obj | Func; } | { common?: string; "4"?: number; ref?: Obj | Func; } | { common?: string; "5"?: number; ref?: Obj | Func; } | { common?: string; "6"?: number; ref?: Obj | Func; } | { common?: string; "7"?: number; ref?: Obj | Func; } | { common?: string; "8"?: number; ref?: Obj | Func; } | { common?: string; "9"?: number; ref?: Obj | Func; } | { common?: string; "10"?: number; ref?: Obj | Func; } | { common?: string; "11"?: number; ref?: Obj | Func; } | { common?: string; "12"?: number; ref?: Obj | Func; } | { common?: string; "13"?: number; ref?: Obj | Func; } | { common?: string; "14"?: number; ref?: Obj | Func; } | { common?: string; "15"?: number; ref?: Obj | Func; } | { common?: string; "16"?: number; ref?: Obj | Func; } | { common?: string; "17"?: number; ref?: Obj | Func; }> +>ctor : CtorOf<{ common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> +>getCtor(all) : CtorOf<{ common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> >getCtor : (comp: T) => CtorOf >all : keyof Big const comp = ctor({ common: "ok", ref: x => console.log(x) }); ->comp : { common?: string; "0"?: number; ref?: Obj | Func; } | { common?: string; "1"?: number; ref?: Obj | Func; } | { common?: string; "2"?: number; ref?: Obj | Func; } | { common?: string; "3"?: number; ref?: Obj | Func; } | { common?: string; "4"?: number; ref?: Obj | Func; } | { common?: string; "5"?: number; ref?: Obj | Func; } | { common?: string; "6"?: number; ref?: Obj | Func; } | { common?: string; "7"?: number; ref?: Obj | Func; } | { common?: string; "8"?: number; ref?: Obj | Func; } | { common?: string; "9"?: number; ref?: Obj | Func; } | { common?: string; "10"?: number; ref?: Obj | Func; } | { common?: string; "11"?: number; ref?: Obj | Func; } | { common?: string; "12"?: number; ref?: Obj | Func; } | { common?: string; "13"?: number; ref?: Obj | Func; } | { common?: string; "14"?: number; ref?: Obj | Func; } | { common?: string; "15"?: number; ref?: Obj | Func; } | { common?: string; "16"?: number; ref?: Obj | Func; } | { common?: string; "17"?: number; ref?: Obj | Func; } ->ctor({ common: "ok", ref: x => console.log(x) }) : { common?: string; "0"?: number; ref?: Obj | Func; } | { common?: string; "1"?: number; ref?: Obj | Func; } | { common?: string; "2"?: number; ref?: Obj | Func; } | { common?: string; "3"?: number; ref?: Obj | Func; } | { common?: string; "4"?: number; ref?: Obj | Func; } | { common?: string; "5"?: number; ref?: Obj | Func; } | { common?: string; "6"?: number; ref?: Obj | Func; } | { common?: string; "7"?: number; ref?: Obj | Func; } | { common?: string; "8"?: number; ref?: Obj | Func; } | { common?: string; "9"?: number; ref?: Obj | Func; } | { common?: string; "10"?: number; ref?: Obj | Func; } | { common?: string; "11"?: number; ref?: Obj | Func; } | { common?: string; "12"?: number; ref?: Obj | Func; } | { common?: string; "13"?: number; ref?: Obj | Func; } | { common?: string; "14"?: number; ref?: Obj | Func; } | { common?: string; "15"?: number; ref?: Obj | Func; } | { common?: string; "16"?: number; ref?: Obj | Func; } | { common?: string; "17"?: number; ref?: Obj | Func; } ->ctor : CtorOf<{ common?: string; "0"?: number; ref?: Obj | Func; } | { common?: string; "1"?: number; ref?: Obj | Func; } | { common?: string; "2"?: number; ref?: Obj | Func; } | { common?: string; "3"?: number; ref?: Obj | Func; } | { common?: string; "4"?: number; ref?: Obj | Func; } | { common?: string; "5"?: number; ref?: Obj | Func; } | { common?: string; "6"?: number; ref?: Obj | Func; } | { common?: string; "7"?: number; ref?: Obj | Func; } | { common?: string; "8"?: number; ref?: Obj | Func; } | { common?: string; "9"?: number; ref?: Obj | Func; } | { common?: string; "10"?: number; ref?: Obj | Func; } | { common?: string; "11"?: number; ref?: Obj | Func; } | { common?: string; "12"?: number; ref?: Obj | Func; } | { common?: string; "13"?: number; ref?: Obj | Func; } | { common?: string; "14"?: number; ref?: Obj | Func; } | { common?: string; "15"?: number; ref?: Obj | Func; } | { common?: string; "16"?: number; ref?: Obj | Func; } | { common?: string; "17"?: number; ref?: Obj | Func; }> +>comp : { common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; } +>ctor({ common: "ok", ref: x => console.log(x) }) : { common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; } +>ctor : CtorOf<{ common?: string | undefined; "0"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "1"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "2"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "3"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "4"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "5"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "6"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "7"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "8"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "9"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "10"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "11"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "12"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "13"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "14"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "15"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "16"?: number | undefined; ref?: Obj | Func | undefined; } | { common?: string | undefined; "17"?: number | undefined; ref?: Obj | Func | undefined; }> >{ common: "ok", ref: x => console.log(x) } : { common: string; ref: (x: any) => void; } >common : string >"ok" : "ok" diff --git a/tests/baselines/reference/numericEnumMappedType.types b/tests/baselines/reference/numericEnumMappedType.types index 284923f54dc9e..bffec2ed8ca18 100644 --- a/tests/baselines/reference/numericEnumMappedType.types +++ b/tests/baselines/reference/numericEnumMappedType.types @@ -41,14 +41,14 @@ const e2: E2 = E2.ONE; b1[1] = "a"; >b1[1] = "a" : "a" ->b1[1] : string +>b1[1] : string | undefined >b1 : Bins1 >1 : 1 >"a" : "a" b1[e1] = "b"; >b1[e1] = "b" : "b" ->b1[e1] : string +>b1[e1] : string | undefined >b1 : Bins1 >e1 : E1.ONE >"b" : "b" diff --git a/tests/baselines/reference/objectLiteralNormalization.errors.txt b/tests/baselines/reference/objectLiteralNormalization.errors.txt index c7fa353f2b37b..bd14787178ba9 100644 --- a/tests/baselines/reference/objectLiteralNormalization.errors.txt +++ b/tests/baselines/reference/objectLiteralNormalization.errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(7,14): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(8,1): error TS2322: Type '{ b: string; }' is not assignable to type '{ a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; }'. +tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(7,14): error TS2322: Type 'number' is not assignable to type 'string | undefined'. +tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(8,1): error TS2322: Type '{ b: string; }' is not assignable to type '{ a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; }'. Type '{ b: string; }' is missing the following properties from type '{ a: number; b: string; c: boolean; }': a, c -tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(9,1): error TS2322: Type '{ c: true; }' is not assignable to type '{ a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; }'. +tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(9,1): error TS2322: Type '{ c: true; }' is not assignable to type '{ a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; }'. Type '{ c: true; }' is missing the following properties from type '{ a: number; b: string; c: boolean; }': a, b -tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(17,1): error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; }'. - Type '{ a: string; b: number; }' is not assignable to type '{ a?: never; b?: never; }'. +tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(17,1): error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; }'. + Type '{ a: string; b: number; }' is not assignable to type '{ a?: undefined; b?: undefined; }'. Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'never'. -tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(18,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; }'. + Type 'string' is not assignable to type 'undefined'. +tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(18,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; }'. Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: number; }'. tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(48,20): error TS2322: Type '2' is not assignable to type '1'. tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(49,14): error TS2322: Type '2' is not assignable to type '1'. @@ -22,15 +22,15 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts a1 = { a: 1 }; a1 = { a: 0, b: 0 }; // Error ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. -!!! related TS6500 tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts:2:47: The expected type comes from property 'b' which is declared here on type '{ a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; }' +!!! error TS2322: Type 'number' is not assignable to type 'string | undefined'. +!!! related TS6500 tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts:2:47: The expected type comes from property 'b' which is declared here on type '{ a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; }' a1 = { b: "y" }; // Error ~~ -!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; }'. +!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; }'. !!! error TS2322: Type '{ b: string; }' is missing the following properties from type '{ a: number; b: string; c: boolean; }': a, c a1 = { c: true }; // Error ~~ -!!! error TS2322: Type '{ c: true; }' is not assignable to type '{ a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; }'. +!!! error TS2322: Type '{ c: true; }' is not assignable to type '{ a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; }'. !!! error TS2322: Type '{ c: true; }' is missing the following properties from type '{ a: number; b: string; c: boolean; }': a, b let a2 = [{ a: 1, b: 2 }, { a: "abc" }, {}][0]; @@ -41,13 +41,13 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts a2 = {}; a2 = { a: "def", b: 20 }; // Error ~~ -!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; }'. -!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a?: never; b?: never; }'. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; }'. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a?: undefined; b?: undefined; }'. !!! error TS2322: Types of property 'a' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'never'. +!!! error TS2322: Type 'string' is not assignable to type 'undefined'. a2 = { a: 1 }; // Error ~~ -!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; }'. +!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; }'. !!! error TS2322: Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: number; }'. !!! related TS2728 tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts:11:19: 'b' is declared here. diff --git a/tests/baselines/reference/objectLiteralNormalization.js b/tests/baselines/reference/objectLiteralNormalization.js index 3f220403e89a4..aa2fa9c7ec2e0 100644 --- a/tests/baselines/reference/objectLiteralNormalization.js +++ b/tests/baselines/reference/objectLiteralNormalization.js @@ -104,12 +104,12 @@ var e4 = f({ a: 2 }, data); //// [objectLiteralNormalization.d.ts] declare let a1: { a: number; - b?: never; - c?: never; + b?: undefined; + c?: undefined; } | { a: number; b: string; - c?: never; + c?: undefined; } | { a: number; b: string; @@ -120,10 +120,10 @@ declare let a2: { b: number; } | { a: string; - b?: never; + b?: undefined; } | { - a?: never; - b?: never; + a?: undefined; + b?: undefined; }; declare let b1: { a: string; @@ -156,25 +156,25 @@ declare let opts: { baz?: boolean; }; declare let c1: { - foo?: string; - bar?: string; - baz?: boolean; + foo?: string | undefined; + bar?: string | undefined; + baz?: boolean | undefined; }; declare let c2: { - foo?: string; - bar?: string; - baz?: boolean; + foo?: string | undefined; + bar?: string | undefined; + baz?: boolean | undefined; }; declare let c3: { a: number; b: number; } | { - a?: never; - b?: never; + a?: undefined; + b?: undefined; }; declare let c4: { - a?: never; - b?: never; + a?: undefined; + b?: undefined; } | { a: number; b: number; @@ -184,21 +184,21 @@ declare let d1: { pos: { x: number; y: number; - a?: never; - b?: never; + a?: undefined; + b?: undefined; }; } | { kind: string; pos: { a: string; - x?: never; - y?: never; - b?: never; + x?: undefined; + y?: undefined; + b?: undefined; } | { b: number; - x?: never; - y?: never; - a?: never; + x?: undefined; + y?: undefined; + a?: undefined; }; }; declare function f(...items: T[]): T; @@ -212,17 +212,17 @@ declare let e1: { b: number; } | { a: string; - b?: never; + b?: undefined; } | { - a?: never; - b?: never; + a?: undefined; + b?: undefined; }; declare let e2: { - a?: never; - b?: never; + a?: undefined; + b?: undefined; } | { a: string; - b?: never; + b?: undefined; } | { a: number; b: number; diff --git a/tests/baselines/reference/objectLiteralNormalization.types b/tests/baselines/reference/objectLiteralNormalization.types index 9f4710df64f0b..28cf4bed6f792 100644 --- a/tests/baselines/reference/objectLiteralNormalization.types +++ b/tests/baselines/reference/objectLiteralNormalization.types @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts === // Object literals in unions are normalized upon widening let a1 = [{ a: 0 }, { a: 1, b: "x" }, { a: 2, b: "y", c: true }][0]; ->a1 : { a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; } +>a1 : { a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; } >[{ a: 0 }, { a: 1, b: "x" }, { a: 2, b: "y", c: true }][0] : { a: number; } | { a: number; b: string; } | { a: number; b: string; c: boolean; } >[{ a: 0 }, { a: 1, b: "x" }, { a: 2, b: "y", c: true }] : ({ a: number; } | { a: number; b: string; } | { a: number; b: string; c: boolean; })[] >{ a: 0 } : { a: number; } @@ -23,29 +23,29 @@ let a1 = [{ a: 0 }, { a: 1, b: "x" }, { a: 2, b: "y", c: true }][0]; a1.a; // number >a1.a : number ->a1 : { a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; } +>a1 : { a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; } >a : number a1.b; // string | undefined >a1.b : string | undefined ->a1 : { a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; } +>a1 : { a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; } >b : string | undefined a1.c; // boolean | undefined >a1.c : boolean | undefined ->a1 : { a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; } +>a1 : { a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; } >c : boolean | undefined a1 = { a: 1 }; >a1 = { a: 1 } : { a: number; } ->a1 : { a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; } +>a1 : { a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; } >{ a: 1 } : { a: number; } >a : number >1 : 1 a1 = { a: 0, b: 0 }; // Error >a1 = { a: 0, b: 0 } : { a: number; b: number; } ->a1 : { a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; } +>a1 : { a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; } >{ a: 0, b: 0 } : { a: number; b: number; } >a : number >0 : 0 @@ -54,20 +54,20 @@ a1 = { a: 0, b: 0 }; // Error a1 = { b: "y" }; // Error >a1 = { b: "y" } : { b: string; } ->a1 : { a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; } +>a1 : { a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; } >{ b: "y" } : { b: string; } >b : string >"y" : "y" a1 = { c: true }; // Error >a1 = { c: true } : { c: true; } ->a1 : { a: number; b?: never; c?: never; } | { a: number; b: string; c?: never; } | { a: number; b: string; c: boolean; } +>a1 : { a: number; b?: undefined; c?: undefined; } | { a: number; b: string; c?: undefined; } | { a: number; b: string; c: boolean; } >{ c: true } : { c: true; } >c : true >true : true let a2 = [{ a: 1, b: 2 }, { a: "abc" }, {}][0]; ->a2 : { a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; } +>a2 : { a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; } >[{ a: 1, b: 2 }, { a: "abc" }, {}][0] : { a: number; b: number; } | { a: string; } | {} >[{ a: 1, b: 2 }, { a: "abc" }, {}] : ({ a: number; b: number; } | { a: string; } | {})[] >{ a: 1, b: 2 } : { a: number; b: number; } @@ -83,17 +83,17 @@ let a2 = [{ a: 1, b: 2 }, { a: "abc" }, {}][0]; a2.a; // string | number | undefined >a2.a : string | number | undefined ->a2 : { a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; } +>a2 : { a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; } >a : string | number | undefined a2.b; // number | undefined >a2.b : number | undefined ->a2 : { a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; } +>a2 : { a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; } >b : number | undefined a2 = { a: 10, b: 20 }; >a2 = { a: 10, b: 20 } : { a: number; b: number; } ->a2 : { a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; } +>a2 : { a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; } >{ a: 10, b: 20 } : { a: number; b: number; } >a : number >10 : 10 @@ -102,19 +102,19 @@ a2 = { a: 10, b: 20 }; a2 = { a: "def" }; >a2 = { a: "def" } : { a: string; } ->a2 : { a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; } +>a2 : { a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; } >{ a: "def" } : { a: string; } >a : string >"def" : "def" a2 = {}; >a2 = {} : {} ->a2 : { a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; } +>a2 : { a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; } >{} : {} a2 = { a: "def", b: 20 }; // Error >a2 = { a: "def", b: 20 } : { a: string; b: number; } ->a2 : { a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; } +>a2 : { a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; } >{ a: "def", b: 20 } : { a: string; b: number; } >a : string >"def" : "def" @@ -123,7 +123,7 @@ a2 = { a: "def", b: 20 }; // Error a2 = { a: 1 }; // Error >a2 = { a: 1 } : { a: number; } ->a2 : { a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; } +>a2 : { a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; } >{ a: 1 } : { a: number; } >a : number >1 : 1 @@ -151,29 +151,29 @@ let b3 = { ...b2 }; // Before widening {} acts like { [x: string]: undefined }, which is a // subtype of types with all optional properties declare let opts: { foo?: string, bar?: string, baz?: boolean }; ->opts : { foo?: string; bar?: string; baz?: boolean; } +>opts : { foo?: string | undefined; bar?: string | undefined; baz?: boolean | undefined; } >foo : string | undefined >bar : string | undefined >baz : boolean | undefined let c1 = !true ? {} : opts; ->c1 : { foo?: string; bar?: string; baz?: boolean; } ->!true ? {} : opts : { foo?: string; bar?: string; baz?: boolean; } +>c1 : { foo?: string | undefined; bar?: string | undefined; baz?: boolean | undefined; } +>!true ? {} : opts : { foo?: string | undefined; bar?: string | undefined; baz?: boolean | undefined; } >!true : false >true : true >{} : {} ->opts : { foo?: string; bar?: string; baz?: boolean; } +>opts : { foo?: string | undefined; bar?: string | undefined; baz?: boolean | undefined; } let c2 = !true ? opts : {}; ->c2 : { foo?: string; bar?: string; baz?: boolean; } ->!true ? opts : {} : { foo?: string; bar?: string; baz?: boolean; } +>c2 : { foo?: string | undefined; bar?: string | undefined; baz?: boolean | undefined; } +>!true ? opts : {} : { foo?: string | undefined; bar?: string | undefined; baz?: boolean | undefined; } >!true : false >true : true ->opts : { foo?: string; bar?: string; baz?: boolean; } +>opts : { foo?: string | undefined; bar?: string | undefined; baz?: boolean | undefined; } >{} : {} let c3 = !true ? { a: 0, b: 0 } : {}; ->c3 : { a: number; b: number; } | { a?: never; b?: never; } +>c3 : { a: number; b: number; } | { a?: undefined; b?: undefined; } >!true ? { a: 0, b: 0 } : {} : { a: number; b: number; } | {} >!true : false >true : true @@ -185,7 +185,7 @@ let c3 = !true ? { a: 0, b: 0 } : {}; >{} : {} let c4 = !true ? {} : { a: 0, b: 0 }; ->c4 : { a?: never; b?: never; } | { a: number; b: number; } +>c4 : { a?: undefined; b?: undefined; } | { a: number; b: number; } >!true ? {} : { a: 0, b: 0 } : {} | { a: number; b: number; } >!true : false >true : true @@ -198,7 +198,7 @@ let c4 = !true ? {} : { a: 0, b: 0 }; // Normalization applies to nested properties let d1 = [{ kind: 'a', pos: { x: 0, y: 0 } }, { kind: 'b', pos: !true ? { a: "x" } : { b: 0 } }][0]; ->d1 : { kind: string; pos: { x: number; y: number; a?: never; b?: never; }; } | { kind: string; pos: { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; }; } +>d1 : { kind: string; pos: { x: number; y: number; a?: undefined; b?: undefined; }; } | { kind: string; pos: { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; }; } >[{ kind: 'a', pos: { x: 0, y: 0 } }, { kind: 'b', pos: !true ? { a: "x" } : { b: 0 } }][0] : { kind: string; pos: { x: number; y: number; }; } | { kind: string; pos: { a: string; } | { b: number; }; } >[{ kind: 'a', pos: { x: 0, y: 0 } }, { kind: 'b', pos: !true ? { a: "x" } : { b: 0 } }] : ({ kind: string; pos: { x: number; y: number; }; } | { kind: string; pos: { a: string; } | { b: number; }; })[] >{ kind: 'a', pos: { x: 0, y: 0 } } : { kind: string; pos: { x: number; y: number; }; } @@ -227,40 +227,40 @@ let d1 = [{ kind: 'a', pos: { x: 0, y: 0 } }, { kind: 'b', pos: !true ? { a: "x" d1.kind; >d1.kind : string ->d1 : { kind: string; pos: { x: number; y: number; a?: never; b?: never; }; } | { kind: string; pos: { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; }; } +>d1 : { kind: string; pos: { x: number; y: number; a?: undefined; b?: undefined; }; } | { kind: string; pos: { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; }; } >kind : string d1.pos; ->d1.pos : { x: number; y: number; a?: never; b?: never; } | { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; } ->d1 : { kind: string; pos: { x: number; y: number; a?: never; b?: never; }; } | { kind: string; pos: { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; }; } ->pos : { x: number; y: number; a?: never; b?: never; } | { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; } +>d1.pos : { x: number; y: number; a?: undefined; b?: undefined; } | { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; } +>d1 : { kind: string; pos: { x: number; y: number; a?: undefined; b?: undefined; }; } | { kind: string; pos: { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; }; } +>pos : { x: number; y: number; a?: undefined; b?: undefined; } | { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; } d1.pos.x; >d1.pos.x : number | undefined ->d1.pos : { x: number; y: number; a?: never; b?: never; } | { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; } ->d1 : { kind: string; pos: { x: number; y: number; a?: never; b?: never; }; } | { kind: string; pos: { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; }; } ->pos : { x: number; y: number; a?: never; b?: never; } | { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; } +>d1.pos : { x: number; y: number; a?: undefined; b?: undefined; } | { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; } +>d1 : { kind: string; pos: { x: number; y: number; a?: undefined; b?: undefined; }; } | { kind: string; pos: { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; }; } +>pos : { x: number; y: number; a?: undefined; b?: undefined; } | { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; } >x : number | undefined d1.pos.y; >d1.pos.y : number | undefined ->d1.pos : { x: number; y: number; a?: never; b?: never; } | { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; } ->d1 : { kind: string; pos: { x: number; y: number; a?: never; b?: never; }; } | { kind: string; pos: { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; }; } ->pos : { x: number; y: number; a?: never; b?: never; } | { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; } +>d1.pos : { x: number; y: number; a?: undefined; b?: undefined; } | { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; } +>d1 : { kind: string; pos: { x: number; y: number; a?: undefined; b?: undefined; }; } | { kind: string; pos: { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; }; } +>pos : { x: number; y: number; a?: undefined; b?: undefined; } | { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; } >y : number | undefined d1.pos.a; >d1.pos.a : string | undefined ->d1.pos : { x: number; y: number; a?: never; b?: never; } | { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; } ->d1 : { kind: string; pos: { x: number; y: number; a?: never; b?: never; }; } | { kind: string; pos: { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; }; } ->pos : { x: number; y: number; a?: never; b?: never; } | { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; } +>d1.pos : { x: number; y: number; a?: undefined; b?: undefined; } | { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; } +>d1 : { kind: string; pos: { x: number; y: number; a?: undefined; b?: undefined; }; } | { kind: string; pos: { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; }; } +>pos : { x: number; y: number; a?: undefined; b?: undefined; } | { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; } >a : string | undefined d1.pos.b; >d1.pos.b : number | undefined ->d1.pos : { x: number; y: number; a?: never; b?: never; } | { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; } ->d1 : { kind: string; pos: { x: number; y: number; a?: never; b?: never; }; } | { kind: string; pos: { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; }; } ->pos : { x: number; y: number; a?: never; b?: never; } | { a: string; x?: never; y?: never; b?: never; } | { b: number; x?: never; y?: never; a?: never; } +>d1.pos : { x: number; y: number; a?: undefined; b?: undefined; } | { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; } +>d1 : { kind: string; pos: { x: number; y: number; a?: undefined; b?: undefined; }; } | { kind: string; pos: { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; }; } +>pos : { x: number; y: number; a?: undefined; b?: undefined; } | { a: string; x?: undefined; y?: undefined; b?: undefined; } | { b: number; x?: undefined; y?: undefined; a?: undefined; } >b : number | undefined declare function f(...items: T[]): T; @@ -276,8 +276,8 @@ declare let data: { a: 1, b: "abc", c: true }; // Object literals are inferred as a single normalized union type let e1 = f({ a: 1, b: 2 }, { a: "abc" }, {}); ->e1 : { a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; } ->f({ a: 1, b: 2 }, { a: "abc" }, {}) : { a: number; b: number; } | { a: string; b?: never; } | { a?: never; b?: never; } +>e1 : { a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; } +>f({ a: 1, b: 2 }, { a: "abc" }, {}) : { a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; } >f : (...items: T[]) => T >{ a: 1, b: 2 } : { a: number; b: number; } >a : number @@ -290,8 +290,8 @@ let e1 = f({ a: 1, b: 2 }, { a: "abc" }, {}); >{} : {} let e2 = f({}, { a: "abc" }, { a: 1, b: 2 }); ->e2 : { a?: never; b?: never; } | { a: string; b?: never; } | { a: number; b: number; } ->f({}, { a: "abc" }, { a: 1, b: 2 }) : { a?: never; b?: never; } | { a: string; b?: never; } | { a: number; b: number; } +>e2 : { a?: undefined; b?: undefined; } | { a: string; b?: undefined; } | { a: number; b: number; } +>f({}, { a: "abc" }, { a: 1, b: 2 }) : { a?: undefined; b?: undefined; } | { a: string; b?: undefined; } | { a: number; b: number; } >f : (...items: T[]) => T >{} : {} >{ a: "abc" } : { a: string; } diff --git a/tests/baselines/reference/objectSpreadRepeatedComplexity.types b/tests/baselines/reference/objectSpreadRepeatedComplexity.types index ad44309a2177d..376a7db385ea6 100644 --- a/tests/baselines/reference/objectSpreadRepeatedComplexity.types +++ b/tests/baselines/reference/objectSpreadRepeatedComplexity.types @@ -1,11 +1,11 @@ === tests/cases/conformance/types/spread/objectSpreadRepeatedComplexity.ts === function f(cnd: Record){ ->f : (cnd: Record) => { prop20a?: number; prop20b?: number; prop19a?: number; prop19b?: number; prop18a?: number; prop18b?: number; prop17a?: number; prop17b?: number; prop16a?: number; prop16b?: number; prop15a?: number; prop15b?: number; prop14a?: number; prop14b?: number; prop13a?: number; prop13b?: number; prop12a?: number; prop12b?: number; prop11a?: number; prop11b?: number; prop10a?: number; prop10b?: number; prop9a?: number; prop9b?: number; prop8a?: number; prop8b?: number; prop7a?: number; prop7b?: number; prop6a?: number; prop6b?: number; prop5a?: number; prop5b?: number; prop4a?: number; prop4b?: number; prop3a?: number; prop3b?: number; prop0?: number; } +>f : (cnd: Record) => { prop20a?: number | undefined; prop20b?: number | undefined; prop19a?: number | undefined; prop19b?: number | undefined; prop18a?: number | undefined; prop18b?: number | undefined; prop17a?: number | undefined; prop17b?: number | undefined; prop16a?: number | undefined; prop16b?: number | undefined; prop15a?: number | undefined; prop15b?: number | undefined; prop14a?: number | undefined; prop14b?: number | undefined; prop13a?: number | undefined; prop13b?: number | undefined; prop12a?: number | undefined; prop12b?: number | undefined; prop11a?: number | undefined; prop11b?: number | undefined; prop10a?: number | undefined; prop10b?: number | undefined; prop9a?: number | undefined; prop9b?: number | undefined; prop8a?: number | undefined; prop8b?: number | undefined; prop7a?: number | undefined; prop7b?: number | undefined; prop6a?: number | undefined; prop6b?: number | undefined; prop5a?: number | undefined; prop5b?: number | undefined; prop4a?: number | undefined; prop4b?: number | undefined; prop3a?: number | undefined; prop3b?: number | undefined; prop0?: number | undefined; } >cnd : Record // Type is a union of 2^(n-1) members, where n is the number of spread objects return { ->{ // Without this one, it collapses to {} ? ...(cnd[1] && cnd[2] && { prop0: 0, }), // With one prop each, it collapses to a single object (#34853?) ...(cnd[3] && { prop3a: 1, prop3b: 1, }), ...(cnd[4] && { prop4a: 1, prop4b: 1, }), ...(cnd[5] && { prop5a: 1, prop5b: 1, }), ...(cnd[6] && { prop6a: 1, prop6b: 1, }), ...(cnd[7] && { prop7a: 1, prop7b: 1, }), ...(cnd[8] && { prop8a: 1, prop8b: 1, }), ...(cnd[9] && { prop9a: 1, prop9b: 1, }), ...(cnd[10] && { prop10a: 1, prop10b: 1, }), ...(cnd[11] && { prop11a: 1, prop11b: 1, }), ...(cnd[12] && { prop12a: 1, prop12b: 1, }), ...(cnd[13] && { prop13a: 1, prop13b: 1, }), ...(cnd[14] && { prop14a: 1, prop14b: 1, }), ...(cnd[15] && { prop15a: 1, prop15b: 1, }), ...(cnd[16] && { prop16a: 1, prop16b: 1, }), ...(cnd[17] && { prop17a: 1, prop17b: 1, }), ...(cnd[18] && { prop18a: 1, prop18b: 1, }), ...(cnd[19] && { prop19a: 1, prop19b: 1, }), ...(cnd[20] && { prop20a: 1, prop20b: 1, }), } : { prop20a?: number; prop20b?: number; prop19a?: number; prop19b?: number; prop18a?: number; prop18b?: number; prop17a?: number; prop17b?: number; prop16a?: number; prop16b?: number; prop15a?: number; prop15b?: number; prop14a?: number; prop14b?: number; prop13a?: number; prop13b?: number; prop12a?: number; prop12b?: number; prop11a?: number; prop11b?: number; prop10a?: number; prop10b?: number; prop9a?: number; prop9b?: number; prop8a?: number; prop8b?: number; prop7a?: number; prop7b?: number; prop6a?: number; prop6b?: number; prop5a?: number; prop5b?: number; prop4a?: number; prop4b?: number; prop3a?: number; prop3b?: number; prop0?: number; } +>{ // Without this one, it collapses to {} ? ...(cnd[1] && cnd[2] && { prop0: 0, }), // With one prop each, it collapses to a single object (#34853?) ...(cnd[3] && { prop3a: 1, prop3b: 1, }), ...(cnd[4] && { prop4a: 1, prop4b: 1, }), ...(cnd[5] && { prop5a: 1, prop5b: 1, }), ...(cnd[6] && { prop6a: 1, prop6b: 1, }), ...(cnd[7] && { prop7a: 1, prop7b: 1, }), ...(cnd[8] && { prop8a: 1, prop8b: 1, }), ...(cnd[9] && { prop9a: 1, prop9b: 1, }), ...(cnd[10] && { prop10a: 1, prop10b: 1, }), ...(cnd[11] && { prop11a: 1, prop11b: 1, }), ...(cnd[12] && { prop12a: 1, prop12b: 1, }), ...(cnd[13] && { prop13a: 1, prop13b: 1, }), ...(cnd[14] && { prop14a: 1, prop14b: 1, }), ...(cnd[15] && { prop15a: 1, prop15b: 1, }), ...(cnd[16] && { prop16a: 1, prop16b: 1, }), ...(cnd[17] && { prop17a: 1, prop17b: 1, }), ...(cnd[18] && { prop18a: 1, prop18b: 1, }), ...(cnd[19] && { prop19a: 1, prop19b: 1, }), ...(cnd[20] && { prop20a: 1, prop20b: 1, }), } : { prop20a?: number | undefined; prop20b?: number | undefined; prop19a?: number | undefined; prop19b?: number | undefined; prop18a?: number | undefined; prop18b?: number | undefined; prop17a?: number | undefined; prop17b?: number | undefined; prop16a?: number | undefined; prop16b?: number | undefined; prop15a?: number | undefined; prop15b?: number | undefined; prop14a?: number | undefined; prop14b?: number | undefined; prop13a?: number | undefined; prop13b?: number | undefined; prop12a?: number | undefined; prop12b?: number | undefined; prop11a?: number | undefined; prop11b?: number | undefined; prop10a?: number | undefined; prop10b?: number | undefined; prop9a?: number | undefined; prop9b?: number | undefined; prop8a?: number | undefined; prop8b?: number | undefined; prop7a?: number | undefined; prop7b?: number | undefined; prop6a?: number | undefined; prop6b?: number | undefined; prop5a?: number | undefined; prop5b?: number | undefined; prop4a?: number | undefined; prop4b?: number | undefined; prop3a?: number | undefined; prop3b?: number | undefined; prop0?: number | undefined; } // Without this one, it collapses to {} ? ...(cnd[1] && diff --git a/tests/baselines/reference/objectSpreadRepeatedNullCheckPerf.types b/tests/baselines/reference/objectSpreadRepeatedNullCheckPerf.types index d2f1e79037175..12f4789c3e390 100644 --- a/tests/baselines/reference/objectSpreadRepeatedNullCheckPerf.types +++ b/tests/baselines/reference/objectSpreadRepeatedNullCheckPerf.types @@ -84,7 +84,7 @@ function parseWithSpread(config: Record): Props { >config : Record return { ->{ ...config.a !== undefined && { a: config.a.toString() }, ...config.b !== undefined && { b: config.b.toString() }, ...config.c !== undefined && { c: config.c.toString() }, ...config.d !== undefined && { d: config.d.toString() }, ...config.e !== undefined && { e: config.e.toString() }, ...config.f !== undefined && { f: config.f.toString() }, ...config.g !== undefined && { g: config.g.toString() }, ...config.h !== undefined && { h: config.h.toString() }, ...config.i !== undefined && { i: config.i.toString() }, ...config.j !== undefined && { j: config.j.toString() }, ...config.k !== undefined && { k: config.k.toString() }, ...config.l !== undefined && { l: config.l.toString() }, ...config.m !== undefined && { m: config.m.toString() }, ...config.n !== undefined && { n: config.n.toString() }, ...config.o !== undefined && { o: config.o.toString() }, ...config.p !== undefined && { p: config.p.toString() }, ...config.q !== undefined && { q: config.q.toString() }, ...config.r !== undefined && { r: config.r.toString() }, ...config.s !== undefined && { s: config.s.toString() }, ...config.t !== undefined && { t: config.t.toString() }, ...config.u !== undefined && { u: config.u.toString() }, ...config.v !== undefined && { v: config.v.toString() }, ...config.w !== undefined && { w: config.w.toString() }, ...config.x !== undefined && { x: config.x.toString() }, ...config.y !== undefined && { y: config.y.toString() }, ...config.z !== undefined && { z: config.z.toString() } } : { z?: string; y?: string; x?: string; w?: string; v?: string; u?: string; t?: string; s?: string; r?: string; q?: string; p?: string; o?: string; n?: string; m?: string; l?: string; k?: string; j?: string; i?: string; h?: string; g?: string; f?: string; e?: string; d?: string; c?: string; b?: string; a?: string; } +>{ ...config.a !== undefined && { a: config.a.toString() }, ...config.b !== undefined && { b: config.b.toString() }, ...config.c !== undefined && { c: config.c.toString() }, ...config.d !== undefined && { d: config.d.toString() }, ...config.e !== undefined && { e: config.e.toString() }, ...config.f !== undefined && { f: config.f.toString() }, ...config.g !== undefined && { g: config.g.toString() }, ...config.h !== undefined && { h: config.h.toString() }, ...config.i !== undefined && { i: config.i.toString() }, ...config.j !== undefined && { j: config.j.toString() }, ...config.k !== undefined && { k: config.k.toString() }, ...config.l !== undefined && { l: config.l.toString() }, ...config.m !== undefined && { m: config.m.toString() }, ...config.n !== undefined && { n: config.n.toString() }, ...config.o !== undefined && { o: config.o.toString() }, ...config.p !== undefined && { p: config.p.toString() }, ...config.q !== undefined && { q: config.q.toString() }, ...config.r !== undefined && { r: config.r.toString() }, ...config.s !== undefined && { s: config.s.toString() }, ...config.t !== undefined && { t: config.t.toString() }, ...config.u !== undefined && { u: config.u.toString() }, ...config.v !== undefined && { v: config.v.toString() }, ...config.w !== undefined && { w: config.w.toString() }, ...config.x !== undefined && { x: config.x.toString() }, ...config.y !== undefined && { y: config.y.toString() }, ...config.z !== undefined && { z: config.z.toString() } } : { z?: string | undefined; y?: string | undefined; x?: string | undefined; w?: string | undefined; v?: string | undefined; u?: string | undefined; t?: string | undefined; s?: string | undefined; r?: string | undefined; q?: string | undefined; p?: string | undefined; o?: string | undefined; n?: string | undefined; m?: string | undefined; l?: string | undefined; k?: string | undefined; j?: string | undefined; i?: string | undefined; h?: string | undefined; g?: string | undefined; f?: string | undefined; e?: string | undefined; d?: string | undefined; c?: string | undefined; b?: string | undefined; a?: string | undefined; } ...config.a !== undefined && { a: config.a.toString() }, >config.a !== undefined && { a: config.a.toString() } : false | { a: string; } diff --git a/tests/baselines/reference/omitTypeHelperModifiers01.errors.txt b/tests/baselines/reference/omitTypeHelperModifiers01.errors.txt index 0094f0e8d6ba5..e175a53703230 100644 --- a/tests/baselines/reference/omitTypeHelperModifiers01.errors.txt +++ b/tests/baselines/reference/omitTypeHelperModifiers01.errors.txt @@ -1,8 +1,7 @@ -tests/cases/compiler/omitTypeHelperModifiers01.ts(13,5): error TS2322: Type 'undefined' is not assignable to type 'string'. tests/cases/compiler/omitTypeHelperModifiers01.ts(16,7): error TS2540: Cannot assign to 'c' because it is a read-only property. -==== tests/cases/compiler/omitTypeHelperModifiers01.ts (2 errors) ==== +==== tests/cases/compiler/omitTypeHelperModifiers01.ts (1 errors) ==== type A = { a: number; b?: string; @@ -16,8 +15,6 @@ tests/cases/compiler/omitTypeHelperModifiers01.ts(16,7): error TS2540: Cannot as const b = x.b; x.b = "hello"; x.b = undefined; - ~~~ -!!! error TS2322: Type 'undefined' is not assignable to type 'string'. const c = x.c; x.c = true; diff --git a/tests/baselines/reference/omitTypeHelperModifiers01.types b/tests/baselines/reference/omitTypeHelperModifiers01.types index 37575cecd4f0f..b1962065e4b8c 100644 --- a/tests/baselines/reference/omitTypeHelperModifiers01.types +++ b/tests/baselines/reference/omitTypeHelperModifiers01.types @@ -31,16 +31,16 @@ function f(x: B) { x.b = "hello"; >x.b = "hello" : "hello" ->x.b : string +>x.b : string | undefined >x : B ->b : string +>b : string | undefined >"hello" : "hello" x.b = undefined; >x.b = undefined : undefined ->x.b : string +>x.b : string | undefined >x : B ->b : string +>b : string | undefined >undefined : undefined const c = x.c; diff --git a/tests/baselines/reference/optionalPropertyAssignableToStringIndexSignature.errors.txt b/tests/baselines/reference/optionalPropertyAssignableToStringIndexSignature.errors.txt index 130557d978e21..f6ba165804206 100644 --- a/tests/baselines/reference/optionalPropertyAssignableToStringIndexSignature.errors.txt +++ b/tests/baselines/reference/optionalPropertyAssignableToStringIndexSignature.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/optional Property 'k1' is incompatible with index signature. Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/optionalPropertyAssignableToStringIndexSignature.ts(10,1): error TS2322: Type '{ 1?: string; }' is not assignable to type '{ [key: number]: string; }'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/optionalPropertyAssignableToStringIndexSignature.ts(10,1): error TS2322: Type '{ 1?: string | undefined; }' is not assignable to type '{ [key: number]: string; }'. Property '1' is incompatible with index signature. Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. @@ -28,7 +28,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/optional declare let numberLiteralKeys: { 1?: string }; probablyArray = numberLiteralKeys; // error ~~~~~~~~~~~~~ -!!! error TS2322: Type '{ 1?: string; }' is not assignable to type '{ [key: number]: string; }'. +!!! error TS2322: Type '{ 1?: string | undefined; }' is not assignable to type '{ [key: number]: string; }'. !!! error TS2322: Property '1' is incompatible with index signature. !!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. !!! error TS2322: Type 'undefined' is not assignable to type 'string'. diff --git a/tests/baselines/reference/optionalPropertyAssignableToStringIndexSignature.types b/tests/baselines/reference/optionalPropertyAssignableToStringIndexSignature.types index b9154db8964c4..1a8859b6e781f 100644 --- a/tests/baselines/reference/optionalPropertyAssignableToStringIndexSignature.types +++ b/tests/baselines/reference/optionalPropertyAssignableToStringIndexSignature.types @@ -1,6 +1,6 @@ === tests/cases/conformance/types/typeRelationships/assignmentCompatibility/optionalPropertyAssignableToStringIndexSignature.ts === declare let optionalProperties: { k1?: string }; ->optionalProperties : { k1?: string; } +>optionalProperties : { k1?: string | undefined; } >k1 : string | undefined declare let undefinedProperties: { k1: string | undefined }; @@ -12,9 +12,9 @@ declare let stringDictionary: { [key: string]: string }; >key : string stringDictionary = optionalProperties; // ok ->stringDictionary = optionalProperties : { k1?: string; } +>stringDictionary = optionalProperties : { k1?: string | undefined; } >stringDictionary : { [key: string]: string; } ->optionalProperties : { k1?: string; } +>optionalProperties : { k1?: string | undefined; } stringDictionary = undefinedProperties; // error >stringDictionary = undefinedProperties : { k1: string | undefined; } @@ -26,13 +26,13 @@ declare let probablyArray: { [key: number]: string }; >key : number declare let numberLiteralKeys: { 1?: string }; ->numberLiteralKeys : { 1?: string; } +>numberLiteralKeys : { 1?: string | undefined; } >1 : string | undefined probablyArray = numberLiteralKeys; // error ->probablyArray = numberLiteralKeys : { 1?: string; } +>probablyArray = numberLiteralKeys : { 1?: string | undefined; } >probablyArray : { [key: number]: string; } ->numberLiteralKeys : { 1?: string; } +>numberLiteralKeys : { 1?: string | undefined; } declare let optionalUndefined: { k1?: undefined }; >optionalUndefined : { k1?: undefined; } @@ -47,7 +47,7 @@ function f() { >f : () => void let optional: { k1?: T } = undefined!; ->optional : { k1?: T; } +>optional : { k1?: T | undefined; } >k1 : T | undefined >undefined! : never >undefined : undefined @@ -55,6 +55,6 @@ function f() { let dict: { [key: string]: T | number } = optional; // ok >dict : { [key: string]: number | T; } >key : string ->optional : { k1?: T; } +>optional : { k1?: T | undefined; } } diff --git a/tests/baselines/reference/optionalTupleElements1.types b/tests/baselines/reference/optionalTupleElements1.types index 980e1a3b98d54..b784bf72e5843 100644 --- a/tests/baselines/reference/optionalTupleElements1.types +++ b/tests/baselines/reference/optionalTupleElements1.types @@ -138,9 +138,9 @@ t3 = [42, "hello"]; >"hello" : "hello" t3 = [42,,true] ->t3 = [42,,true] : [number, never?, true?] +>t3 = [42,,true] : [number, undefined, true] >t3 : T3 ->[42,,true] : [number, never?, true?] +>[42,,true] : [number, undefined, true] >42 : 42 > : undefined >true : true @@ -159,25 +159,25 @@ t4 = [42, "hello"]; >"hello" : "hello" t4 = [42,,true]; ->t4 = [42,,true] : [number, never?, true?] +>t4 = [42,,true] : [number, undefined, true] >t4 : T4 ->[42,,true] : [number, never?, true?] +>[42,,true] : [number, undefined, true] >42 : 42 > : undefined >true : true t4 = [,"hello", true]; ->t4 = [,"hello", true] : [never?, string?, true?] +>t4 = [,"hello", true] : [undefined, string, true] >t4 : T4 ->[,"hello", true] : [never?, string?, true?] +>[,"hello", true] : [undefined, string, true] > : undefined >"hello" : "hello" >true : true t4 = [,,true]; ->t4 = [,,true] : [never?, never?, true?] +>t4 = [,,true] : [undefined, undefined, true] >t4 : T4 ->[,,true] : [never?, never?, true?] +>[,,true] : [undefined, undefined, true] > : undefined > : undefined >true : true diff --git a/tests/baselines/reference/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.errors.txt b/tests/baselines/reference/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.errors.txt index 8120d68d750b3..4304bb486ef0e 100644 --- a/tests/baselines/reference/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.errors.txt +++ b/tests/baselines/reference/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.errors.txt @@ -1,11 +1,13 @@ -tests/cases/compiler/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.ts(27,23): error TS2345: Argument of type '{ x?: number[]; y?: string[]; }' is not assignable to parameter of type '{ y?: number[]; }'. +tests/cases/compiler/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.ts(27,23): error TS2345: Argument of type '{ x?: number[] | undefined; y?: string[] | undefined; }' is not assignable to parameter of type '{ y?: number[] | undefined; }'. Types of property 'y' are incompatible. - Type 'string[]' is not assignable to type 'number[]'. - Type 'string' is not assignable to type 'number'. -tests/cases/compiler/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.ts(28,23): error TS2345: Argument of type '{ x?: number[]; y?: string[]; }' is not assignable to parameter of type '{ x?: string[]; }'. + Type 'string[] | undefined' is not assignable to type 'number[] | undefined'. + Type 'string[]' is not assignable to type 'number[]'. + Type 'string' is not assignable to type 'number'. +tests/cases/compiler/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.ts(28,23): error TS2345: Argument of type '{ x?: number[] | undefined; y?: string[] | undefined; }' is not assignable to parameter of type '{ x?: string[] | undefined; }'. Types of property 'x' are incompatible. - Type 'number[]' is not assignable to type 'string[]'. - Type 'number' is not assignable to type 'string'. + Type 'number[] | undefined' is not assignable to type 'string[] | undefined'. + Type 'number[]' is not assignable to type 'string[]'. + Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.ts (2 errors) ==== @@ -37,13 +39,15 @@ tests/cases/compiler/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.t appendToOptionalArray(foo, 'y', 'bar'); // ok appendToOptionalArray(foo, 'y', 12); // should fail ~~~ -!!! error TS2345: Argument of type '{ x?: number[]; y?: string[]; }' is not assignable to parameter of type '{ y?: number[]; }'. +!!! error TS2345: Argument of type '{ x?: number[] | undefined; y?: string[] | undefined; }' is not assignable to parameter of type '{ y?: number[] | undefined; }'. !!! error TS2345: Types of property 'y' are incompatible. -!!! error TS2345: Type 'string[]' is not assignable to type 'number[]'. -!!! error TS2345: Type 'string' is not assignable to type 'number'. +!!! error TS2345: Type 'string[] | undefined' is not assignable to type 'number[] | undefined'. +!!! error TS2345: Type 'string[]' is not assignable to type 'number[]'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. appendToOptionalArray(foo, 'x', "no"); // should fail ~~~ -!!! error TS2345: Argument of type '{ x?: number[]; y?: string[]; }' is not assignable to parameter of type '{ x?: string[]; }'. +!!! error TS2345: Argument of type '{ x?: number[] | undefined; y?: string[] | undefined; }' is not assignable to parameter of type '{ x?: string[] | undefined; }'. !!! error TS2345: Types of property 'x' are incompatible. -!!! error TS2345: Type 'number[]' is not assignable to type 'string[]'. -!!! error TS2345: Type 'number' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2345: Type 'number[] | undefined' is not assignable to type 'string[] | undefined'. +!!! error TS2345: Type 'number[]' is not assignable to type 'string[]'. +!!! error TS2345: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.types b/tests/baselines/reference/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.types index 040d68293170e..4e4f667b549c9 100644 --- a/tests/baselines/reference/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.types +++ b/tests/baselines/reference/paramsOnlyHaveLiteralTypesWhenAppropriatelyContextualized.types @@ -7,13 +7,13 @@ type Lower = { [K in keyof T]: T[K] }; >Lower : Lower export function appendToOptionalArray< ->appendToOptionalArray : (object: { [x in K]?: Lower[]; }, key: K, value: T) => void +>appendToOptionalArray : (object: { [x in K]?: Lower[] | undefined; }, key: K, value: T) => void K extends string | number | symbol, T >( object: { [x in K]?: Lower[] }, ->object : { [x in K]?: Lower[]; } +>object : { [x in K]?: Lower[] | undefined; } key: K, >key : K @@ -23,13 +23,13 @@ export function appendToOptionalArray< ) { const array = object[key]; ->array : { [x in K]?: Lower[]; }[K] ->object[key] : { [x in K]?: Lower[]; }[K] ->object : { [x in K]?: Lower[]; } +>array : { [x in K]?: Lower[] | undefined; }[K] +>object[key] : { [x in K]?: Lower[] | undefined; }[K] +>object : { [x in K]?: Lower[] | undefined; } >key : K if (array) { ->array : { [x in K]?: Lower[]; }[K] +>array : { [x in K]?: Lower[] | undefined; }[K] array.push(value); >array.push(value) : number @@ -41,8 +41,8 @@ export function appendToOptionalArray< } else { object[key] = [value]; >object[key] = [value] : T[] ->object[key] : { [x in K]?: Lower[]; }[K] ->object : { [x in K]?: Lower[]; } +>object[key] : { [x in K]?: Lower[] | undefined; }[K] +>object : { [x in K]?: Lower[] | undefined; } >key : K >[value] : T[] >value : T @@ -51,36 +51,36 @@ export function appendToOptionalArray< // e.g. const foo: {x?: number[]; y?: string[]; } = {}; ->foo : { x?: number[]; y?: string[]; } +>foo : { x?: number[] | undefined; y?: string[] | undefined; } >x : number[] | undefined >y : string[] | undefined >{} : {} appendToOptionalArray(foo, 'x', 123); // ok >appendToOptionalArray(foo, 'x', 123) : void ->appendToOptionalArray : (object: { [x in K]?: Lower[]; }, key: K, value: T) => void ->foo : { x?: number[]; y?: string[]; } +>appendToOptionalArray : (object: { [x in K]?: Lower[] | undefined; }, key: K, value: T) => void +>foo : { x?: number[] | undefined; y?: string[] | undefined; } >'x' : "x" >123 : 123 appendToOptionalArray(foo, 'y', 'bar'); // ok >appendToOptionalArray(foo, 'y', 'bar') : void ->appendToOptionalArray : (object: { [x in K]?: Lower[]; }, key: K, value: T) => void ->foo : { x?: number[]; y?: string[]; } +>appendToOptionalArray : (object: { [x in K]?: Lower[] | undefined; }, key: K, value: T) => void +>foo : { x?: number[] | undefined; y?: string[] | undefined; } >'y' : "y" >'bar' : "bar" appendToOptionalArray(foo, 'y', 12); // should fail >appendToOptionalArray(foo, 'y', 12) : void ->appendToOptionalArray : (object: { [x in K]?: Lower[]; }, key: K, value: T) => void ->foo : { x?: number[]; y?: string[]; } +>appendToOptionalArray : (object: { [x in K]?: Lower[] | undefined; }, key: K, value: T) => void +>foo : { x?: number[] | undefined; y?: string[] | undefined; } >'y' : "y" >12 : 12 appendToOptionalArray(foo, 'x', "no"); // should fail >appendToOptionalArray(foo, 'x', "no") : void ->appendToOptionalArray : (object: { [x in K]?: Lower[]; }, key: K, value: T) => void ->foo : { x?: number[]; y?: string[]; } +>appendToOptionalArray : (object: { [x in K]?: Lower[] | undefined; }, key: K, value: T) => void +>foo : { x?: number[] | undefined; y?: string[] | undefined; } >'x' : "x" >"no" : "no" diff --git a/tests/baselines/reference/propTypeValidatorInference.types b/tests/baselines/reference/propTypeValidatorInference.types index a04d2a0918f39..be23e8eecb6cc 100644 --- a/tests/baselines/reference/propTypeValidatorInference.types +++ b/tests/baselines/reference/propTypeValidatorInference.types @@ -91,7 +91,7 @@ interface Props { >bool : boolean shape: { ->shape : { foo: string; bar?: boolean; baz?: any; } +>shape : { foo: string; bar?: boolean | undefined; baz?: any; } foo: string; >foo : string @@ -104,7 +104,7 @@ interface Props { }; oneOfType: string | boolean | { ->oneOfType : string | boolean | { foo?: string; bar: number; } +>oneOfType : string | boolean | { foo?: string | undefined; bar: number; } foo?: string; >foo : string | undefined diff --git a/tests/baselines/reference/propertyAccessChain.types b/tests/baselines/reference/propertyAccessChain.types index 99c5533f1a8c7..b776ca10fa28c 100644 --- a/tests/baselines/reference/propertyAccessChain.types +++ b/tests/baselines/reference/propertyAccessChain.types @@ -33,39 +33,39 @@ 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 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 ->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 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 ->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 diff --git a/tests/baselines/reference/reactDefaultPropsInferenceSuccess.errors.txt b/tests/baselines/reference/reactDefaultPropsInferenceSuccess.errors.txt index edc74f9662628..335f0febc862f 100644 --- a/tests/baselines/reference/reactDefaultPropsInferenceSuccess.errors.txt +++ b/tests/baselines/reference/reactDefaultPropsInferenceSuccess.errors.txt @@ -1,24 +1,23 @@ tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(27,36): error TS2769: No overload matches this call. Overload 1 of 2, '(props: Readonly): FieldFeedback', gave the following error. - Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean)'. + Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'. Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. Type 'void' is not assignable to type 'boolean'. Overload 2 of 2, '(props: Props, context?: any): FieldFeedback', gave the following error. - Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean)'. - Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. + Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'. tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(43,41): error TS2769: No overload matches this call. Overload 1 of 2, '(props: Readonly): FieldFeedbackBeta', gave the following error. - Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean)'. + Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'. Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. Type 'void' is not assignable to type 'boolean'. Overload 2 of 2, '(props: Props, context?: any): FieldFeedbackBeta', gave the following error. - Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean)'. - Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. -tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(64,52): error TS2769: No overload matches this call. + Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'. +tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(64,37): error TS2769: No overload matches this call. Overload 1 of 2, '(props: Readonly): FieldFeedback2', gave the following error. - Type 'void' is not assignable to type 'boolean'. + Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. + Type 'void' is not assignable to type 'boolean'. Overload 2 of 2, '(props: MyPropsProps, context?: any): FieldFeedback2', gave the following error. - Type 'void' is not assignable to type 'boolean'. + Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. ==== tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx (3 errors) ==== @@ -52,12 +51,11 @@ tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(64,52): error TS2769: ~~~~ !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(props: Readonly): FieldFeedback', gave the following error. -!!! error TS2769: Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean)'. +!!! error TS2769: Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'. !!! error TS2769: Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. !!! error TS2769: Type 'void' is not assignable to type 'boolean'. !!! error TS2769: Overload 2 of 2, '(props: Props, context?: any): FieldFeedback', gave the following error. -!!! error TS2769: Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean)'. -!!! error TS2769: Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. +!!! error TS2769: Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'. !!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes> & Pick & Readonly, "children" | "error"> & Partial & Readonly, "when">> & Partial boolean; }, never>>' !!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes> & Pick & Readonly, "children" | "error"> & Partial & Readonly, "when">> & Partial boolean; }, never>>' @@ -79,12 +77,11 @@ tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(64,52): error TS2769: ~~~~ !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(props: Readonly): FieldFeedbackBeta', gave the following error. -!!! error TS2769: Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean)'. +!!! error TS2769: Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'. !!! error TS2769: Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. !!! error TS2769: Type 'void' is not assignable to type 'boolean'. !!! error TS2769: Overload 2 of 2, '(props: Props, context?: any): FieldFeedbackBeta', gave the following error. -!!! error TS2769: Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean)'. -!!! error TS2769: Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. +!!! error TS2769: Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'. !!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes> & Pick & Readonly, "children"> & Partial & Readonly, keyof Props>> & Partial>' !!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes> & Pick & Readonly, "children"> & Partial & Readonly, keyof Props>> & Partial>' @@ -108,14 +105,15 @@ tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(64,52): error TS2769: // Error: Void not assignable to boolean const Test4 = () => console.log(value)} />; - ~~~~~~~~~~~~~~~~~~ + ~~~~ !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(props: Readonly): FieldFeedback2', gave the following error. -!!! error TS2769: Type 'void' is not assignable to type 'boolean'. +!!! error TS2769: Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. +!!! error TS2769: Type 'void' is not assignable to type 'boolean'. !!! error TS2769: Overload 2 of 2, '(props: MyPropsProps, context?: any): FieldFeedback2', gave the following error. -!!! error TS2769: Type 'void' is not assignable to type 'boolean'. -!!! related TS6502 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:46:9: The expected type comes from the return type of this signature. -!!! related TS6502 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:46:9: The expected type comes from the return type of this signature. +!!! error TS2769: Type '(value: string) => void' is not assignable to type '(value: string) => boolean'. +!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:46:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes> & Pick & Readonly, "children" | "error"> & Partial & Readonly, "when">> & Partial boolean; }, never>>' +!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:46:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes> & Pick & Readonly, "children" | "error"> & Partial & Readonly, "when">> & Partial boolean; }, never>>' // OK const Test5 = () => ; diff --git a/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.types b/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.types index a6c8176e10ee1..9bc29e06e9063 100644 --- a/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.types +++ b/tests/baselines/reference/reactReduxLikeDeferredInferenceAllowsAssignment.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/showConfig/Shows tsconfig for single option/exactOptionalPropertyTypes/tsconfig.json b/tests/baselines/reference/showConfig/Shows tsconfig for single option/exactOptionalPropertyTypes/tsconfig.json new file mode 100644 index 0000000000000..dc26a86117b82 --- /dev/null +++ b/tests/baselines/reference/showConfig/Shows tsconfig for single option/exactOptionalPropertyTypes/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "exactOptionalPropertyTypes": true + } +} diff --git a/tests/baselines/reference/spreadIdenticalTypesRemoved.types b/tests/baselines/reference/spreadIdenticalTypesRemoved.types index 42d7006306b82..6695770ccc3ed 100644 --- a/tests/baselines/reference/spreadIdenticalTypesRemoved.types +++ b/tests/baselines/reference/spreadIdenticalTypesRemoved.types @@ -17,12 +17,12 @@ interface Animal { } function clonePet(pet: Animal, fullCopy?: boolean) { ->clonePet : (pet: Animal, fullCopy?: boolean | undefined) => { name: string; kind: string; age?: number; location?: string; owner?: object; } +>clonePet : (pet: Animal, fullCopy?: boolean | undefined) => { name: string; kind: string; age?: number | undefined; location?: string | undefined; owner?: object | undefined; } >pet : Animal >fullCopy : boolean | undefined return { ->{ name: pet.name, kind: pet.kind, ...(fullCopy && pet), } : { name: string; kind: string; age?: number; location?: string; owner?: object; } +>{ name: pet.name, kind: pet.kind, ...(fullCopy && pet), } : { name: string; kind: string; age?: number | undefined; location?: string | undefined; owner?: object | undefined; } name: pet.name, >name : string @@ -52,11 +52,11 @@ interface Animal2 { >owner : string | undefined } function billOwner(pet: Animal2) { ->billOwner : (pet: Animal2) => { paid: boolean; name?: string; owner?: string; } +>billOwner : (pet: Animal2) => { paid: boolean; name?: string | undefined; owner?: string | undefined; } >pet : Animal2 return { ->{ ...(pet.owner && pet), paid: false } : { paid: boolean; name?: string; owner?: string; } +>{ ...(pet.owner && pet), paid: false } : { paid: boolean; name?: string | undefined; owner?: string | undefined; } ...(pet.owner && pet), >(pet.owner && pet) : "" | Animal2 | undefined diff --git a/tests/baselines/reference/spreadOfObjectLiteralAssignableToIndexSignature.types b/tests/baselines/reference/spreadOfObjectLiteralAssignableToIndexSignature.types index 53462c68c03ea..8b4fd5422a738 100644 --- a/tests/baselines/reference/spreadOfObjectLiteralAssignableToIndexSignature.types +++ b/tests/baselines/reference/spreadOfObjectLiteralAssignableToIndexSignature.types @@ -9,11 +9,11 @@ const recordOfRecords: RecordOfRecords = {} >{} : {} recordOfRecords.propA = {...(foo !== undefined ? {foo} : {})} // OK ->recordOfRecords.propA = {...(foo !== undefined ? {foo} : {})} : { foo?: Record; } +>recordOfRecords.propA = {...(foo !== undefined ? {foo} : {})} : { foo?: Record | undefined; } >recordOfRecords.propA : RecordOfRecords >recordOfRecords : RecordOfRecords >propA : RecordOfRecords ->{...(foo !== undefined ? {foo} : {})} : { foo?: Record; } +>{...(foo !== undefined ? {foo} : {})} : { foo?: Record | undefined; } >(foo !== undefined ? {foo} : {}) : { foo: Record; } | {} >foo !== undefined ? {foo} : {} : { foo: Record; } | {} >foo !== undefined : boolean @@ -36,11 +36,11 @@ recordOfRecords.propB = {...(foo && {foo})} // OK >foo : Record recordOfRecords.propC = {...(foo !== undefined && {foo})} // error'd in 3.7 beta, should be OK ->recordOfRecords.propC = {...(foo !== undefined && {foo})} : { foo?: Record; } +>recordOfRecords.propC = {...(foo !== undefined && {foo})} : { foo?: Record | undefined; } >recordOfRecords.propC : RecordOfRecords >recordOfRecords : RecordOfRecords >propC : RecordOfRecords ->{...(foo !== undefined && {foo})} : { foo?: Record; } +>{...(foo !== undefined && {foo})} : { foo?: Record | undefined; } >(foo !== undefined && {foo}) : false | { foo: Record; } >foo !== undefined && {foo} : false | { foo: Record; } >foo !== undefined : boolean @@ -55,11 +55,11 @@ const recordsOfRecordsOrEmpty: RecordOfRecordsOrEmpty = {} >{} : {} recordsOfRecordsOrEmpty.propA = {...(foo !== undefined ? {foo} : {})} // OK ->recordsOfRecordsOrEmpty.propA = {...(foo !== undefined ? {foo} : {})} : { foo?: Record; } +>recordsOfRecordsOrEmpty.propA = {...(foo !== undefined ? {foo} : {})} : { foo?: Record | undefined; } >recordsOfRecordsOrEmpty.propA : {} | RecordOfRecordsOrEmpty >recordsOfRecordsOrEmpty : RecordOfRecordsOrEmpty >propA : {} | RecordOfRecordsOrEmpty ->{...(foo !== undefined ? {foo} : {})} : { foo?: Record; } +>{...(foo !== undefined ? {foo} : {})} : { foo?: Record | undefined; } >(foo !== undefined ? {foo} : {}) : { foo: Record; } | {} >foo !== undefined ? {foo} : {} : { foo: Record; } | {} >foo !== undefined : boolean @@ -82,11 +82,11 @@ recordsOfRecordsOrEmpty.propB = {...(foo && {foo})} // OK >foo : Record recordsOfRecordsOrEmpty.propC = {...(foo !== undefined && {foo})} // OK ->recordsOfRecordsOrEmpty.propC = {...(foo !== undefined && {foo})} : { foo?: Record; } +>recordsOfRecordsOrEmpty.propC = {...(foo !== undefined && {foo})} : { foo?: Record | undefined; } >recordsOfRecordsOrEmpty.propC : {} | RecordOfRecordsOrEmpty >recordsOfRecordsOrEmpty : RecordOfRecordsOrEmpty >propC : {} | RecordOfRecordsOrEmpty ->{...(foo !== undefined && {foo})} : { foo?: Record; } +>{...(foo !== undefined && {foo})} : { foo?: Record | undefined; } >(foo !== undefined && {foo}) : false | { foo: Record; } >foo !== undefined && {foo} : false | { foo: Record; } >foo !== undefined : boolean diff --git a/tests/baselines/reference/spreadOverwritesPropertyStrict.types b/tests/baselines/reference/spreadOverwritesPropertyStrict.types index 9ecf3c2b94e22..62a109a410f9a 100644 --- a/tests/baselines/reference/spreadOverwritesPropertyStrict.types +++ b/tests/baselines/reference/spreadOverwritesPropertyStrict.types @@ -5,7 +5,7 @@ declare var ab: { a: number, b: number }; >b : number declare var abq: { a: number, b?: number }; ->abq : { a: number; b?: number; } +>abq : { a: number; b?: number | undefined; } >a : number >b : number | undefined @@ -27,7 +27,7 @@ var unused3 = { b: 1, ...abq } // ok, abq might have b: undefined >{ b: 1, ...abq } : { a: number; b: number; } >b : number >1 : 1 ->abq : { a: number; b?: number; } +>abq : { a: number; b?: number | undefined; } var unused4 = { ...ab, b: 1 } // ok, we don't care that b in ab is overwritten >unused4 : { b: number; a: number; } @@ -39,7 +39,7 @@ var unused4 = { ...ab, b: 1 } // ok, we don't care that b in ab is overwritten var unused5 = { ...abq, b: 1 } // ok >unused5 : { b: number; a: number; } >{ ...abq, b: 1 } : { b: number; a: number; } ->abq : { a: number; b?: number; } +>abq : { a: number; b?: number | undefined; } >b : number >1 : 1 @@ -78,14 +78,14 @@ function h(obj: { x: number } | { x: string }) { >obj : { x: number; } | { x: string; } } function i(b: boolean, t: { command: string, ok: string }) { ->i : (b: boolean, t: { command: string; ok: string;}) => { command: string; ok?: string; } +>i : (b: boolean, t: { command: string; ok: string;}) => { command: string; ok?: string | undefined; } >b : boolean >t : { command: string; ok: string; } >command : string >ok : string return { command: "hi", ...(b ? t : {}) } // ok ->{ command: "hi", ...(b ? t : {}) } : { command: string; ok?: string; } +>{ command: "hi", ...(b ? t : {}) } : { command: string; ok?: string | undefined; } >command : string >"hi" : "hi" >(b ? t : {}) : { command: string; ok: string; } | {} diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index e1c5ef2bcd17d..fabb4d8bc8076 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -79,12 +79,12 @@ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json index 4dac607128f16..d7ab4c78b3b6c 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json @@ -79,12 +79,12 @@ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index 22b2990e991d9..3641adac589f0 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -79,12 +79,12 @@ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index a2e520b658ec1..c17c9e888bc91 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -79,12 +79,12 @@ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 65948b3da0b4c..1d8029a48a51f 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -79,12 +79,12 @@ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 8d3e008e22ca3..d5597eb32de41 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -79,12 +79,12 @@ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index e1c5ef2bcd17d..fabb4d8bc8076 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -79,12 +79,12 @@ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 4f4aa82160934..d71d6cd9dfe21 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -79,12 +79,12 @@ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index 0ffa10335be50..067fd945939a0 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -79,12 +79,12 @@ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js index 8f95fdf16180a..bb4a4cbbe4039 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js @@ -100,12 +100,12 @@ interface Array { length: number; [n: number]: T; } // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js index d02d550323450..9f2abff782a83 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js @@ -100,12 +100,12 @@ interface Array { length: number; [n: number]: T; } // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js index 85180bd89d9ce..81c67ec96e420 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js @@ -100,12 +100,12 @@ interface Array { length: number; [n: number]: T; } // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js index 8de7b095812c2..deb41e96a51de 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js @@ -100,12 +100,12 @@ interface Array { length: number; [n: number]: T; } // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js index f26ee9895a71e..bf0c2f06c386e 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js @@ -100,12 +100,12 @@ interface Array { length: number; [n: number]: T; } // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js index cf5107b973bfd..7aa3bc919f6a4 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js @@ -100,12 +100,12 @@ interface Array { length: number; [n: number]: T; } // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictOptionalProperties": true, /* Enable strict checking of optional properties. */ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ diff --git a/tests/baselines/reference/tsxInvokeComponentType.types b/tests/baselines/reference/tsxInvokeComponentType.types index fc20c0caf527b..a8cad986828b1 100644 --- a/tests/baselines/reference/tsxInvokeComponentType.types +++ b/tests/baselines/reference/tsxInvokeComponentType.types @@ -20,12 +20,12 @@ const good = ; >someKey : string declare const Elem2: ComponentType<{ opt?: number }>; ->Elem2 : React.ComponentType<{ opt?: number; }> +>Elem2 : React.ComponentType<{ opt?: number | undefined; }> >opt : number | undefined const alsoOk = text; >alsoOk : JSX.Element >text : JSX.Element ->Elem2 : React.ComponentType<{ opt?: number; }> ->Elem2 : React.ComponentType<{ opt?: number; }> +>Elem2 : React.ComponentType<{ opt?: number | undefined; }> +>Elem2 : React.ComponentType<{ opt?: number | undefined; }> diff --git a/tests/baselines/reference/tsxLibraryManagedAttributes.errors.txt b/tests/baselines/reference/tsxLibraryManagedAttributes.errors.txt index 2f8bd35e62713..75911e6e6c5ca 100644 --- a/tests/baselines/reference/tsxLibraryManagedAttributes.errors.txt +++ b/tests/baselines/reference/tsxLibraryManagedAttributes.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(69,26): error TS2322 tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(71,35): error TS2322: Type 'null' is not assignable to type 'ReactNode'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(80,38): error TS2322: Type '{ foo: number; bar: string; }' is not assignable to type 'Defaultize<{}, { foo: number; }>'. Property 'bar' does not exist on type 'Defaultize<{}, { foo: number; }>'. -tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(81,29): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(81,29): error TS2322: Type 'string' is not assignable to type 'number | undefined'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(98,12): error TS2322: Type '{ foo: string; }' is not assignable to type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: string; }>'. Type '{ foo: string; }' is missing the following properties from type '{ bar: ReactNode | null | undefined; baz: number; }': bar, baz tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(100,56): error TS2322: Type '{ bar: string; baz: number; bat: string; }' is not assignable to type 'Defaultize; bar: PropTypeChecker; baz: PropTypeChecker; }>, { foo: string; }>'. @@ -18,7 +18,7 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(112,46): error TS232 tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(113,57): error TS2322: Type 'null' is not assignable to type 'ReactNode'. tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(122,58): error TS2322: Type '{ foo: string; bar: string; }' is not assignable to type 'Defaultize'. Property 'bar' does not exist on type 'Defaultize'. -tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS2322: Type 'number' is not assignable to type 'string | undefined'. ==== tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx (15 errors) ==== @@ -121,7 +121,7 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS232 !!! error TS2322: Property 'bar' does not exist on type 'Defaultize<{}, { foo: number; }>'. const m = ; // error, wrong type ~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. !!! related TS6500 tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx:75:9: The expected type comes from property 'foo' which is declared here on type 'Defaultize<{}, { foo: number; }>' interface FooProps { @@ -186,7 +186,7 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS232 !!! error TS2322: Property 'bar' does not exist on type 'Defaultize'. const z = ; // error, wrong type ~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string | undefined'. !!! related TS6500 tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx:117:9: The expected type comes from property 'foo' which is declared here on type 'Defaultize' const aa = ; \ No newline at end of file diff --git a/tests/baselines/reference/typeFromContextualThisType.types b/tests/baselines/reference/typeFromContextualThisType.types index 015480578b5b7..035ab3eb3b09e 100644 --- a/tests/baselines/reference/typeFromContextualThisType.types +++ b/tests/baselines/reference/typeFromContextualThisType.types @@ -20,7 +20,7 @@ const o1 = { /** @type {{ d(): void; e?(n: number): number; f?(n: number): number; g?: number }} */ const o2 = { ->o2 : { d(): void; e?(n: number): number; f?(n: number): number; g?: number; } +>o2 : { d(): void; e?(n: number): number; f?(n: number): number; g?: number | undefined; } >{ d() { this.e = this.f = m => this.g || m; }} : { d(): void; } d() { @@ -29,17 +29,17 @@ const o2 = { this.e = this.f = m => this.g || m; >this.e = this.f = m => this.g || m : (m: number) => number >this.e : ((n: number) => number) | undefined ->this : { d(): void; e?(n: number): number; f?(n: number): number; g?: number; } +>this : { d(): void; e?(n: number): number; f?(n: number): number; g?: number | undefined; } >e : ((n: number) => number) | undefined >this.f = m => this.g || m : (m: number) => number >this.f : ((n: number) => number) | undefined ->this : { d(): void; e?(n: number): number; f?(n: number): number; g?: number; } +>this : { d(): void; e?(n: number): number; f?(n: number): number; g?: number | undefined; } >f : ((n: number) => number) | undefined >m => this.g || m : (m: number) => number >m : number >this.g || m : number >this.g : number | undefined ->this : { d(): void; e?(n: number): number; f?(n: number): number; g?: number; } +>this : { d(): void; e?(n: number): number; f?(n: number): number; g?: number | undefined; } >g : number | undefined >m : number } diff --git a/tests/baselines/reference/typeGuardNarrowsIndexedAccessOfKnownProperty.types b/tests/baselines/reference/typeGuardNarrowsIndexedAccessOfKnownProperty.types index 0d7293ea1efc3..f88376b118fb0 100644 --- a/tests/baselines/reference/typeGuardNarrowsIndexedAccessOfKnownProperty.types +++ b/tests/baselines/reference/typeGuardNarrowsIndexedAccessOfKnownProperty.types @@ -290,15 +290,15 @@ function check(z: Z, c: C) { export function g(pair: [number, string?]): string { >g : (pair: [number, string?]) => string ->pair : [number, string?] +>pair : [number, (string | undefined)?] return pair[1] ? pair[1] : 'nope'; >pair[1] ? pair[1] : 'nope' : string >pair[1] : string | undefined ->pair : [number, string?] +>pair : [number, (string | undefined)?] >1 : 1 >pair[1] : string ->pair : [number, string?] +>pair : [number, (string | undefined)?] >1 : 1 >'nope' : "nope" } diff --git a/tests/baselines/reference/unionExcessPropsWithPartialMember.types b/tests/baselines/reference/unionExcessPropsWithPartialMember.types index cd6f429b18079..2c3460d977c07 100644 --- a/tests/baselines/reference/unionExcessPropsWithPartialMember.types +++ b/tests/baselines/reference/unionExcessPropsWithPartialMember.types @@ -22,9 +22,9 @@ declare var a: A; >a : A ab = {...a, y: (null as any as string | undefined)}; // Should be allowed, since `y` is missing on `A` ->ab = {...a, y: (null as any as string | undefined)} : { y: string | undefined; unused?: string; x: string; } +>ab = {...a, y: (null as any as string | undefined)} : { y: string | undefined; unused?: string | undefined; x: string; } >ab : A | B ->{...a, y: (null as any as string | undefined)} : { y: string | undefined; unused?: string; x: string; } +>{...a, y: (null as any as string | undefined)} : { y: string | undefined; unused?: string | undefined; x: string; } >a : A >y : string | undefined >(null as any as string | undefined) : string | undefined diff --git a/tests/baselines/reference/unionTypeInference.types b/tests/baselines/reference/unionTypeInference.types index 9e54f9e5bd37b..268d4ed86ebfb 100644 --- a/tests/baselines/reference/unionTypeInference.types +++ b/tests/baselines/reference/unionTypeInference.types @@ -213,26 +213,26 @@ async function fun(deepPromised: DeepPromised) { >deepPromised : DeepPromised for (const value of Object.values(deepPromisedWithIndexer)) { ->value : {} | ({ [containsPromises]?: true; } & {}) | Promise<{ [containsPromises]?: true; } & {}> | null | undefined ->Object.values(deepPromisedWithIndexer) : ({} | ({ [containsPromises]?: true; } & {}) | Promise<{ [containsPromises]?: true; } & {}> | null | undefined)[] +>value : {} | ({ [containsPromises]?: true | undefined; } & {}) | Promise<{ [containsPromises]?: true | undefined; } & {}> | null | undefined +>Object.values(deepPromisedWithIndexer) : ({} | ({ [containsPromises]?: true | undefined; } & {}) | Promise<{ [containsPromises]?: true | undefined; } & {}> | null | undefined)[] >Object.values : { (o: { [s: string]: T; } | ArrayLike): T[]; (o: {}): any[]; } >Object : ObjectConstructor >values : { (o: { [s: string]: T; } | ArrayLike): T[]; (o: {}): any[]; } >deepPromisedWithIndexer : DeepPromised<{ [name: string]: {} | null | undefined; }> const awaitedValue = await value; ->awaitedValue : {} | ({ [containsPromises]?: true; } & {}) | null | undefined ->await value : {} | ({ [containsPromises]?: true; } & {}) | null | undefined ->value : {} | ({ [containsPromises]?: true; } & {}) | Promise<{ [containsPromises]?: true; } & {}> | null | undefined +>awaitedValue : {} | ({ [containsPromises]?: true | undefined; } & {}) | null | undefined +>await value : {} | ({ [containsPromises]?: true | undefined; } & {}) | null | undefined +>value : {} | ({ [containsPromises]?: true | undefined; } & {}) | Promise<{ [containsPromises]?: true | undefined; } & {}> | null | undefined if (awaitedValue) ->awaitedValue : {} | ({ [containsPromises]?: true; } & {}) | null | undefined +>awaitedValue : {} | ({ [containsPromises]?: true | undefined; } & {}) | null | undefined await fun(awaitedValue); >await fun(awaitedValue) : void >fun(awaitedValue) : Promise >fun : (deepPromised: DeepPromised) => Promise ->awaitedValue : {} | ({ [containsPromises]?: true; } & {}) +>awaitedValue : {} | ({ [containsPromises]?: true | undefined; } & {}) } } diff --git a/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.types b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.types index a9f53e30f0bc8..62dcc0607ae33 100644 --- a/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.types +++ b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.types @@ -21,7 +21,7 @@ export function foo(p: Promise) { p[FOO_SYMBOL] = 3; >p[FOO_SYMBOL] = 3 : 3 ->p[FOO_SYMBOL] : number +>p[FOO_SYMBOL] : number | undefined >p : Promise >FOO_SYMBOL : unique symbol >3 : 3 diff --git a/tests/baselines/reference/variadicTuples1.errors.txt b/tests/baselines/reference/variadicTuples1.errors.txt index 26e303faa69df..781160d18d9ab 100644 --- a/tests/baselines/reference/variadicTuples1.errors.txt +++ b/tests/baselines/reference/variadicTuples1.errors.txt @@ -35,7 +35,7 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(191,5): error TS2322: Typ 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'readonly string[]'. tests/cases/conformance/types/tuple/variadicTuples1.ts(203,5): error TS2322: Type 'string' is not assignable to type 'keyof [1, 2, ...T]'. Type '"2"' is not assignable to type 'number | "0" | keyof T[] | "1"'. -tests/cases/conformance/types/tuple/variadicTuples1.ts(357,26): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/tuple/variadicTuples1.ts(357,26): error TS2322: Type 'string' is not assignable to type 'number | undefined'. tests/cases/conformance/types/tuple/variadicTuples1.ts(397,7): error TS2322: Type '[false, false]' is not assignable to type '[...number[], boolean]'. Type at position 0 in source is not compatible with type at position 0 in target. Type 'boolean' is not assignable to type 'number'. @@ -456,7 +456,7 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(397,7): error TS2322: Typ let v1 = f20(args); // U let v2 = f20(["foo", "bar"]); // [string] ~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. let v3 = f20(["foo", 42]); // [string] } diff --git a/tests/baselines/reference/variadicTuples1.types b/tests/baselines/reference/variadicTuples1.types index 01af769fb7683..3bb6d7d6d65c2 100644 --- a/tests/baselines/reference/variadicTuples1.types +++ b/tests/baselines/reference/variadicTuples1.types @@ -412,10 +412,10 @@ type TM1 = ArrayifyTM1 : readonly [string[], (number | undefined)[]?, ...Arrayify, ...boolean[][]] type TP1 = Partial<[string, ...T, number]>; // [string?, Partial, number?] ->TP1 : [string?, ...Partial, number?] +>TP1 : [(string | undefined)?, ...Partial, (number | undefined)?] type TP2 = Partial<[string, ...T, ...number[]]>; // [string?, Partial, ...(number | undefined)[]] ->TP2 : [string?, ...Partial, ...(number | undefined)[]] +>TP2 : [(string | undefined)?, ...Partial, ...(number | undefined)[]] // Reverse mapping through mapped type applied to variadic tuple type @@ -897,7 +897,7 @@ type T34 = DropLast<[symbol, ...string[]]>; >T34 : [symbol, ...string[]] type T35 = DropLast<[string?]>; ->T35 : [string?] +>T35 : [(string | undefined)?] type T36 = DropLast; >T36 : string[] @@ -1181,11 +1181,11 @@ curry2(fn10, ['hello'], [42, true]); declare function ft(t1: [...T], t2: [...T, number?]): T; >ft : (t1: [...T], t2: [...T, number?]) => T >t1 : [...T] ->t2 : [...T, number?] +>t2 : [...T, (number | undefined)?] ft([1, 2, 3], [1, 2, 3]); >ft([1, 2, 3], [1, 2, 3]) : [number, number, number] ->ft : (t1: [...T], t2: [...T, number?]) => T +>ft : (t1: [...T], t2: [...T, (number | undefined)?]) => T >[1, 2, 3] : [number, number, number] >1 : 1 >2 : 2 @@ -1197,7 +1197,7 @@ ft([1, 2, 3], [1, 2, 3]); ft([1, 2], [1, 2, 3]); >ft([1, 2], [1, 2, 3]) : [number, number] ->ft : (t1: [...T], t2: [...T, number?]) => T +>ft : (t1: [...T], t2: [...T, (number | undefined)?]) => T >[1, 2] : [number, number] >1 : 1 >2 : 2 @@ -1208,7 +1208,7 @@ ft([1, 2], [1, 2, 3]); ft(['a', 'b'], ['c', 'd']) >ft(['a', 'b'], ['c', 'd']) : [string, string] ->ft : (t1: [...T], t2: [...T, number?]) => T +>ft : (t1: [...T], t2: [...T, (number | undefined)?]) => T >['a', 'b'] : [string, string] >'a' : "a" >'b' : "b" @@ -1218,7 +1218,7 @@ ft(['a', 'b'], ['c', 'd']) ft(['a', 'b'], ['c', 'd', 42]) >ft(['a', 'b'], ['c', 'd', 42]) : [string, string] ->ft : (t1: [...T], t2: [...T, number?]) => T +>ft : (t1: [...T], t2: [...T, (number | undefined)?]) => T >['a', 'b'] : [string, string] >'a' : "a" >'b' : "b" @@ -1257,22 +1257,22 @@ call(...sa, (...x) => 42); declare function f20(args: [...T, number?]): T; >f20 : (args: [...T, number?]) => T ->args : [...T, number?] +>args : [...T, (number | undefined)?] function f21(args: [...U, number?]) { >f21 : (args: [...U, number?]) => void ->args : [...U, number?] +>args : [...U, (number | undefined)?] let v1 = f20(args); // U >v1 : U >f20(args) : U ->f20 : (args: [...T, number?]) => T ->args : [...U, number?] +>f20 : (args: [...T, (number | undefined)?]) => T +>args : [...U, (number | undefined)?] let v2 = f20(["foo", "bar"]); // [string] >v2 : [string] >f20(["foo", "bar"]) : [string] ->f20 : (args: [...T, number?]) => T +>f20 : (args: [...T, (number | undefined)?]) => T >["foo", "bar"] : [string, string] >"foo" : "foo" >"bar" : "bar" @@ -1280,7 +1280,7 @@ function f21(args: [...U, number?]) { let v3 = f20(["foo", 42]); // [string] >v3 : [string] >f20(["foo", 42]) : [string] ->f20 : (args: [...T, number?]) => T +>f20 : (args: [...T, (number | undefined)?]) => T >["foo", 42] : [string, number] >"foo" : "foo" >42 : 42 @@ -1349,16 +1349,16 @@ const b = a.bind("", 1); // Desc<[boolean], object> // Repro from #39607 declare function getUser(id: string, options?: { x?: string }): string; ->getUser : (id: string, options?: { x?: string; } | undefined) => string +>getUser : (id: string, options?: { x?: string | undefined; } | undefined) => string >id : string ->options : { x?: string; } | undefined +>options : { x?: string | undefined; } | undefined >x : string | undefined declare function getOrgUser(id: string, orgId: number, options?: { y?: number, z?: boolean }): void; ->getOrgUser : (id: string, orgId: number, options?: { y?: number; z?: boolean; } | undefined) => void +>getOrgUser : (id: string, orgId: number, options?: { y?: number | undefined; z?: boolean | undefined; } | undefined) => void >id : string >orgId : number ->options : { y?: number; z?: boolean; } | undefined +>options : { y?: number | undefined; z?: boolean | undefined; } | undefined >y : number | undefined >z : boolean | undefined @@ -1380,12 +1380,12 @@ function callApi(method: (...args: [...T, ob callApi(getUser); >callApi(getUser) : (id: string) => string >callApi : (method: (...args: [...T, object]) => U) => (...args_0: T) => U ->getUser : (id: string, options?: { x?: string; } | undefined) => string +>getUser : (id: string, options?: { x?: string | undefined; } | undefined) => string callApi(getOrgUser); >callApi(getOrgUser) : (id: string, orgId: number) => void >callApi : (method: (...args: [...T, object]) => U) => (...args_0: T) => U ->getOrgUser : (id: string, orgId: number, options?: { y?: number; z?: boolean; } | undefined) => void +>getOrgUser : (id: string, orgId: number, options?: { y?: number | undefined; z?: boolean | undefined; } | undefined) => void // Repro from #40235 diff --git a/tests/baselines/reference/variadicTuples2.types b/tests/baselines/reference/variadicTuples2.types index 493d283daa4be..b60c45bc727f6 100644 --- a/tests/baselines/reference/variadicTuples2.types +++ b/tests/baselines/reference/variadicTuples2.types @@ -37,7 +37,7 @@ type V23 = Tup3<[number], string[], [boolean?]>; // [number, (string | boolean >V23 : [number, ...(string | boolean | undefined)[]] type V24 = Tup3<[number], [boolean?], string[]>; // [number, boolean?, ...string[]] ->V24 : [number, boolean?, ...string[]] +>V24 : [number, (boolean | undefined)?, ...string[]] type V25 = Tup3; // (string | number | boolean)[] >V25 : (string | number | boolean)[] @@ -46,7 +46,7 @@ type V26 = Tup3; // [...(string | number)[], boo >V26 : [...(string | number)[], boolean] type V27 = Tup3<[number?], [string], [boolean?]>; // [number | undefined, string, boolean?] ->V27 : [number | undefined, string, boolean?] +>V27 : [number | undefined, string, (boolean | undefined)?] type V30 = Tup3; // [...A, ...(string | number)[]] >V30 : [...A, ...(string | number)[]] @@ -58,13 +58,13 @@ type V32 = Tup3; // [...(string | n >V32 : [...(string | number)[], ...A] type V40 = Tup3; // [...A, string?, ...number[]] ->V40 : [...A, string?, ...number[]] +>V40 : [...A, (string | undefined)?, ...number[]] type V41 = Tup3<[string?], A, number[]>; // [string?, ...A, ...number[]] ->V41 : [string?, ...A, ...number[]] +>V41 : [(string | undefined)?, ...A, ...number[]] type V42 = Tup3<[string?], number[], A>; // [string?, ...number[], ...A] ->V42 : [string?, ...number[], ...A] +>V42 : [(string | undefined)?, ...number[], ...A] type V50 = Tup3; // [...A, ...(string | number | undefined)[]] >V50 : [...A, ...(string | number | undefined)[]] diff --git a/tests/cases/compiler/inferenceOptionalProperties.ts b/tests/cases/compiler/inferenceOptionalProperties.ts index f1d4fec0903a2..085b6b2466fcc 100644 --- a/tests/cases/compiler/inferenceOptionalProperties.ts +++ b/tests/cases/compiler/inferenceOptionalProperties.ts @@ -1,5 +1,5 @@ // @strict: true -// @strictOptionalProperties: true +// @exactOptionalPropertyTypes: true // @declaration: true declare function test(x: { [key: string]: T }): T; diff --git a/tests/cases/compiler/inferenceOptionalPropertiesStrict.ts b/tests/cases/compiler/inferenceOptionalPropertiesStrict.ts index f1d4fec0903a2..085b6b2466fcc 100644 --- a/tests/cases/compiler/inferenceOptionalPropertiesStrict.ts +++ b/tests/cases/compiler/inferenceOptionalPropertiesStrict.ts @@ -1,5 +1,5 @@ // @strict: true -// @strictOptionalProperties: true +// @exactOptionalPropertyTypes: true // @declaration: true declare function test(x: { [key: string]: T }): T; diff --git a/tests/cases/compiler/strictOptionalProperties1.ts b/tests/cases/compiler/strictOptionalProperties1.ts index fd47c98aad01d..1a71bb3dd75ae 100644 --- a/tests/cases/compiler/strictOptionalProperties1.ts +++ b/tests/cases/compiler/strictOptionalProperties1.ts @@ -1,4 +1,5 @@ // @strict: true +// @exactOptionalPropertyTypes: true // @declaration: true function f1(obj: { a?: string, b?: string | undefined }) { diff --git a/tests/cases/compiler/strictOptionalProperties2.ts b/tests/cases/compiler/strictOptionalProperties2.ts index 21d1959545d22..56076b2274331 100644 --- a/tests/cases/compiler/strictOptionalProperties2.ts +++ b/tests/cases/compiler/strictOptionalProperties2.ts @@ -1,4 +1,5 @@ // @strict: true +// @exactOptionalPropertyTypes: true // @declaration: true // Repro from #44567