diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ebd026658ff95..0c0770c247fe0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -464,6 +464,7 @@ import { IntersectionFlags, IntersectionType, IntersectionTypeNode, + IntraExpressionInferenceSite, intrinsicTagNameToString, IntrinsicType, introducesArgumentsExoticObject, @@ -2366,6 +2367,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { var reverseMappedSourceStack: Type[] = []; var reverseMappedTargetStack: Type[] = []; var reverseExpandingFlags = ExpandingFlags.None; + var reversePartialHomomorphicInferrableTypes = new Map(); var diagnostics = createDiagnosticCollection(); var suggestionDiagnostics = createDiagnosticCollection(); @@ -14646,7 +14648,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const modifiers = getMappedTypeModifiers(type.mappedType); const readonlyMask = modifiers & MappedTypeModifiers.IncludeReadonly ? false : true; const optionalMask = modifiers & MappedTypeModifiers.IncludeOptional ? 0 : SymbolFlags.Optional; - const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType) || unknownType, readonlyMask && indexInfo.isReadonly)] : emptyArray; + const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType, /*sourceValueDeclaration*/ undefined) || unknownType, readonlyMask && indexInfo.isReadonly)] : emptyArray; const members = createSymbolTable(); const limitedConstraint = getLimitedConstraint(type); for (const prop of getPropertiesOfType(type.source)) { @@ -14662,6 +14664,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const checkFlags = CheckFlags.ReverseMapped | (readonlyMask && isReadonlySymbol(prop) ? CheckFlags.Readonly : 0); const inferredProp = createSymbol(SymbolFlags.Property | prop.flags & optionalMask, prop.escapedName, checkFlags) as ReverseMappedSymbol; inferredProp.declarations = prop.declarations; + inferredProp.valueDeclaration = prop.valueDeclaration; + inferredProp.links.reverseMappedType = type; inferredProp.links.nameType = getSymbolLinks(prop).nameType; inferredProp.links.propertyType = getTypeOfSymbol(prop); if ( @@ -26206,7 +26210,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!inference.isFixed) { // Before we commit to a particular inference (and thus lock out any further inferences), // we infer from any intra-expression inference sites we have collected. - inferFromIntraExpressionSites(context); + if (context.intraExpressionInferenceSites) { + inferFromIntraExpressionSites(context.inferences, context.intraExpressionInferenceSites); + context.intraExpressionInferenceSites = undefined; + } clearCachedInferences(context.inferences); inference.isFixed = true; } @@ -26233,7 +26240,34 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function addIntraExpressionInferenceSite(context: InferenceContext, node: Expression | MethodDeclaration, type: Type) { - (context.intraExpressionInferenceSites ??= []).push({ node, type }); + const site = { node, type }; + (context.intraExpressionInferenceSites ??= []).push(site); + if (context.reverseMappedIntraExpressionInferenceSites) { + for (const reverseMappedSites of context.reverseMappedIntraExpressionInferenceSites) { + reverseMappedSites.push(site); + } + } + } + + function pushReverseMappedTypeIntraExpressionInferenceScope(context: InferenceContext, node: Node) { + (context.reverseMappedIntraExpressionInferenceScopeNodes ??= []).push(node); + (context.reverseMappedIntraExpressionInferenceSites ??= []).push([]); + } + + function popReverseMappedTypeIntraExpressionInferenceScope(context: InferenceContext) { + context.reverseMappedIntraExpressionInferenceScopeNodes!.pop(); + context.reverseMappedIntraExpressionInferenceSites!.pop(); + } + + function findReverseMappedTypeIntraExpressionInferenceScope(context: InferenceContext | undefined, node: Node) { + if (context?.reverseMappedIntraExpressionInferenceScopeNodes) { + for (let i = context.reverseMappedIntraExpressionInferenceScopeNodes.length - 1; i >= 0; i--) { + if (context.reverseMappedIntraExpressionInferenceScopeNodes[i] === node) { + return i; + } + } + } + return -1; } // We collect intra-expression inference sites within object and array literals to handle cases where @@ -26249,17 +26283,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // arrow function. This happens automatically when the arrow functions are discrete arguments (because we // infer from each argument before processing the next), but when the arrow functions are elements of an // object or array literal, we need to perform intra-expression inferences early. - function inferFromIntraExpressionSites(context: InferenceContext) { - if (context.intraExpressionInferenceSites) { - for (const { node, type } of context.intraExpressionInferenceSites) { - const contextualType = node.kind === SyntaxKind.MethodDeclaration ? - getContextualTypeForObjectLiteralMethod(node as MethodDeclaration, ContextFlags.NoConstraints) : - getContextualType(node, ContextFlags.NoConstraints); - if (contextualType) { - inferTypes(context.inferences, type, contextualType); - } + function inferFromIntraExpressionSites(inferences: InferenceInfo[], intraExpressionInferenceSites: IntraExpressionInferenceSite[]) { + for (const { node, type } of intraExpressionInferenceSites) { + const contextualType = node.kind === SyntaxKind.MethodDeclaration ? + getContextualTypeForObjectLiteralMethod(node as MethodDeclaration, ContextFlags.NoConstraints) : + getContextualType(node, ContextFlags.NoConstraints); + if (contextualType) { + inferTypes(inferences, type, contextualType); } - context.intraExpressionInferenceSites = undefined; } } @@ -26380,33 +26411,27 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return type; } - // We consider a type to be partially inferable if it isn't marked non-inferable or if it is - // an object literal type with at least one property of an inferable type. For example, an object - // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive - // arrow function, but is considered partially inferable because property 'a' has an inferable type. - function isPartiallyInferableType(type: Type): boolean { - return !(getObjectFlags(type) & ObjectFlags.NonInferrableType) || - isObjectLiteralType(type) && some(getPropertiesOfType(type), prop => isPartiallyInferableType(getTypeOfSymbol(prop))) || - isTupleType(type) && some(getElementTypes(type), isPartiallyInferableType); + function isPartialHomomorphicReverseMappedType(type: Type | undefined): boolean { + return !!(type && getObjectFlags(type) & ObjectFlags.ReverseMapped && getObjectFlags((type as ReverseMappedType).source) & ObjectFlags.NonInferrableType); } function createReverseMappedType(source: Type, target: MappedType, constraint: IndexType) { // We consider a source type reverse mappable if it has a string index signature or if - // it has one or more properties and is of a partially inferable type. - if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) { + // it has one or more properties + if (!getIndexInfoOfType(source, stringType) && !getPropertiesOfType(source).length) { return undefined; } // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - const elementType = inferReverseMappedType(getTypeArguments(source)[0], target, constraint); + const elementType = inferReverseMappedType(getTypeArguments(source)[0], target, constraint, /*sourceValueDeclaration*/ undefined); if (!elementType) { return undefined; } return createArrayType(elementType, isReadonlyArrayType(source)); } if (isTupleType(source)) { - const elementTypes = map(getElementTypes(source), t => inferReverseMappedType(t, target, constraint)); + const elementTypes = map(getElementTypes(source), t => inferReverseMappedType(t, target, constraint, /*sourceValueDeclaration*/ undefined)); if (!every(elementTypes, (t): t is Type => !!t)) { return undefined; } @@ -26427,21 +26452,54 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function getTypeOfReverseMappedSymbol(symbol: ReverseMappedSymbol): Type { const links = getSymbolLinks(symbol); if (!links.type) { - links.type = inferReverseMappedType(symbol.links.propertyType, symbol.links.mappedType, symbol.links.constraintType) || unknownType; + const declaration = symbol.valueDeclaration; + let source = symbol.links.propertyType; + if (declaration && getObjectFlags(source) & ObjectFlags.NonInferrableType) { + const inferrableSource = reversePartialHomomorphicInferrableTypes.get(symbol.links.reverseMappedType.id); + if (inferrableSource) { + const name = getSymbolOfDeclaration(declaration).escapedName; + const prop = getPropertyOfType(inferrableSource, name); + if (prop) { + source = getTypeOfSymbol(prop); + } + } + } + links.type = inferReverseMappedType(source, symbol.links.mappedType, symbol.links.constraintType, declaration) || unknownType; } return links.type; } - function inferReverseMappedTypeWorker(sourceType: Type, target: MappedType, constraint: IndexType): Type { + function inferReverseMappedTypeWorker(sourceType: Type, target: MappedType, constraint: IndexType, sourceValueDeclaration: Declaration | undefined): Type { const typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)) as TypeParameter; const templateType = getTemplateTypeFromMappedType(target); const inference = createInferenceInfo(typeParameter); inferTypes([inference], sourceType, templateType); + if (sourceValueDeclaration && getObjectFlags(sourceType) & ObjectFlags.NonInferrableType) { + const scopeNode = sourceValueDeclaration.parent; + const inferenceContext = getInferenceContext(scopeNode); + const index = findReverseMappedTypeIntraExpressionInferenceScope(inferenceContext, scopeNode); + if (index !== -1) { + Debug.assert(inferenceContext); + const intraExpressionSites = inferenceContext.reverseMappedIntraExpressionInferenceSites![index]; + const recordSymbol = getGlobalRecordSymbol(); + if (intraExpressionSites.length && recordSymbol) { + // Intra-expression inference infers from collected sites into their contextual types. + // The scope node is the object literal expression being source of this whole reverse mapped type + // and its regular contextual type is "replaced" here (it overshadows earlier entries on the stack). + // This tricks the algorithm to avoid contextual types for expressions *inside it* being computed of the mapped type substitution. + // So `T[K]` stays as `T[K]` (instead of being instantiated as `T["prop"]`) + // and thus it stays being a viable inference target for inferring the type of this reverse mapped type property. + pushContextualType(scopeNode as Expression, getTypeAliasInstantiation(recordSymbol, [stringNumberSymbolType, templateType]), /*isCache*/ false); + inferFromIntraExpressionSites([inference], intraExpressionSites); + popContextualType(); + } + } + } return getWidenedType(getTypeFromInference(inference) || unknownType); } - function inferReverseMappedType(source: Type, target: MappedType, constraint: IndexType): Type | undefined { - const cacheKey = source.id + "," + target.id + "," + constraint.id; + function inferReverseMappedType(source: Type, target: MappedType, constraint: IndexType, sourceValueDeclaration: Declaration | undefined): Type | undefined { + const cacheKey = source.id + "," + target.id + "," + constraint.id + (sourceValueDeclaration && getObjectFlags(source) & ObjectFlags.NonInferrableType ? "," + getNodeId(sourceValueDeclaration) : ""); if (reverseMappedCache.has(cacheKey)) { return reverseMappedCache.get(cacheKey) || unknownType; } @@ -26452,7 +26510,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (isDeeplyNestedType(target, reverseMappedTargetStack, reverseMappedTargetStack.length, 2)) reverseExpandingFlags |= ExpandingFlags.Target; let type; if (reverseExpandingFlags !== ExpandingFlags.Both) { - type = inferReverseMappedTypeWorker(source, target, constraint); + type = inferReverseMappedTypeWorker(source, target, constraint, sourceValueDeclaration); } reverseMappedSourceStack.pop(); reverseMappedTargetStack.pop(); @@ -27132,9 +27190,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function inferToMappedType(source: Type, target: MappedType, constraintType: Type): boolean { - if ((constraintType.flags & TypeFlags.Union) || (constraintType.flags & TypeFlags.Intersection)) { + if (constraintType.flags & TypeFlags.UnionOrIntersection) { let result = false; - for (const type of (constraintType as (UnionType | IntersectionType)).types) { + for (const type of (constraintType as (UnionOrIntersectionType)).types) { result = inferToMappedType(source, target, type) || result; } return result; @@ -27145,7 +27203,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // type and then make a secondary inference from that type to T. We make a secondary inference // such that direct inferences to T get priority over inferences to Partial, for example. const inference = getInferenceInfoForType((constraintType as IndexType).type); - if (inference && !inference.isFixed && !isFromInferenceBlockedSource(source)) { + if (inference && (!inference.isFixed || isPartialHomomorphicReverseMappedType(inference.inferredType)) && !isFromInferenceBlockedSource(source)) { + if (inference.isFixed) { + if ((inference.inferredType as ReverseMappedType).source.symbol.valueDeclaration === source.symbol.valueDeclaration) { + reversePartialHomomorphicInferrableTypes.set((inference.inferredType as ReverseMappedType).id, source); + } + return true; + } const inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType as IndexType); if (inferredType) { // We assign a lower priority to inferences made from types containing non-inferrable @@ -33458,6 +33522,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } + const intraExpressionInferenceContext = contextualType && checkMode & CheckMode.Inferential && !(checkMode & CheckMode.SkipContextSensitive) ? getInferenceContext(node) : undefined; + let offset = 0; for (const memberDecl of node.properties) { let member = getSymbolOfDeclaration(memberDecl); @@ -33468,12 +33534,25 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment || isObjectLiteralMethod(memberDecl) ) { + const isIntraExpressionInferenceSource = intraExpressionInferenceContext && (memberDecl.kind === SyntaxKind.PropertyAssignment || memberDecl.kind === SyntaxKind.MethodDeclaration) && isContextSensitive(memberDecl); + if (isIntraExpressionInferenceSource) { + // this object literal is a potential source for reverse mapped type inference + // so we push it onto the reverse mapped intra-expression inference scope stack + // that makes `addIntraExpressionInferenceSite` called when checking expressions *contained in* this member + // to collect intra-expression inference sites for the potential reverse mapped type symbol originating from this member + // the member's type itself wouldn't contribute to intra-expression inference + // as there wouldn't be any "earlier" (in source order) expressions able to "consume" this type through contextual parameter assignment + pushReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext, node); + } let type = memberDecl.kind === SyntaxKind.PropertyAssignment ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); + if (isIntraExpressionInferenceSource) { + popReverseMappedTypeIntraExpressionInferenceScope(intraExpressionInferenceContext); + } if (isInJavascript) { const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); if (jsDocType) { @@ -33521,14 +33600,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { member = prop; allPropertiesTable?.set(prop.escapedName, prop); - if ( - contextualType && checkMode & CheckMode.Inferential && !(checkMode & CheckMode.SkipContextSensitive) && - (memberDecl.kind === SyntaxKind.PropertyAssignment || memberDecl.kind === SyntaxKind.MethodDeclaration) && isContextSensitive(memberDecl) - ) { - const inferenceContext = getInferenceContext(node); - Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context + if (isIntraExpressionInferenceSource) { const inferenceNode = memberDecl.kind === SyntaxKind.PropertyAssignment ? memberDecl.initializer : memberDecl; - addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type); + addIntraExpressionInferenceSite(intraExpressionInferenceContext, inferenceNode, type); } } else if (memberDecl.kind === SyntaxKind.SpreadAssignment) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f0b33e6bac806..a324ba5a17997 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6153,6 +6153,7 @@ export interface MappedSymbol extends TransientSymbol { /** @internal */ export interface ReverseMappedSymbolLinks extends TransientSymbolLinks { + reverseMappedType: ReverseMappedType; propertyType: Type; mappedType: MappedType; constraintType: IndexType; @@ -7156,6 +7157,8 @@ export interface InferenceContext { outerReturnMapper?: TypeMapper; // Type mapper for inferences from return types of outer function (if any) inferredTypeParameters?: readonly TypeParameter[]; // Inferred type parameters for function result intraExpressionInferenceSites?: IntraExpressionInferenceSite[]; + reverseMappedIntraExpressionInferenceScopeNodes?: Node[]; + reverseMappedIntraExpressionInferenceSites?: IntraExpressionInferenceSite[][]; } /** @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4939145c433c7..fd08309c1a841 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -8002,13 +8002,14 @@ export function getCheckFlags(symbol: Symbol): CheckFlags { /** @internal */ export function getDeclarationModifierFlagsFromSymbol(s: Symbol, isWrite = false): ModifierFlags { - if (s.valueDeclaration) { + const checkFlags = getCheckFlags(s); + if (!(checkFlags & CheckFlags.ReverseMapped) && s.valueDeclaration) { const declaration = (isWrite && s.declarations && find(s.declarations, isSetAccessorDeclaration)) || (s.flags & SymbolFlags.GetAccessor && find(s.declarations, isGetAccessorDeclaration)) || s.valueDeclaration; const flags = getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & SymbolFlags.Class ? flags : flags & ~ModifierFlags.AccessibilityModifier; } - if (getCheckFlags(s) & CheckFlags.Synthetic) { + if (checkFlags & CheckFlags.Synthetic) { // NOTE: potentially unchecked cast to TransientSymbol const checkFlags = (s as TransientSymbol).links.checkFlags; const accessModifier = checkFlags & CheckFlags.ContainsPrivate ? ModifierFlags.Private : diff --git a/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.errors.txt b/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.errors.txt new file mode 100644 index 0000000000000..48955e4b6f38a --- /dev/null +++ b/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.errors.txt @@ -0,0 +1,310 @@ +intraExpressionInferencesReverseMappedTypes.ts(67,21): error TS18046: 'x' is of type 'unknown'. +intraExpressionInferencesReverseMappedTypes.ts(71,21): error TS18046: 'x' is of type 'unknown'. +intraExpressionInferencesReverseMappedTypes.ts(80,21): error TS18046: 'x' is of type 'unknown'. +intraExpressionInferencesReverseMappedTypes.ts(86,21): error TS18046: 'x' is of type 'unknown'. +intraExpressionInferencesReverseMappedTypes.ts(95,21): error TS18046: 'x' is of type 'unknown'. +intraExpressionInferencesReverseMappedTypes.ts(101,21): error TS18046: 'x' is of type 'unknown'. + + +==== intraExpressionInferencesReverseMappedTypes.ts (6 errors) ==== + // repro cases based on https://github.com/microsoft/TypeScript/issues/53018 + + declare function f( + arg: { + [K in keyof T]: { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + } + ): T; + + const res1 = f({ + a: { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }, + b: { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }, + }); + + const res2 = f({ + a: { + produce: function () { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + }, + b: { + produce: function () { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + }, + }); + + const res3 = f({ + a: { + produce() { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + }, + b: { + produce() { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + }, + }); + + declare function f2( + arg: [ + ...{ + [K in keyof T]: { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + } + ] + ): T; + + const res4 = f2([ + { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + ~ +!!! error TS18046: 'x' is of type 'unknown'. + }, + { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + ~ +!!! error TS18046: 'x' is of type 'unknown'. + }, + ]); + + const res5 = f2([ + { + produce: function () { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + ~ +!!! error TS18046: 'x' is of type 'unknown'. + }, + { + produce: function () { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + ~ +!!! error TS18046: 'x' is of type 'unknown'. + }, + ]); + + const res6 = f2([ + { + produce() { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + ~ +!!! error TS18046: 'x' is of type 'unknown'. + }, + { + produce() { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + ~ +!!! error TS18046: 'x' is of type 'unknown'. + }, + ]); + + declare function f3( + arg: { + [K in keyof T]: { + other: number, + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + } + ): T; + + const res7 = f3({ + a: { + other: 42, + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }, + b: { + other: 100, + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }, + }); + + declare function f4( + arg: { + [K in keyof T]: [ + (n: string) => T[K], + (x: T[K]) => void + ]; + } + ): T; + + const res8 = f4({ + a: [ + (n) => n, + (x) => x.toLowerCase(), + ], + b: [ + (n) => ({ v: n }), + (x) => x.v.toLowerCase(), + ], + }); + + declare function f5( + arg: { + [K in keyof T1]: { + produce1: (n: string) => T1[K]; + consume1: (x: T1[K]) => void; + }; + } & { + [K in keyof T2]: { + produce2: (n: string) => T2[K]; + consume2: (x: T2[K]) => void; + }; + }, + ): [T1, T2]; + + const res9 = f5({ + a: { + produce1: (n) => n, + consume1: (x) => x.toLowerCase(), + produce2: (n) => [n], + consume2: (x) => x[0].toLowerCase(), + }, + b: { + produce1: (n) => ({ v: n }), + consume1: (x) => x.v.toLowerCase(), + produce2: (n) => ({ v: [n] }), + consume2: (x) => x.v[0].toLowerCase(), + }, + }); + + declare function f6(arg: { + [K in keyof T]: () => { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + }): T; + + const res10 = f6({ + a() { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b() { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, + }); + + const res11 = f6({ + a: () => { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b: () => { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, + }); + + declare function f7(arg: { + [K in keyof T]: (arg: boolean) => { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + }): T; + + const res12 = f7({ + a(arg) { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b(arg) { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, + }); + + const res13 = f7({ + a: (arg) => { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b: (arg) => { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, + }); + + declare function f8(arg: { + [K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void]; + }): T; + + const res14 = f8({ + a() { + return [(n) => n, (x) => x.toLowerCase()]; + }, + b() { + return [(n) => ({ v: n }), (x) => x.v.toLowerCase()]; + }, + }); + + declare function f9( + arg: { + [K in keyof T1]: { + produce: (n: string) => [T1[K], any]; + consume: (x: T1[K]) => void; + }; + } & { + a: { + produce: (n: string) => [any, T2]; + consume2: (x: T2) => void; + }; + }, + ): [T1, T2]; + + const res15 = f9({ + a: { + produce: (n) => [n, [n]], + consume2: (x) => x[0].toLowerCase(), + consume: (x) => x.toLowerCase(), + }, + b: { + produce: (n) => [{ v: n }, null], + consume: (x) => x.v.toLowerCase(), + }, + }); + \ No newline at end of file diff --git a/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.js b/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.js new file mode 100644 index 0000000000000..62cfac8935e17 --- /dev/null +++ b/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.js @@ -0,0 +1,636 @@ +//// [tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesReverseMappedTypes.ts] //// + +//// [intraExpressionInferencesReverseMappedTypes.ts] +// repro cases based on https://github.com/microsoft/TypeScript/issues/53018 + +declare function f( + arg: { + [K in keyof T]: { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + } +): T; + +const res1 = f({ + a: { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }, + b: { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }, +}); + +const res2 = f({ + a: { + produce: function () { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + }, + b: { + produce: function () { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + }, +}); + +const res3 = f({ + a: { + produce() { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + }, + b: { + produce() { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + }, +}); + +declare function f2( + arg: [ + ...{ + [K in keyof T]: { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + } + ] +): T; + +const res4 = f2([ + { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }, + { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }, +]); + +const res5 = f2([ + { + produce: function () { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + }, + { + produce: function () { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + }, +]); + +const res6 = f2([ + { + produce() { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + }, + { + produce() { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + }, +]); + +declare function f3( + arg: { + [K in keyof T]: { + other: number, + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + } +): T; + +const res7 = f3({ + a: { + other: 42, + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }, + b: { + other: 100, + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }, +}); + +declare function f4( + arg: { + [K in keyof T]: [ + (n: string) => T[K], + (x: T[K]) => void + ]; + } +): T; + +const res8 = f4({ + a: [ + (n) => n, + (x) => x.toLowerCase(), + ], + b: [ + (n) => ({ v: n }), + (x) => x.v.toLowerCase(), + ], +}); + +declare function f5( + arg: { + [K in keyof T1]: { + produce1: (n: string) => T1[K]; + consume1: (x: T1[K]) => void; + }; + } & { + [K in keyof T2]: { + produce2: (n: string) => T2[K]; + consume2: (x: T2[K]) => void; + }; + }, +): [T1, T2]; + +const res9 = f5({ + a: { + produce1: (n) => n, + consume1: (x) => x.toLowerCase(), + produce2: (n) => [n], + consume2: (x) => x[0].toLowerCase(), + }, + b: { + produce1: (n) => ({ v: n }), + consume1: (x) => x.v.toLowerCase(), + produce2: (n) => ({ v: [n] }), + consume2: (x) => x.v[0].toLowerCase(), + }, +}); + +declare function f6(arg: { + [K in keyof T]: () => { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; +}): T; + +const res10 = f6({ + a() { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b() { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, +}); + +const res11 = f6({ + a: () => { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b: () => { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, +}); + +declare function f7(arg: { + [K in keyof T]: (arg: boolean) => { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; +}): T; + +const res12 = f7({ + a(arg) { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b(arg) { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, +}); + +const res13 = f7({ + a: (arg) => { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b: (arg) => { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, +}); + +declare function f8(arg: { + [K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void]; +}): T; + +const res14 = f8({ + a() { + return [(n) => n, (x) => x.toLowerCase()]; + }, + b() { + return [(n) => ({ v: n }), (x) => x.v.toLowerCase()]; + }, +}); + +declare function f9( + arg: { + [K in keyof T1]: { + produce: (n: string) => [T1[K], any]; + consume: (x: T1[K]) => void; + }; + } & { + a: { + produce: (n: string) => [any, T2]; + consume2: (x: T2) => void; + }; + }, +): [T1, T2]; + +const res15 = f9({ + a: { + produce: (n) => [n, [n]], + consume2: (x) => x[0].toLowerCase(), + consume: (x) => x.toLowerCase(), + }, + b: { + produce: (n) => [{ v: n }, null], + consume: (x) => x.v.toLowerCase(), + }, +}); + + +//// [intraExpressionInferencesReverseMappedTypes.js] +"use strict"; +// repro cases based on https://github.com/microsoft/TypeScript/issues/53018 +var res1 = f({ + a: { + produce: function (n) { return n; }, + consume: function (x) { return x.toLowerCase(); }, + }, + b: { + produce: function (n) { return ({ v: n }); }, + consume: function (x) { return x.v.toLowerCase(); }, + }, +}); +var res2 = f({ + a: { + produce: function () { + return "hello"; + }, + consume: function (x) { return x.toLowerCase(); }, + }, + b: { + produce: function () { + return { v: "hello" }; + }, + consume: function (x) { return x.v.toLowerCase(); }, + }, +}); +var res3 = f({ + a: { + produce: function () { + return "hello"; + }, + consume: function (x) { return x.toLowerCase(); }, + }, + b: { + produce: function () { + return { v: "hello" }; + }, + consume: function (x) { return x.v.toLowerCase(); }, + }, +}); +var res4 = f2([ + { + produce: function (n) { return n; }, + consume: function (x) { return x.toLowerCase(); }, + }, + { + produce: function (n) { return ({ v: n }); }, + consume: function (x) { return x.v.toLowerCase(); }, + }, +]); +var res5 = f2([ + { + produce: function () { + return "hello"; + }, + consume: function (x) { return x.toLowerCase(); }, + }, + { + produce: function () { + return { v: "hello" }; + }, + consume: function (x) { return x.v.toLowerCase(); }, + }, +]); +var res6 = f2([ + { + produce: function () { + return "hello"; + }, + consume: function (x) { return x.toLowerCase(); }, + }, + { + produce: function () { + return { v: "hello" }; + }, + consume: function (x) { return x.v.toLowerCase(); }, + }, +]); +var res7 = f3({ + a: { + other: 42, + produce: function (n) { return n; }, + consume: function (x) { return x.toLowerCase(); }, + }, + b: { + other: 100, + produce: function (n) { return ({ v: n }); }, + consume: function (x) { return x.v.toLowerCase(); }, + }, +}); +var res8 = f4({ + a: [ + function (n) { return n; }, + function (x) { return x.toLowerCase(); }, + ], + b: [ + function (n) { return ({ v: n }); }, + function (x) { return x.v.toLowerCase(); }, + ], +}); +var res9 = f5({ + a: { + produce1: function (n) { return n; }, + consume1: function (x) { return x.toLowerCase(); }, + produce2: function (n) { return [n]; }, + consume2: function (x) { return x[0].toLowerCase(); }, + }, + b: { + produce1: function (n) { return ({ v: n }); }, + consume1: function (x) { return x.v.toLowerCase(); }, + produce2: function (n) { return ({ v: [n] }); }, + consume2: function (x) { return x.v[0].toLowerCase(); }, + }, +}); +var res10 = f6({ + a: function () { + return { + produce: function (n) { return n; }, + consume: function (x) { return x.toLowerCase(); }, + }; + }, + b: function () { + return { + produce: function (n) { return ({ v: n }); }, + consume: function (x) { return x.v.toLowerCase(); }, + }; + }, +}); +var res11 = f6({ + a: function () { + return { + produce: function (n) { return n; }, + consume: function (x) { return x.toLowerCase(); }, + }; + }, + b: function () { + return { + produce: function (n) { return ({ v: n }); }, + consume: function (x) { return x.v.toLowerCase(); }, + }; + }, +}); +var res12 = f7({ + a: function (arg) { + return { + produce: function (n) { return n; }, + consume: function (x) { return x.toLowerCase(); }, + }; + }, + b: function (arg) { + return { + produce: function (n) { return ({ v: n }); }, + consume: function (x) { return x.v.toLowerCase(); }, + }; + }, +}); +var res13 = f7({ + a: function (arg) { + return { + produce: function (n) { return n; }, + consume: function (x) { return x.toLowerCase(); }, + }; + }, + b: function (arg) { + return { + produce: function (n) { return ({ v: n }); }, + consume: function (x) { return x.v.toLowerCase(); }, + }; + }, +}); +var res14 = f8({ + a: function () { + return [function (n) { return n; }, function (x) { return x.toLowerCase(); }]; + }, + b: function () { + return [function (n) { return ({ v: n }); }, function (x) { return x.v.toLowerCase(); }]; + }, +}); +var res15 = f9({ + a: { + produce: function (n) { return [n, [n]]; }, + consume2: function (x) { return x[0].toLowerCase(); }, + consume: function (x) { return x.toLowerCase(); }, + }, + b: { + produce: function (n) { return [{ v: n }, null]; }, + consume: function (x) { return x.v.toLowerCase(); }, + }, +}); + + +//// [intraExpressionInferencesReverseMappedTypes.d.ts] +declare function f(arg: { + [K in keyof T]: { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; +}): T; +declare const res1: { + a: string; + b: { + v: string; + }; +}; +declare const res2: { + a: string; + b: { + v: string; + }; +}; +declare const res3: { + a: string; + b: { + v: string; + }; +}; +declare function f2(arg: [ + ...{ + [K in keyof T]: { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + } +]): T; +declare const res4: [string, { + v: string; +}]; +declare const res5: [string, { + v: string; +}]; +declare const res6: [string, { + v: string; +}]; +declare function f3(arg: { + [K in keyof T]: { + other: number; + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; +}): T; +declare const res7: { + a: string; + b: { + v: string; + }; +}; +declare function f4(arg: { + [K in keyof T]: [ + (n: string) => T[K], + (x: T[K]) => void + ]; +}): T; +declare const res8: { + a: string; + b: { + v: string; + }; +}; +declare function f5(arg: { + [K in keyof T1]: { + produce1: (n: string) => T1[K]; + consume1: (x: T1[K]) => void; + }; +} & { + [K in keyof T2]: { + produce2: (n: string) => T2[K]; + consume2: (x: T2[K]) => void; + }; +}): [T1, T2]; +declare const res9: [{ + a: string; + b: { + v: string; + }; +}, { + a: string[]; + b: { + v: string[]; + }; +}]; +declare function f6(arg: { + [K in keyof T]: () => { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; +}): T; +declare const res10: { + a: string; + b: { + v: string; + }; +}; +declare const res11: { + a: string; + b: { + v: string; + }; +}; +declare function f7(arg: { + [K in keyof T]: (arg: boolean) => { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; +}): T; +declare const res12: { + a: string; + b: { + v: string; + }; +}; +declare const res13: { + a: string; + b: { + v: string; + }; +}; +declare function f8(arg: { + [K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void]; +}): T; +declare const res14: { + a: string; + b: { + v: string; + }; +}; +declare function f9(arg: { + [K in keyof T1]: { + produce: (n: string) => [T1[K], any]; + consume: (x: T1[K]) => void; + }; +} & { + a: { + produce: (n: string) => [any, T2]; + consume2: (x: T2) => void; + }; +}): [T1, T2]; +declare const res15: [{ + a: string; + b: { + v: string; + }; +}, string[]]; diff --git a/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.symbols b/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.symbols new file mode 100644 index 0000000000000..78f95108f16c8 --- /dev/null +++ b/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.symbols @@ -0,0 +1,917 @@ +//// [tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesReverseMappedTypes.ts] //// + +=== intraExpressionInferencesReverseMappedTypes.ts === +// repro cases based on https://github.com/microsoft/TypeScript/issues/53018 + +declare function f( +>f : Symbol(f, Decl(intraExpressionInferencesReverseMappedTypes.ts, 0, 0)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 2, 19)) + + arg: { +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 2, 22)) + + [K in keyof T]: { +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 4, 5)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 2, 19)) + + produce: (n: string) => T[K]; +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 4, 21)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 5, 16)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 2, 19)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 4, 5)) + + consume: (x: T[K]) => void; +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 5, 35)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 6, 16)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 2, 19)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 4, 5)) + + }; + } +): T; +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 2, 19)) + +const res1 = f({ +>res1 : Symbol(res1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 11, 5)) +>f : Symbol(f, Decl(intraExpressionInferencesReverseMappedTypes.ts, 0, 0)) + + a: { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 11, 16)) + + produce: (n) => n, +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 12, 6)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 13, 14)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 13, 14)) + + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 13, 22)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 14, 14)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 14, 14)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, + b: { +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 15, 4)) + + produce: (n) => ({ v: n }), +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 16, 6)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 17, 14)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 17, 22)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 17, 14)) + + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 17, 31)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 18, 14)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 17, 22)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 18, 14)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 17, 22)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, +}); + +const res2 = f({ +>res2 : Symbol(res2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 22, 5)) +>f : Symbol(f, Decl(intraExpressionInferencesReverseMappedTypes.ts, 0, 0)) + + a: { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 22, 16)) + + produce: function () { +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 23, 6)) + + return "hello"; + }, + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 26, 6)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 27, 14)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 27, 14)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, + b: { +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 28, 4)) + + produce: function () { +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 29, 6)) + + return { v: "hello" }; +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 31, 14)) + + }, + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 32, 6)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 33, 14)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 31, 14)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 33, 14)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 31, 14)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, +}); + +const res3 = f({ +>res3 : Symbol(res3, Decl(intraExpressionInferencesReverseMappedTypes.ts, 37, 5)) +>f : Symbol(f, Decl(intraExpressionInferencesReverseMappedTypes.ts, 0, 0)) + + a: { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 37, 16)) + + produce() { +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 38, 6)) + + return "hello"; + }, + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 41, 6)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 42, 14)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 42, 14)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, + b: { +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 43, 4)) + + produce() { +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 44, 6)) + + return { v: "hello" }; +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 46, 14)) + + }, + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 47, 6)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 48, 14)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 46, 14)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 48, 14)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 46, 14)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, +}); + +declare function f2( +>f2 : Symbol(f2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 50, 3)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 52, 20)) + + arg: [ +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 52, 41)) + + ...{ + [K in keyof T]: { +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 55, 7)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 52, 20)) + + produce: (n: string) => T[K]; +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 55, 23)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 56, 18)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 52, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 55, 7)) + + consume: (x: T[K]) => void; +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 56, 37)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 57, 18)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 52, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 55, 7)) + + }; + } + ] +): T; +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 52, 20)) + +const res4 = f2([ +>res4 : Symbol(res4, Decl(intraExpressionInferencesReverseMappedTypes.ts, 63, 5)) +>f2 : Symbol(f2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 50, 3)) + { + produce: (n) => n, +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 64, 3)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 65, 14)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 65, 14)) + + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 65, 22)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 66, 14)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 66, 14)) + + }, + { + produce: (n) => ({ v: n }), +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 68, 3)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 69, 14)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 69, 22)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 69, 14)) + + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 69, 31)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 70, 14)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 70, 14)) + + }, +]); + +const res5 = f2([ +>res5 : Symbol(res5, Decl(intraExpressionInferencesReverseMappedTypes.ts, 74, 5)) +>f2 : Symbol(f2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 50, 3)) + { + produce: function () { +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 75, 3)) + + return "hello"; + }, + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 78, 6)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 79, 14)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 79, 14)) + + }, + { + produce: function () { +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 81, 3)) + + return { v: "hello" }; +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 83, 14)) + + }, + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 84, 6)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 85, 14)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 85, 14)) + + }, +]); + +const res6 = f2([ +>res6 : Symbol(res6, Decl(intraExpressionInferencesReverseMappedTypes.ts, 89, 5)) +>f2 : Symbol(f2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 50, 3)) + { + produce() { +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 90, 3)) + + return "hello"; + }, + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 93, 6)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 94, 14)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 94, 14)) + + }, + { + produce() { +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 96, 3)) + + return { v: "hello" }; +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 98, 14)) + + }, + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 99, 6)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 100, 14)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 100, 14)) + + }, +]); + +declare function f3( +>f3 : Symbol(f3, Decl(intraExpressionInferencesReverseMappedTypes.ts, 102, 3)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 104, 20)) + + arg: { +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 104, 23)) + + [K in keyof T]: { +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 106, 5)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 104, 20)) + + other: number, +>other : Symbol(other, Decl(intraExpressionInferencesReverseMappedTypes.ts, 106, 21)) + + produce: (n: string) => T[K]; +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 107, 20)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 108, 16)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 104, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 106, 5)) + + consume: (x: T[K]) => void; +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 108, 35)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 109, 16)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 104, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 106, 5)) + + }; + } +): T; +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 104, 20)) + +const res7 = f3({ +>res7 : Symbol(res7, Decl(intraExpressionInferencesReverseMappedTypes.ts, 114, 5)) +>f3 : Symbol(f3, Decl(intraExpressionInferencesReverseMappedTypes.ts, 102, 3)) + + a: { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 114, 17)) + + other: 42, +>other : Symbol(other, Decl(intraExpressionInferencesReverseMappedTypes.ts, 115, 6)) + + produce: (n) => n, +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 116, 14)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 117, 14)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 117, 14)) + + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 117, 22)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 118, 14)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 118, 14)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, + b: { +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 119, 4)) + + other: 100, +>other : Symbol(other, Decl(intraExpressionInferencesReverseMappedTypes.ts, 120, 6)) + + produce: (n) => ({ v: n }), +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 121, 15)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 122, 14)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 122, 22)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 122, 14)) + + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 122, 31)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 123, 14)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 122, 22)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 123, 14)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 122, 22)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, +}); + +declare function f4( +>f4 : Symbol(f4, Decl(intraExpressionInferencesReverseMappedTypes.ts, 125, 3)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 20)) + + arg: { +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 23)) + + [K in keyof T]: [ +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 129, 5)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 20)) + + (n: string) => T[K], +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 130, 7)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 129, 5)) + + (x: T[K]) => void +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 131, 7)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 129, 5)) + + ]; + } +): T; +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 127, 20)) + +const res8 = f4({ +>res8 : Symbol(res8, Decl(intraExpressionInferencesReverseMappedTypes.ts, 136, 5)) +>f4 : Symbol(f4, Decl(intraExpressionInferencesReverseMappedTypes.ts, 125, 3)) + + a: [ +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 136, 17)) + + (n) => n, +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 138, 5)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 138, 5)) + + (x) => x.toLowerCase(), +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 139, 5)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 139, 5)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + ], + b: [ +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 140, 4)) + + (n) => ({ v: n }), +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 142, 5)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 142, 13)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 142, 5)) + + (x) => x.v.toLowerCase(), +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 143, 5)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 142, 13)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 143, 5)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 142, 13)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + ], +}); + +declare function f5( +>f5 : Symbol(f5, Decl(intraExpressionInferencesReverseMappedTypes.ts, 145, 3)) +>T1 : Symbol(T1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 147, 20)) +>T2 : Symbol(T2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 147, 23)) + + arg: { +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 147, 28)) + + [K in keyof T1]: { +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 149, 5)) +>T1 : Symbol(T1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 147, 20)) + + produce1: (n: string) => T1[K]; +>produce1 : Symbol(produce1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 149, 22)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 150, 17)) +>T1 : Symbol(T1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 147, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 149, 5)) + + consume1: (x: T1[K]) => void; +>consume1 : Symbol(consume1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 150, 37)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 151, 17)) +>T1 : Symbol(T1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 147, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 149, 5)) + + }; + } & { + [K in keyof T2]: { +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 154, 5)) +>T2 : Symbol(T2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 147, 23)) + + produce2: (n: string) => T2[K]; +>produce2 : Symbol(produce2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 154, 22)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 155, 17)) +>T2 : Symbol(T2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 147, 23)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 154, 5)) + + consume2: (x: T2[K]) => void; +>consume2 : Symbol(consume2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 155, 37)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 156, 17)) +>T2 : Symbol(T2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 147, 23)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 154, 5)) + + }; + }, +): [T1, T2]; +>T1 : Symbol(T1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 147, 20)) +>T2 : Symbol(T2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 147, 23)) + +const res9 = f5({ +>res9 : Symbol(res9, Decl(intraExpressionInferencesReverseMappedTypes.ts, 161, 5)) +>f5 : Symbol(f5, Decl(intraExpressionInferencesReverseMappedTypes.ts, 145, 3)) + + a: { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 161, 17)) + + produce1: (n) => n, +>produce1 : Symbol(produce1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 162, 6)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 163, 15)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 163, 15)) + + consume1: (x) => x.toLowerCase(), +>consume1 : Symbol(consume1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 163, 23)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 164, 15)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 164, 15)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + produce2: (n) => [n], +>produce2 : Symbol(produce2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 164, 37)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 165, 15)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 165, 15)) + + consume2: (x) => x[0].toLowerCase(), +>consume2 : Symbol(consume2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 165, 25)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 166, 15)) +>x[0].toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 166, 15)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, + b: { +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 167, 4)) + + produce1: (n) => ({ v: n }), +>produce1 : Symbol(produce1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 168, 6)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 169, 15)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 169, 23)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 169, 15)) + + consume1: (x) => x.v.toLowerCase(), +>consume1 : Symbol(consume1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 169, 32)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 170, 15)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 169, 23)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 170, 15)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 169, 23)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + produce2: (n) => ({ v: [n] }), +>produce2 : Symbol(produce2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 170, 39)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 171, 15)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 171, 23)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 171, 15)) + + consume2: (x) => x.v[0].toLowerCase(), +>consume2 : Symbol(consume2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 171, 34)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 172, 15)) +>x.v[0].toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 171, 23)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 172, 15)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 171, 23)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, +}); + +declare function f6(arg: { +>f6 : Symbol(f6, Decl(intraExpressionInferencesReverseMappedTypes.ts, 174, 3)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 176, 20)) +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 176, 23)) + + [K in keyof T]: () => { +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 177, 3)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 176, 20)) + + produce: (n: string) => T[K]; +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 177, 25)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 178, 14)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 176, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 177, 3)) + + consume: (x: T[K]) => void; +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 178, 33)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 179, 14)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 176, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 177, 3)) + + }; +}): T; +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 176, 20)) + +const res10 = f6({ +>res10 : Symbol(res10, Decl(intraExpressionInferencesReverseMappedTypes.ts, 183, 5)) +>f6 : Symbol(f6, Decl(intraExpressionInferencesReverseMappedTypes.ts, 174, 3)) + + a() { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 183, 18)) + + return { + produce: (n) => n, +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 185, 12)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 186, 16)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 186, 16)) + + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 186, 24)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 187, 16)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 187, 16)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }; + }, + b() { +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 189, 4)) + + return { + produce: (n) => ({ v: n }), +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 191, 12)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 192, 16)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 192, 24)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 192, 16)) + + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 192, 33)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 193, 16)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 192, 24)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 193, 16)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 192, 24)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }; + }, +}); + +const res11 = f6({ +>res11 : Symbol(res11, Decl(intraExpressionInferencesReverseMappedTypes.ts, 198, 5)) +>f6 : Symbol(f6, Decl(intraExpressionInferencesReverseMappedTypes.ts, 174, 3)) + + a: () => { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 198, 18)) + + return { + produce: (n) => n, +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 200, 12)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 201, 16)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 201, 16)) + + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 201, 24)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 202, 16)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 202, 16)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }; + }, + b: () => { +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 204, 4)) + + return { + produce: (n) => ({ v: n }), +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 206, 12)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 207, 16)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 207, 24)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 207, 16)) + + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 207, 33)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 208, 16)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 207, 24)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 208, 16)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 207, 24)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }; + }, +}); + +declare function f7(arg: { +>f7 : Symbol(f7, Decl(intraExpressionInferencesReverseMappedTypes.ts, 211, 3)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 213, 20)) +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 213, 23)) + + [K in keyof T]: (arg: boolean) => { +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 214, 3)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 213, 20)) +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 214, 19)) + + produce: (n: string) => T[K]; +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 214, 37)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 215, 14)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 213, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 214, 3)) + + consume: (x: T[K]) => void; +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 215, 33)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 216, 14)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 213, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 214, 3)) + + }; +}): T; +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 213, 20)) + +const res12 = f7({ +>res12 : Symbol(res12, Decl(intraExpressionInferencesReverseMappedTypes.ts, 220, 5)) +>f7 : Symbol(f7, Decl(intraExpressionInferencesReverseMappedTypes.ts, 211, 3)) + + a(arg) { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 220, 18)) +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 221, 4)) + + return { + produce: (n) => n, +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 222, 12)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 223, 16)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 223, 16)) + + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 223, 24)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 224, 16)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 224, 16)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }; + }, + b(arg) { +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 226, 4)) +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 227, 4)) + + return { + produce: (n) => ({ v: n }), +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 228, 12)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 229, 16)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 229, 24)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 229, 16)) + + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 229, 33)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 230, 16)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 229, 24)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 230, 16)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 229, 24)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }; + }, +}); + +const res13 = f7({ +>res13 : Symbol(res13, Decl(intraExpressionInferencesReverseMappedTypes.ts, 235, 5)) +>f7 : Symbol(f7, Decl(intraExpressionInferencesReverseMappedTypes.ts, 211, 3)) + + a: (arg) => { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 235, 18)) +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 236, 6)) + + return { + produce: (n) => n, +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 237, 12)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 238, 16)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 238, 16)) + + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 238, 24)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 239, 16)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 239, 16)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }; + }, + b: (arg) => { +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 241, 4)) +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 242, 6)) + + return { + produce: (n) => ({ v: n }), +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 243, 12)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 244, 16)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 244, 24)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 244, 16)) + + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 244, 33)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 245, 16)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 244, 24)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 245, 16)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 244, 24)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }; + }, +}); + +declare function f8(arg: { +>f8 : Symbol(f8, Decl(intraExpressionInferencesReverseMappedTypes.ts, 248, 3)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 250, 20)) +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 250, 23)) + + [K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void]; +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 251, 3)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 250, 20)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 251, 26)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 250, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 251, 3)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 251, 47)) +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 250, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 251, 3)) + +}): T; +>T : Symbol(T, Decl(intraExpressionInferencesReverseMappedTypes.ts, 250, 20)) + +const res14 = f8({ +>res14 : Symbol(res14, Decl(intraExpressionInferencesReverseMappedTypes.ts, 254, 5)) +>f8 : Symbol(f8, Decl(intraExpressionInferencesReverseMappedTypes.ts, 248, 3)) + + a() { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 254, 18)) + + return [(n) => n, (x) => x.toLowerCase()]; +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 256, 13)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 256, 13)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 256, 23)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 256, 23)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, + b() { +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 257, 4)) + + return [(n) => ({ v: n }), (x) => x.v.toLowerCase()]; +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 259, 13)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 259, 21)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 259, 13)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 259, 32)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 259, 21)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 259, 32)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 259, 21)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, +}); + +declare function f9( +>f9 : Symbol(f9, Decl(intraExpressionInferencesReverseMappedTypes.ts, 261, 3)) +>T1 : Symbol(T1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 263, 20)) +>T2 : Symbol(T2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 263, 23)) + + arg: { +>arg : Symbol(arg, Decl(intraExpressionInferencesReverseMappedTypes.ts, 263, 28)) + + [K in keyof T1]: { +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 265, 5)) +>T1 : Symbol(T1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 263, 20)) + + produce: (n: string) => [T1[K], any]; +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 265, 22)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 266, 16)) +>T1 : Symbol(T1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 263, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 265, 5)) + + consume: (x: T1[K]) => void; +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 266, 43)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 267, 16)) +>T1 : Symbol(T1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 263, 20)) +>K : Symbol(K, Decl(intraExpressionInferencesReverseMappedTypes.ts, 265, 5)) + + }; + } & { + a: { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 269, 7)) + + produce: (n: string) => [any, T2]; +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 270, 8)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 271, 16)) +>T2 : Symbol(T2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 263, 23)) + + consume2: (x: T2) => void; +>consume2 : Symbol(consume2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 271, 40)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 272, 17)) +>T2 : Symbol(T2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 263, 23)) + + }; + }, +): [T1, T2]; +>T1 : Symbol(T1, Decl(intraExpressionInferencesReverseMappedTypes.ts, 263, 20)) +>T2 : Symbol(T2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 263, 23)) + +const res15 = f9({ +>res15 : Symbol(res15, Decl(intraExpressionInferencesReverseMappedTypes.ts, 277, 5)) +>f9 : Symbol(f9, Decl(intraExpressionInferencesReverseMappedTypes.ts, 261, 3)) + + a: { +>a : Symbol(a, Decl(intraExpressionInferencesReverseMappedTypes.ts, 277, 18)) + + produce: (n) => [n, [n]], +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 278, 6)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 279, 14)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 279, 14)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 279, 14)) + + consume2: (x) => x[0].toLowerCase(), +>consume2 : Symbol(consume2, Decl(intraExpressionInferencesReverseMappedTypes.ts, 279, 29)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 280, 15)) +>x[0].toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 280, 15)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + consume: (x) => x.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 280, 40)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 281, 14)) +>x.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 281, 14)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, + b: { +>b : Symbol(b, Decl(intraExpressionInferencesReverseMappedTypes.ts, 282, 4)) + + produce: (n) => [{ v: n }, null], +>produce : Symbol(produce, Decl(intraExpressionInferencesReverseMappedTypes.ts, 283, 6)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 284, 14)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 284, 22)) +>n : Symbol(n, Decl(intraExpressionInferencesReverseMappedTypes.ts, 284, 14)) + + consume: (x) => x.v.toLowerCase(), +>consume : Symbol(consume, Decl(intraExpressionInferencesReverseMappedTypes.ts, 284, 37)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 285, 14)) +>x.v.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>x.v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 284, 22)) +>x : Symbol(x, Decl(intraExpressionInferencesReverseMappedTypes.ts, 285, 14)) +>v : Symbol(v, Decl(intraExpressionInferencesReverseMappedTypes.ts, 284, 22)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) + + }, +}); + diff --git a/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.types b/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.types new file mode 100644 index 0000000000000..b2546e4060007 --- /dev/null +++ b/tests/baselines/reference/intraExpressionInferencesReverseMappedTypes.types @@ -0,0 +1,1683 @@ +//// [tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesReverseMappedTypes.ts] //// + +=== Performance Stats === +Type Count: 1,000 + +=== intraExpressionInferencesReverseMappedTypes.ts === +// repro cases based on https://github.com/microsoft/TypeScript/issues/53018 + +declare function f( +>f : (arg: { [K in keyof T]: { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ + + arg: { +>arg : { [K in keyof T]: { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^ + + [K in keyof T]: { + produce: (n: string) => T[K]; +>produce : (n: string) => T[K] +> : ^ ^^ ^^^^^ +>n : string +> : ^^^^^^ + + consume: (x: T[K]) => void; +>consume : (x: T[K]) => void +> : ^ ^^ ^^^^^ +>x : T[K] +> : ^^^^ + + }; + } +): T; + +const res1 = f({ +>res1 : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f({ a: { produce: (n) => n, consume: (x) => x.toLowerCase(), }, b: { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), },}) : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f : (arg: { [K in keyof T]: { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a: { produce: (n) => n, consume: (x) => x.toLowerCase(), }, b: { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), },} : { a: { produce: (n: string) => string; consume: (x: string) => string; }; b: { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; }; } +> : ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a: { +>a : { produce: (n: string) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>{ produce: (n) => n, consume: (x) => x.toLowerCase(), } : { produce: (n: string) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => n, +>produce : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(n) => n : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.toLowerCase(), +>consume : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, + b: { +>b : { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), } : { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => ({ v: n }), +>produce : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => ({ v: n }) : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>({ v: n }) : { v: string; } +> : ^^^^^^^^^^^^^^ +>{ v: n } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.v.toLowerCase(), +>consume : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, +}); + +const res2 = f({ +>res2 : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f({ a: { produce: function () { return "hello"; }, consume: (x) => x.toLowerCase(), }, b: { produce: function () { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), },}) : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f : (arg: { [K in keyof T]: { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a: { produce: function () { return "hello"; }, consume: (x) => x.toLowerCase(), }, b: { produce: function () { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), },} : { a: { produce: () => string; consume: (x: string) => string; }; b: { produce: () => { v: string; }; consume: (x: { v: string; }) => string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a: { +>a : { produce: () => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>{ produce: function () { return "hello"; }, consume: (x) => x.toLowerCase(), } : { produce: () => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + produce: function () { +>produce : () => string +> : ^^^^^^^^^^^^ +>function () { return "hello"; } : () => string +> : ^^^^^^^^^^^^ + + return "hello"; +>"hello" : "hello" +> : ^^^^^^^ + + }, + consume: (x) => x.toLowerCase(), +>consume : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, + b: { +>b : { produce: () => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ produce: function () { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), } : { produce: () => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + produce: function () { +>produce : () => { v: string; } +> : ^^^^^^^^^^^^^^^^^^^^ +>function () { return { v: "hello" }; } : () => { v: string; } +> : ^^^^^^^^^^^^^^^^^^^^ + + return { v: "hello" }; +>{ v: "hello" } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>"hello" : "hello" +> : ^^^^^^^ + + }, + consume: (x) => x.v.toLowerCase(), +>consume : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, +}); + +const res3 = f({ +>res3 : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f({ a: { produce() { return "hello"; }, consume: (x) => x.toLowerCase(), }, b: { produce() { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), },}) : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f : (arg: { [K in keyof T]: { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a: { produce() { return "hello"; }, consume: (x) => x.toLowerCase(), }, b: { produce() { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), },} : { a: { produce(): string; consume: (x: string) => string; }; b: { produce(): { v: string; }; consume: (x: { v: string; }) => string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a: { +>a : { produce(): string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>{ produce() { return "hello"; }, consume: (x) => x.toLowerCase(), } : { produce(): string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + produce() { +>produce : () => string +> : ^^^^^^^^^^^^ + + return "hello"; +>"hello" : "hello" +> : ^^^^^^^ + + }, + consume: (x) => x.toLowerCase(), +>consume : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, + b: { +>b : { produce(): { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ produce() { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), } : { produce(): { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + produce() { +>produce : () => { v: string; } +> : ^^^^^^^^^^^^^^^^^^^^ + + return { v: "hello" }; +>{ v: "hello" } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>"hello" : "hello" +> : ^^^^^^^ + + }, + consume: (x) => x.v.toLowerCase(), +>consume : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, +}); + +declare function f2( +>f2 : (arg: [...{ [K in keyof T]: { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }]) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ + + arg: [ +>arg : [...{ [K in keyof T]: { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }] +> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^ + + ...{ + [K in keyof T]: { + produce: (n: string) => T[K]; +>produce : (n: string) => T[K] +> : ^ ^^ ^^^^^ +>n : string +> : ^^^^^^ + + consume: (x: T[K]) => void; +>consume : (x: T[K]) => void +> : ^ ^^ ^^^^^ +>x : T[K] +> : ^^^^ + + }; + } + ] +): T; + +const res4 = f2([ +>res4 : [string, { v: string; }] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>f2([ { produce: (n) => n, consume: (x) => x.toLowerCase(), }, { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), },]) : [string, { v: string; }] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>f2 : (arg: [...{ [K in keyof T]: { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }]) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ { produce: (n) => n, consume: (x) => x.toLowerCase(), }, { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), },] : [{ produce: (n: string) => string; consume: (x: unknown) => any; }, { produce: (n: string) => { v: string; }; consume: (x: unknown) => any; }] +> : ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ + { +>{ produce: (n) => n, consume: (x) => x.toLowerCase(), } : { produce: (n: string) => string; consume: (x: unknown) => any; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => n, +>produce : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(n) => n : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.toLowerCase(), +>consume : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>x : unknown +> : ^^^^^^^ +>x.toLowerCase() : any +> : ^^^ +>x.toLowerCase : any +> : ^^^ +>x : unknown +> : ^^^^^^^ +>toLowerCase : any +> : ^^^ + + }, + { +>{ produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), } : { produce: (n: string) => { v: string; }; consume: (x: unknown) => any; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => ({ v: n }), +>produce : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => ({ v: n }) : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>({ v: n }) : { v: string; } +> : ^^^^^^^^^^^^^^ +>{ v: n } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.v.toLowerCase(), +>consume : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>x : unknown +> : ^^^^^^^ +>x.v.toLowerCase() : any +> : ^^^ +>x.v.toLowerCase : any +> : ^^^ +>x.v : any +> : ^^^ +>x : unknown +> : ^^^^^^^ +>v : any +> : ^^^ +>toLowerCase : any +> : ^^^ + + }, +]); + +const res5 = f2([ +>res5 : [string, { v: string; }] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>f2([ { produce: function () { return "hello"; }, consume: (x) => x.toLowerCase(), }, { produce: function () { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), },]) : [string, { v: string; }] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>f2 : (arg: [...{ [K in keyof T]: { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }]) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ { produce: function () { return "hello"; }, consume: (x) => x.toLowerCase(), }, { produce: function () { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), },] : [{ produce: () => string; consume: (x: unknown) => any; }, { produce: () => { v: string; }; consume: (x: unknown) => any; }] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ + { +>{ produce: function () { return "hello"; }, consume: (x) => x.toLowerCase(), } : { produce: () => string; consume: (x: unknown) => any; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ + + produce: function () { +>produce : () => string +> : ^^^^^^^^^^^^ +>function () { return "hello"; } : () => string +> : ^^^^^^^^^^^^ + + return "hello"; +>"hello" : "hello" +> : ^^^^^^^ + + }, + consume: (x) => x.toLowerCase(), +>consume : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>x : unknown +> : ^^^^^^^ +>x.toLowerCase() : any +> : ^^^ +>x.toLowerCase : any +> : ^^^ +>x : unknown +> : ^^^^^^^ +>toLowerCase : any +> : ^^^ + + }, + { +>{ produce: function () { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), } : { produce: () => { v: string; }; consume: (x: unknown) => any; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ + + produce: function () { +>produce : () => { v: string; } +> : ^^^^^^^^^^^^^^^^^^^^ +>function () { return { v: "hello" }; } : () => { v: string; } +> : ^^^^^^^^^^^^^^^^^^^^ + + return { v: "hello" }; +>{ v: "hello" } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>"hello" : "hello" +> : ^^^^^^^ + + }, + consume: (x) => x.v.toLowerCase(), +>consume : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>x : unknown +> : ^^^^^^^ +>x.v.toLowerCase() : any +> : ^^^ +>x.v.toLowerCase : any +> : ^^^ +>x.v : any +> : ^^^ +>x : unknown +> : ^^^^^^^ +>v : any +> : ^^^ +>toLowerCase : any +> : ^^^ + + }, +]); + +const res6 = f2([ +>res6 : [string, { v: string; }] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>f2([ { produce() { return "hello"; }, consume: (x) => x.toLowerCase(), }, { produce() { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), },]) : [string, { v: string; }] +> : ^^^^^^^^^^^^^^^^^^^^^^^^ +>f2 : (arg: [...{ [K in keyof T]: { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }]) => T +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>[ { produce() { return "hello"; }, consume: (x) => x.toLowerCase(), }, { produce() { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), },] : [{ produce(): string; consume: (x: unknown) => any; }, { produce(): { v: string; }; consume: (x: unknown) => any; }] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ + { +>{ produce() { return "hello"; }, consume: (x) => x.toLowerCase(), } : { produce(): string; consume: (x: unknown) => any; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ + + produce() { +>produce : () => string +> : ^^^^^^^^^^^^ + + return "hello"; +>"hello" : "hello" +> : ^^^^^^^ + + }, + consume: (x) => x.toLowerCase(), +>consume : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>x : unknown +> : ^^^^^^^ +>x.toLowerCase() : any +> : ^^^ +>x.toLowerCase : any +> : ^^^ +>x : unknown +> : ^^^^^^^ +>toLowerCase : any +> : ^^^ + + }, + { +>{ produce() { return { v: "hello" }; }, consume: (x) => x.v.toLowerCase(), } : { produce(): { v: string; }; consume: (x: unknown) => any; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ + + produce() { +>produce : () => { v: string; } +> : ^^^^^^^^^^^^^^^^^^^^ + + return { v: "hello" }; +>{ v: "hello" } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>"hello" : "hello" +> : ^^^^^^^ + + }, + consume: (x) => x.v.toLowerCase(), +>consume : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: unknown) => any +> : ^ ^^^^^^^^^^^^^^^^^ +>x : unknown +> : ^^^^^^^ +>x.v.toLowerCase() : any +> : ^^^ +>x.v.toLowerCase : any +> : ^^^ +>x.v : any +> : ^^^ +>x : unknown +> : ^^^^^^^ +>v : any +> : ^^^ +>toLowerCase : any +> : ^^^ + + }, +]); + +declare function f3( +>f3 : (arg: { [K in keyof T]: { other: number; produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ + + arg: { +>arg : { [K in keyof T]: { other: number; produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^ + + [K in keyof T]: { + other: number, +>other : number +> : ^^^^^^ + + produce: (n: string) => T[K]; +>produce : (n: string) => T[K] +> : ^ ^^ ^^^^^ +>n : string +> : ^^^^^^ + + consume: (x: T[K]) => void; +>consume : (x: T[K]) => void +> : ^ ^^ ^^^^^ +>x : T[K] +> : ^^^^ + + }; + } +): T; + +const res7 = f3({ +>res7 : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f3({ a: { other: 42, produce: (n) => n, consume: (x) => x.toLowerCase(), }, b: { other: 100, produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), },}) : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f3 : (arg: { [K in keyof T]: { other: number; produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a: { other: 42, produce: (n) => n, consume: (x) => x.toLowerCase(), }, b: { other: 100, produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), },} : { a: { other: number; produce: (n: string) => string; consume: (x: string) => string; }; b: { other: number; produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a: { +>a : { other: number; produce: (n: string) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>{ other: 42, produce: (n) => n, consume: (x) => x.toLowerCase(), } : { other: number; produce: (n: string) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + other: 42, +>other : number +> : ^^^^^^ +>42 : 42 +> : ^^ + + produce: (n) => n, +>produce : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(n) => n : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.toLowerCase(), +>consume : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, + b: { +>b : { other: number; produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ other: 100, produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), } : { other: number; produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + other: 100, +>other : number +> : ^^^^^^ +>100 : 100 +> : ^^^ + + produce: (n) => ({ v: n }), +>produce : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => ({ v: n }) : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>({ v: n }) : { v: string; } +> : ^^^^^^^^^^^^^^ +>{ v: n } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.v.toLowerCase(), +>consume : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, +}); + +declare function f4( +>f4 : (arg: { [K in keyof T]: [(n: string) => T[K], (x: T[K]) => void]; }) => T +> : ^ ^^ ^^ ^^^^^ + + arg: { +>arg : { [K in keyof T]: [(n: string) => T[K], (x: T[K]) => void]; } +> : ^^^ ^^^^^^^^^^^^^^^^ ^^ ^^^^^ ^^^ ^^ ^^^^^ ^^^^ + + [K in keyof T]: [ + (n: string) => T[K], +>n : string +> : ^^^^^^ + + (x: T[K]) => void +>x : T[K] +> : ^^^^ + + ]; + } +): T; + +const res8 = f4({ +>res8 : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f4({ a: [ (n) => n, (x) => x.toLowerCase(), ], b: [ (n) => ({ v: n }), (x) => x.v.toLowerCase(), ],}) : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f4 : (arg: { [K in keyof T]: [(n: string) => T[K], (x: T[K]) => void]; }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a: [ (n) => n, (x) => x.toLowerCase(), ], b: [ (n) => ({ v: n }), (x) => x.v.toLowerCase(), ],} : { a: [(n: string) => string, (x: string) => string]; b: [(n: string) => { v: string; }, (x: { v: string; }) => string]; } +> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a: [ +>a : [(n: string) => string, (x: string) => string] +> : ^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ +>[ (n) => n, (x) => x.toLowerCase(), ] : [(n: string) => string, (x: string) => string] +> : ^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ + + (n) => n, +>(n) => n : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + (x) => x.toLowerCase(), +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + ], + b: [ +>b : [(n: string) => { v: string; }, (x: { v: string; }) => string] +> : ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>[ (n) => ({ v: n }), (x) => x.v.toLowerCase(), ] : [(n: string) => { v: string; }, (x: { v: string; }) => string] +> : ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + (n) => ({ v: n }), +>(n) => ({ v: n }) : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>({ v: n }) : { v: string; } +> : ^^^^^^^^^^^^^^ +>{ v: n } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + (x) => x.v.toLowerCase(), +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + ], +}); + +declare function f5( +>f5 : (arg: { [K in keyof T1]: { produce1: (n: string) => T1[K]; consume1: (x: T1[K]) => void; }; } & { [K in keyof T2]: { produce2: (n: string) => T2[K]; consume2: (x: T2[K]) => void; }; }) => [T1, T2] +> : ^ ^^ ^^ ^^ ^^^^^ + + arg: { +>arg : { [K in keyof T1]: { produce1: (n: string) => T1[K]; consume1: (x: T1[K]) => void; }; } & { [K_1 in keyof T2]: { produce2: (n: string) => T2[K_1]; consume2: (x: T2[K_1]) => void; }; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^ + + [K in keyof T1]: { + produce1: (n: string) => T1[K]; +>produce1 : (n: string) => T1[K] +> : ^ ^^ ^^^^^ +>n : string +> : ^^^^^^ + + consume1: (x: T1[K]) => void; +>consume1 : (x: T1[K]) => void +> : ^ ^^ ^^^^^ +>x : T1[K] +> : ^^^^^ + + }; + } & { + [K in keyof T2]: { + produce2: (n: string) => T2[K]; +>produce2 : (n: string) => T2[K] +> : ^ ^^ ^^^^^ +>n : string +> : ^^^^^^ + + consume2: (x: T2[K]) => void; +>consume2 : (x: T2[K]) => void +> : ^ ^^ ^^^^^ +>x : T2[K] +> : ^^^^^ + + }; + }, +): [T1, T2]; + +const res9 = f5({ +>res9 : [{ a: string; b: { v: string; }; }, { a: string[]; b: { v: string[]; }; }] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f5({ a: { produce1: (n) => n, consume1: (x) => x.toLowerCase(), produce2: (n) => [n], consume2: (x) => x[0].toLowerCase(), }, b: { produce1: (n) => ({ v: n }), consume1: (x) => x.v.toLowerCase(), produce2: (n) => ({ v: [n] }), consume2: (x) => x.v[0].toLowerCase(), },}) : [{ a: string; b: { v: string; }; }, { a: string[]; b: { v: string[]; }; }] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f5 : (arg: { [K in keyof T1]: { produce1: (n: string) => T1[K]; consume1: (x: T1[K]) => void; }; } & { [K in keyof T2]: { produce2: (n: string) => T2[K]; consume2: (x: T2[K]) => void; }; }) => [T1, T2] +> : ^ ^^ ^^ ^^ ^^^^^ +>{ a: { produce1: (n) => n, consume1: (x) => x.toLowerCase(), produce2: (n) => [n], consume2: (x) => x[0].toLowerCase(), }, b: { produce1: (n) => ({ v: n }), consume1: (x) => x.v.toLowerCase(), produce2: (n) => ({ v: [n] }), consume2: (x) => x.v[0].toLowerCase(), },} : { a: { produce1: (n: string) => string; consume1: (x: string) => string; produce2: (n: string) => string[]; consume2: (x: string[]) => string; }; b: { produce1: (n: string) => { v: string; }; consume1: (x: { v: string; }) => string; produce2: (n: string) => { v: string[]; }; consume2: (x: { v: string[]; }) => string; }; } +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a: { +>a : { produce1: (n: string) => string; consume1: (x: string) => string; produce2: (n: string) => string[]; consume2: (x: string[]) => string; } +> : ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>{ produce1: (n) => n, consume1: (x) => x.toLowerCase(), produce2: (n) => [n], consume2: (x) => x[0].toLowerCase(), } : { produce1: (n: string) => string; consume1: (x: string) => string; produce2: (n: string) => string[]; consume2: (x: string[]) => string; } +> : ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ + + produce1: (n) => n, +>produce1 : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(n) => n : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume1: (x) => x.toLowerCase(), +>consume1 : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + produce2: (n) => [n], +>produce2 : (n: string) => string[] +> : ^ ^^^^^^^^^^^^^^^^^^^^^ +>(n) => [n] : (n: string) => string[] +> : ^ ^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>[n] : string[] +> : ^^^^^^^^ +>n : string +> : ^^^^^^ + + consume2: (x) => x[0].toLowerCase(), +>consume2 : (x: string[]) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^ +>(x) => x[0].toLowerCase() : (x: string[]) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^ +>x : string[] +> : ^^^^^^^^ +>x[0].toLowerCase() : string +> : ^^^^^^ +>x[0].toLowerCase : () => string +> : ^^^^^^ +>x[0] : string +> : ^^^^^^ +>x : string[] +> : ^^^^^^^^ +>0 : 0 +> : ^ +>toLowerCase : () => string +> : ^^^^^^ + + }, + b: { +>b : { produce1: (n: string) => { v: string; }; consume1: (x: { v: string; }) => string; produce2: (n: string) => { v: string[]; }; consume2: (x: { v: string[]; }) => string; } +> : ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ produce1: (n) => ({ v: n }), consume1: (x) => x.v.toLowerCase(), produce2: (n) => ({ v: [n] }), consume2: (x) => x.v[0].toLowerCase(), } : { produce1: (n: string) => { v: string; }; consume1: (x: { v: string; }) => string; produce2: (n: string) => { v: string[]; }; consume2: (x: { v: string[]; }) => string; } +> : ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + produce1: (n) => ({ v: n }), +>produce1 : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => ({ v: n }) : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>({ v: n }) : { v: string; } +> : ^^^^^^^^^^^^^^ +>{ v: n } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume1: (x) => x.v.toLowerCase(), +>consume1 : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + produce2: (n) => ({ v: [n] }), +>produce2 : (n: string) => { v: string[]; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => ({ v: [n] }) : (n: string) => { v: string[]; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>({ v: [n] }) : { v: string[]; } +> : ^^^^^^^^^^^^^^^^ +>{ v: [n] } : { v: string[]; } +> : ^^^^^^^^^^^^^^^^ +>v : string[] +> : ^^^^^^^^ +>[n] : string[] +> : ^^^^^^^^ +>n : string +> : ^^^^^^ + + consume2: (x) => x.v[0].toLowerCase(), +>consume2 : (x: { v: string[]; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(x) => x.v[0].toLowerCase() : (x: { v: string[]; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string[]; } +> : ^^^^^^^^^^^^^^^^ +>x.v[0].toLowerCase() : string +> : ^^^^^^ +>x.v[0].toLowerCase : () => string +> : ^^^^^^ +>x.v[0] : string +> : ^^^^^^ +>x.v : string[] +> : ^^^^^^^^ +>x : { v: string[]; } +> : ^^^^^^^^^^^^^^^^ +>v : string[] +> : ^^^^^^^^ +>0 : 0 +> : ^ +>toLowerCase : () => string +> : ^^^^^^ + + }, +}); + +declare function f6(arg: { +>f6 : (arg: { [K in keyof T]: () => { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ +>arg : { [K in keyof T]: () => { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^ + + [K in keyof T]: () => { + produce: (n: string) => T[K]; +>produce : (n: string) => T[K] +> : ^ ^^ ^^^^^ +>n : string +> : ^^^^^^ + + consume: (x: T[K]) => void; +>consume : (x: T[K]) => void +> : ^ ^^ ^^^^^ +>x : T[K] +> : ^^^^ + + }; +}): T; + +const res10 = f6({ +>res10 : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f6({ a() { return { produce: (n) => n, consume: (x) => x.toLowerCase(), }; }, b() { return { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), }; },}) : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f6 : (arg: { [K in keyof T]: () => { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a() { return { produce: (n) => n, consume: (x) => x.toLowerCase(), }; }, b() { return { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), }; },} : { a(): { produce: (n: string) => string; consume: (x: string) => string; }; b(): { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; }; } +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a() { +>a : () => { produce: (n: string) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + return { +>{ produce: (n) => n, consume: (x) => x.toLowerCase(), } : { produce: (n: string) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => n, +>produce : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(n) => n : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.toLowerCase(), +>consume : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }; + }, + b() { +>b : () => { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + return { +>{ produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), } : { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => ({ v: n }), +>produce : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => ({ v: n }) : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>({ v: n }) : { v: string; } +> : ^^^^^^^^^^^^^^ +>{ v: n } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.v.toLowerCase(), +>consume : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }; + }, +}); + +const res11 = f6({ +>res11 : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f6({ a: () => { return { produce: (n) => n, consume: (x) => x.toLowerCase(), }; }, b: () => { return { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), }; },}) : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f6 : (arg: { [K in keyof T]: () => { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a: () => { return { produce: (n) => n, consume: (x) => x.toLowerCase(), }; }, b: () => { return { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), }; },} : { a: () => { produce: (n: string) => string; consume: (x: string) => string; }; b: () => { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a: () => { +>a : () => { produce: (n: string) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>() => { return { produce: (n) => n, consume: (x) => x.toLowerCase(), }; } : () => { produce: (n: string) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + return { +>{ produce: (n) => n, consume: (x) => x.toLowerCase(), } : { produce: (n: string) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => n, +>produce : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(n) => n : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.toLowerCase(), +>consume : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }; + }, + b: () => { +>b : () => { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>() => { return { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), }; } : () => { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + return { +>{ produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), } : { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => ({ v: n }), +>produce : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => ({ v: n }) : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>({ v: n }) : { v: string; } +> : ^^^^^^^^^^^^^^ +>{ v: n } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.v.toLowerCase(), +>consume : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }; + }, +}); + +declare function f7(arg: { +>f7 : (arg: { [K in keyof T]: (arg: boolean) => { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ +>arg : { [K in keyof T]: (arg: boolean) => { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; } +> : ^^^ ^^^^^^^^^^^^^^^ ^^ ^^^^^ ^^^ + + [K in keyof T]: (arg: boolean) => { +>arg : boolean +> : ^^^^^^^ + + produce: (n: string) => T[K]; +>produce : (n: string) => T[K] +> : ^ ^^ ^^^^^ +>n : string +> : ^^^^^^ + + consume: (x: T[K]) => void; +>consume : (x: T[K]) => void +> : ^ ^^ ^^^^^ +>x : T[K] +> : ^^^^ + + }; +}): T; + +const res12 = f7({ +>res12 : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f7({ a(arg) { return { produce: (n) => n, consume: (x) => x.toLowerCase(), }; }, b(arg) { return { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), }; },}) : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f7 : (arg: { [K in keyof T]: (arg: boolean) => { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a(arg) { return { produce: (n) => n, consume: (x) => x.toLowerCase(), }; }, b(arg) { return { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), }; },} : { a(arg: boolean): { produce: (n: string) => string; consume: (x: string) => string; }; b(arg: boolean): { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; }; } +> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a(arg) { +>a : (arg: boolean) => { produce: (n: string) => string; consume: (x: string) => string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>arg : boolean +> : ^^^^^^^ + + return { +>{ produce: (n) => n, consume: (x) => x.toLowerCase(), } : { produce: (n: string) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => n, +>produce : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(n) => n : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.toLowerCase(), +>consume : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }; + }, + b(arg) { +>b : (arg: boolean) => { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>arg : boolean +> : ^^^^^^^ + + return { +>{ produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), } : { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => ({ v: n }), +>produce : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => ({ v: n }) : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>({ v: n }) : { v: string; } +> : ^^^^^^^^^^^^^^ +>{ v: n } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.v.toLowerCase(), +>consume : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }; + }, +}); + +const res13 = f7({ +>res13 : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f7({ a: (arg) => { return { produce: (n) => n, consume: (x) => x.toLowerCase(), }; }, b: (arg) => { return { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), }; },}) : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f7 : (arg: { [K in keyof T]: (arg: boolean) => { produce: (n: string) => T[K]; consume: (x: T[K]) => void; }; }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a: (arg) => { return { produce: (n) => n, consume: (x) => x.toLowerCase(), }; }, b: (arg) => { return { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), }; },} : { a: (arg: boolean) => { produce: (n: string) => string; consume: (x: string) => string; }; b: (arg: boolean) => { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; }; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a: (arg) => { +>a : (arg: boolean) => { produce: (n: string) => string; consume: (x: string) => string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>(arg) => { return { produce: (n) => n, consume: (x) => x.toLowerCase(), }; } : (arg: boolean) => { produce: (n: string) => string; consume: (x: string) => string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>arg : boolean +> : ^^^^^^^ + + return { +>{ produce: (n) => n, consume: (x) => x.toLowerCase(), } : { produce: (n: string) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => n, +>produce : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(n) => n : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.toLowerCase(), +>consume : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }; + }, + b: (arg) => { +>b : (arg: boolean) => { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(arg) => { return { produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), }; } : (arg: boolean) => { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>arg : boolean +> : ^^^^^^^ + + return { +>{ produce: (n) => ({ v: n }), consume: (x) => x.v.toLowerCase(), } : { produce: (n: string) => { v: string; }; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => ({ v: n }), +>produce : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => ({ v: n }) : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>({ v: n }) : { v: string; } +> : ^^^^^^^^^^^^^^ +>{ v: n } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.v.toLowerCase(), +>consume : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }; + }, +}); + +declare function f8(arg: { +>f8 : (arg: { [K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void]; }) => T +> : ^ ^^ ^^ ^^^^^ +>arg : { [K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void]; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^ + + [K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void]; +>n : string +> : ^^^^^^ +>x : T[K] +> : ^^^^ + +}): T; + +const res14 = f8({ +>res14 : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f8({ a() { return [(n) => n, (x) => x.toLowerCase()]; }, b() { return [(n) => ({ v: n }), (x) => x.v.toLowerCase()]; },}) : { a: string; b: { v: string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f8 : (arg: { [K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void]; }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a() { return [(n) => n, (x) => x.toLowerCase()]; }, b() { return [(n) => ({ v: n }), (x) => x.v.toLowerCase()]; },} : { a(): [(n: string) => string, (x: string) => string]; b(): [(n: string) => { v: string; }, (x: { v: string; }) => string]; } +> : ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a() { +>a : () => [(n: string) => string, (x: string) => string] +> : ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ + + return [(n) => n, (x) => x.toLowerCase()]; +>[(n) => n, (x) => x.toLowerCase()] : [(n: string) => string, (x: string) => string] +> : ^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ +>(n) => n : (n: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>n : string +> : ^^^^^^ +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, + b() { +>b : () => [(n: string) => { v: string; }, (x: { v: string; }) => string] +> : ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + return [(n) => ({ v: n }), (x) => x.v.toLowerCase()]; +>[(n) => ({ v: n }), (x) => x.v.toLowerCase()] : [(n: string) => { v: string; }, (x: { v: string; }) => string] +> : ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => ({ v: n }) : (n: string) => { v: string; } +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>({ v: n }) : { v: string; } +> : ^^^^^^^^^^^^^^ +>{ v: n } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>n : string +> : ^^^^^^ +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, +}); + +declare function f9( +>f9 : (arg: { [K in keyof T1]: { produce: (n: string) => [T1[K], any]; consume: (x: T1[K]) => void; }; } & { a: { produce: (n: string) => [any, T2]; consume2: (x: T2) => void; }; }) => [T1, T2] +> : ^ ^^ ^^ ^^ ^^^^^ + + arg: { +>arg : { [K in keyof T1]: { produce: (n: string) => [T1[K], any]; consume: (x: T1[K]) => void; }; } & { a: { produce: (n: string) => [any, T2]; consume2: (x: T2) => void; }; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^ ^^^ + + [K in keyof T1]: { + produce: (n: string) => [T1[K], any]; +>produce : (n: string) => [T1[K], any] +> : ^ ^^ ^^^^^ +>n : string +> : ^^^^^^ + + consume: (x: T1[K]) => void; +>consume : (x: T1[K]) => void +> : ^ ^^ ^^^^^ +>x : T1[K] +> : ^^^^^ + + }; + } & { + a: { +>a : { produce: (n: string) => [any, T2]; consume2: (x: T2) => void; } +> : ^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^ + + produce: (n: string) => [any, T2]; +>produce : (n: string) => [any, T2] +> : ^ ^^ ^^^^^ +>n : string +> : ^^^^^^ + + consume2: (x: T2) => void; +>consume2 : (x: T2) => void +> : ^ ^^ ^^^^^ +>x : T2 +> : ^^ + + }; + }, +): [T1, T2]; + +const res15 = f9({ +>res15 : [{ a: string; b: { v: string; }; }, string[]] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f9({ a: { produce: (n) => [n, [n]], consume2: (x) => x[0].toLowerCase(), consume: (x) => x.toLowerCase(), }, b: { produce: (n) => [{ v: n }, null], consume: (x) => x.v.toLowerCase(), },}) : [{ a: string; b: { v: string; }; }, string[]] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f9 : (arg: { [K in keyof T1]: { produce: (n: string) => [T1[K], any]; consume: (x: T1[K]) => void; }; } & { a: { produce: (n: string) => [any, T2]; consume2: (x: T2) => void; }; }) => [T1, T2] +> : ^ ^^ ^^ ^^ ^^^^^ +>{ a: { produce: (n) => [n, [n]], consume2: (x) => x[0].toLowerCase(), consume: (x) => x.toLowerCase(), }, b: { produce: (n) => [{ v: n }, null], consume: (x) => x.v.toLowerCase(), },} : { a: { produce: (n: string) => [string, string[]]; consume2: (x: string[]) => string; consume: (x: string) => string; }; b: { produce: (n: string) => [{ v: string; }, null]; consume: (x: { v: string; }) => string; }; } +> : ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + a: { +>a : { produce: (n: string) => [string, string[]]; consume2: (x: string[]) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ +>{ produce: (n) => [n, [n]], consume2: (x) => x[0].toLowerCase(), consume: (x) => x.toLowerCase(), } : { produce: (n: string) => [string, string[]]; consume2: (x: string[]) => string; consume: (x: string) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => [n, [n]], +>produce : (n: string) => [string, string[]] +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => [n, [n]] : (n: string) => [string, string[]] +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>[n, [n]] : [string, string[]] +> : ^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>[n] : string[] +> : ^^^^^^^^ +>n : string +> : ^^^^^^ + + consume2: (x) => x[0].toLowerCase(), +>consume2 : (x: string[]) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^ +>(x) => x[0].toLowerCase() : (x: string[]) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^ +>x : string[] +> : ^^^^^^^^ +>x[0].toLowerCase() : string +> : ^^^^^^ +>x[0].toLowerCase : () => string +> : ^^^^^^ +>x[0] : string +> : ^^^^^^ +>x : string[] +> : ^^^^^^^^ +>0 : 0 +> : ^ +>toLowerCase : () => string +> : ^^^^^^ + + consume: (x) => x.toLowerCase(), +>consume : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(x) => x.toLowerCase() : (x: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : string +> : ^^^^^^ +>x.toLowerCase() : string +> : ^^^^^^ +>x.toLowerCase : () => string +> : ^^^^^^ +>x : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, + b: { +>b : { produce: (n: string) => [{ v: string; }, null]; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ produce: (n) => [{ v: n }, null], consume: (x) => x.v.toLowerCase(), } : { produce: (n: string) => [{ v: string; }, null]; consume: (x: { v: string; }) => string; } +> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + produce: (n) => [{ v: n }, null], +>produce : (n: string) => [{ v: string; }, null] +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(n) => [{ v: n }, null] : (n: string) => [{ v: string; }, null] +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>n : string +> : ^^^^^^ +>[{ v: n }, null] : [{ v: string; }, null] +> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ v: n } : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>n : string +> : ^^^^^^ + + consume: (x) => x.v.toLowerCase(), +>consume : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(x) => x.v.toLowerCase() : (x: { v: string; }) => string +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>x.v.toLowerCase() : string +> : ^^^^^^ +>x.v.toLowerCase : () => string +> : ^^^^^^ +>x.v : string +> : ^^^^^^ +>x : { v: string; } +> : ^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>toLowerCase : () => string +> : ^^^^^^ + + }, +}); + diff --git a/tests/baselines/reference/reverseMappedInferenceWithCircularConstraint.errors.txt b/tests/baselines/reference/reverseMappedInferenceWithCircularConstraint.errors.txt new file mode 100644 index 0000000000000..f21f939cb384e --- /dev/null +++ b/tests/baselines/reference/reverseMappedInferenceWithCircularConstraint.errors.txt @@ -0,0 +1,65 @@ +reverseMappedInferenceWithCircularConstraint.ts(47,3): error TS2322: Type '"unknown"' is not assignable to type '"pending"'. + + +==== reverseMappedInferenceWithCircularConstraint.ts (1 errors) ==== + // repro from https://github.com/microsoft/TypeScript/issues/48798 + + type AnyFunction = (...args: any[]) => any; + + type InferNarrowest = T extends any + ? T extends AnyFunction + ? T + : T extends object + ? InferNarrowestObject + : T + : never; + + type InferNarrowestObject = { + readonly [K in keyof T]: InferNarrowest; + }; + + type Config> = { + states: { + [StateKey in keyof TState]: { + on?: {}; + }; + }; + } & { + initial: keyof TState; + }; + + type Prop = K extends keyof T ? T[K] : never; + + const createMachine = >( + _config: InferNarrowestObject + ): void => {}; + + createMachine({ + initial: "pending", + states: { + pending: { + on: { + done() { + return "noData"; + }, + }, + }, + }, + }); + + createMachine({ + initial: "unknown", // error + ~~~~~~~ +!!! error TS2322: Type '"unknown"' is not assignable to type '"pending"'. +!!! related TS6500 reverseMappedInferenceWithCircularConstraint.ts:24:3: The expected type comes from property 'initial' which is declared here on type 'InferNarrowestObject>' + states: { + pending: { + on: { + done() { + return "noData"; + }, + }, + }, + }, + }); + \ No newline at end of file diff --git a/tests/baselines/reference/reverseMappedInferenceWithCircularConstraint.symbols b/tests/baselines/reference/reverseMappedInferenceWithCircularConstraint.symbols new file mode 100644 index 0000000000000..3a8476afdc0b2 --- /dev/null +++ b/tests/baselines/reference/reverseMappedInferenceWithCircularConstraint.symbols @@ -0,0 +1,144 @@ +//// [tests/cases/compiler/reverseMappedInferenceWithCircularConstraint.ts] //// + +=== reverseMappedInferenceWithCircularConstraint.ts === +// repro from https://github.com/microsoft/TypeScript/issues/48798 + +type AnyFunction = (...args: any[]) => any; +>AnyFunction : Symbol(AnyFunction, Decl(reverseMappedInferenceWithCircularConstraint.ts, 0, 0)) +>args : Symbol(args, Decl(reverseMappedInferenceWithCircularConstraint.ts, 2, 20)) + +type InferNarrowest = T extends any +>InferNarrowest : Symbol(InferNarrowest, Decl(reverseMappedInferenceWithCircularConstraint.ts, 2, 43)) +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 4, 20)) +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 4, 20)) + + ? T extends AnyFunction +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 4, 20)) +>AnyFunction : Symbol(AnyFunction, Decl(reverseMappedInferenceWithCircularConstraint.ts, 0, 0)) + + ? T +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 4, 20)) + + : T extends object +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 4, 20)) + + ? InferNarrowestObject +>InferNarrowestObject : Symbol(InferNarrowestObject, Decl(reverseMappedInferenceWithCircularConstraint.ts, 10, 10)) +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 4, 20)) + + : T +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 4, 20)) + + : never; + +type InferNarrowestObject = { +>InferNarrowestObject : Symbol(InferNarrowestObject, Decl(reverseMappedInferenceWithCircularConstraint.ts, 10, 10)) +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 12, 26)) + + readonly [K in keyof T]: InferNarrowest; +>K : Symbol(K, Decl(reverseMappedInferenceWithCircularConstraint.ts, 13, 12)) +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 12, 26)) +>InferNarrowest : Symbol(InferNarrowest, Decl(reverseMappedInferenceWithCircularConstraint.ts, 2, 43)) +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 12, 26)) +>K : Symbol(K, Decl(reverseMappedInferenceWithCircularConstraint.ts, 13, 12)) + +}; + +type Config> = { +>Config : Symbol(Config, Decl(reverseMappedInferenceWithCircularConstraint.ts, 14, 2)) +>TGlobal : Symbol(TGlobal, Decl(reverseMappedInferenceWithCircularConstraint.ts, 16, 12)) +>TState : Symbol(TState, Decl(reverseMappedInferenceWithCircularConstraint.ts, 16, 20)) +>Prop : Symbol(Prop, Decl(reverseMappedInferenceWithCircularConstraint.ts, 24, 2)) +>TGlobal : Symbol(TGlobal, Decl(reverseMappedInferenceWithCircularConstraint.ts, 16, 12)) + + states: { +>states : Symbol(states, Decl(reverseMappedInferenceWithCircularConstraint.ts, 16, 58)) + + [StateKey in keyof TState]: { +>StateKey : Symbol(StateKey, Decl(reverseMappedInferenceWithCircularConstraint.ts, 18, 5)) +>TState : Symbol(TState, Decl(reverseMappedInferenceWithCircularConstraint.ts, 16, 20)) + + on?: {}; +>on : Symbol(on, Decl(reverseMappedInferenceWithCircularConstraint.ts, 18, 33)) + + }; + }; +} & { + initial: keyof TState; +>initial : Symbol(initial, Decl(reverseMappedInferenceWithCircularConstraint.ts, 22, 5)) +>TState : Symbol(TState, Decl(reverseMappedInferenceWithCircularConstraint.ts, 16, 20)) + +}; + +type Prop = K extends keyof T ? T[K] : never; +>Prop : Symbol(Prop, Decl(reverseMappedInferenceWithCircularConstraint.ts, 24, 2)) +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 26, 10)) +>K : Symbol(K, Decl(reverseMappedInferenceWithCircularConstraint.ts, 26, 12)) +>K : Symbol(K, Decl(reverseMappedInferenceWithCircularConstraint.ts, 26, 12)) +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 26, 10)) +>T : Symbol(T, Decl(reverseMappedInferenceWithCircularConstraint.ts, 26, 10)) +>K : Symbol(K, Decl(reverseMappedInferenceWithCircularConstraint.ts, 26, 12)) + +const createMachine = >( +>createMachine : Symbol(createMachine, Decl(reverseMappedInferenceWithCircularConstraint.ts, 28, 5)) +>TConfig : Symbol(TConfig, Decl(reverseMappedInferenceWithCircularConstraint.ts, 28, 23)) +>Config : Symbol(Config, Decl(reverseMappedInferenceWithCircularConstraint.ts, 14, 2)) +>TConfig : Symbol(TConfig, Decl(reverseMappedInferenceWithCircularConstraint.ts, 28, 23)) + + _config: InferNarrowestObject +>_config : Symbol(_config, Decl(reverseMappedInferenceWithCircularConstraint.ts, 28, 56)) +>InferNarrowestObject : Symbol(InferNarrowestObject, Decl(reverseMappedInferenceWithCircularConstraint.ts, 10, 10)) +>TConfig : Symbol(TConfig, Decl(reverseMappedInferenceWithCircularConstraint.ts, 28, 23)) + +): void => {}; + +createMachine({ +>createMachine : Symbol(createMachine, Decl(reverseMappedInferenceWithCircularConstraint.ts, 28, 5)) + + initial: "pending", +>initial : Symbol(initial, Decl(reverseMappedInferenceWithCircularConstraint.ts, 32, 15)) + + states: { +>states : Symbol(states, Decl(reverseMappedInferenceWithCircularConstraint.ts, 33, 21)) + + pending: { +>pending : Symbol(pending, Decl(reverseMappedInferenceWithCircularConstraint.ts, 34, 11)) + + on: { +>on : Symbol(on, Decl(reverseMappedInferenceWithCircularConstraint.ts, 35, 14)) + + done() { +>done : Symbol(done, Decl(reverseMappedInferenceWithCircularConstraint.ts, 36, 11)) + + return "noData"; + }, + }, + }, + }, +}); + +createMachine({ +>createMachine : Symbol(createMachine, Decl(reverseMappedInferenceWithCircularConstraint.ts, 28, 5)) + + initial: "unknown", // error +>initial : Symbol(initial, Decl(reverseMappedInferenceWithCircularConstraint.ts, 45, 15)) + + states: { +>states : Symbol(states, Decl(reverseMappedInferenceWithCircularConstraint.ts, 46, 21)) + + pending: { +>pending : Symbol(pending, Decl(reverseMappedInferenceWithCircularConstraint.ts, 47, 11)) + + on: { +>on : Symbol(on, Decl(reverseMappedInferenceWithCircularConstraint.ts, 48, 14)) + + done() { +>done : Symbol(done, Decl(reverseMappedInferenceWithCircularConstraint.ts, 49, 11)) + + return "noData"; + }, + }, + }, + }, +}); + diff --git a/tests/baselines/reference/reverseMappedInferenceWithCircularConstraint.types b/tests/baselines/reference/reverseMappedInferenceWithCircularConstraint.types new file mode 100644 index 0000000000000..1d50158d0265c --- /dev/null +++ b/tests/baselines/reference/reverseMappedInferenceWithCircularConstraint.types @@ -0,0 +1,159 @@ +//// [tests/cases/compiler/reverseMappedInferenceWithCircularConstraint.ts] //// + +=== reverseMappedInferenceWithCircularConstraint.ts === +// repro from https://github.com/microsoft/TypeScript/issues/48798 + +type AnyFunction = (...args: any[]) => any; +>AnyFunction : AnyFunction +> : ^^^^^^^^^^^ +>args : any[] +> : ^^^^^ + +type InferNarrowest = T extends any +>InferNarrowest : InferNarrowest +> : ^^^^^^^^^^^^^^^^^ + + ? T extends AnyFunction + ? T + : T extends object + ? InferNarrowestObject + : T + : never; + +type InferNarrowestObject = { +>InferNarrowestObject : InferNarrowestObject +> : ^^^^^^^^^^^^^^^^^^^^^^^ + + readonly [K in keyof T]: InferNarrowest; +}; + +type Config> = { +>Config : Config +> : ^^^^^^^^^^^^^^^^^^^^^^^ + + states: { +>states : { [StateKey in keyof TState]: { on?: {}; }; } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ + + [StateKey in keyof TState]: { + on?: {}; +>on : {} | undefined +> : ^^^^^^^^^^^^^^ + + }; + }; +} & { + initial: keyof TState; +>initial : keyof TState +> : ^^^^^^^^^^^^ + +}; + +type Prop = K extends keyof T ? T[K] : never; +>Prop : Prop +> : ^^^^^^^^^^ + +const createMachine = >( +>createMachine : >(_config: InferNarrowestObject) => void +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>>( _config: InferNarrowestObject): void => {} : >(_config: InferNarrowestObject) => void +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ + + _config: InferNarrowestObject +>_config : InferNarrowestObject +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +): void => {}; + +createMachine({ +>createMachine({ initial: "pending", states: { pending: { on: { done() { return "noData"; }, }, }, },}) : void +> : ^^^^ +>createMachine : >(_config: InferNarrowestObject) => void +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>{ initial: "pending", states: { pending: { on: { done() { return "noData"; }, }, }, },} : { initial: "pending"; states: { pending: { on: { done(): "noData"; }; }; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + initial: "pending", +>initial : "pending" +> : ^^^^^^^^^ +>"pending" : "pending" +> : ^^^^^^^^^ + + states: { +>states : { pending: { on: { done(): "noData"; }; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ pending: { on: { done() { return "noData"; }, }, }, } : { pending: { on: { done(): "noData"; }; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + pending: { +>pending : { on: { done(): "noData"; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ on: { done() { return "noData"; }, }, } : { on: { done(): "noData"; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + on: { +>on : { done(): "noData"; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>{ done() { return "noData"; }, } : { done(): "noData"; } +> : ^^^^^^^^^^^^^^^^^^^^^ + + done() { +>done : () => "noData" +> : ^^^^^^^^^^^^^^ + + return "noData"; +>"noData" : "noData" +> : ^^^^^^^^ + + }, + }, + }, + }, +}); + +createMachine({ +>createMachine({ initial: "unknown", // error states: { pending: { on: { done() { return "noData"; }, }, }, },}) : void +> : ^^^^ +>createMachine : >(_config: InferNarrowestObject) => void +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>{ initial: "unknown", // error states: { pending: { on: { done() { return "noData"; }, }, }, },} : { initial: "unknown"; states: { pending: { on: { done(): string; }; }; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + initial: "unknown", // error +>initial : "unknown" +> : ^^^^^^^^^ +>"unknown" : "unknown" +> : ^^^^^^^^^ + + states: { +>states : { pending: { on: { done(): string; }; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ pending: { on: { done() { return "noData"; }, }, }, } : { pending: { on: { done(): string; }; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + pending: { +>pending : { on: { done(): string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ on: { done() { return "noData"; }, }, } : { on: { done(): string; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + on: { +>on : { done(): string; } +> : ^^^^^^^^^^^^^^^^^^^ +>{ done() { return "noData"; }, } : { done(): string; } +> : ^^^^^^^^^^^^^^^^^^^ + + done() { +>done : () => string +> : ^^^^^^^^^^^^ + + return "noData"; +>"noData" : "noData" +> : ^^^^^^^^ + + }, + }, + }, + }, +}); + diff --git a/tests/baselines/reference/reverseMappedPartiallyInferableTypes.types b/tests/baselines/reference/reverseMappedPartiallyInferableTypes.types index 50e7502dd422c..9dea997c04137 100644 --- a/tests/baselines/reference/reverseMappedPartiallyInferableTypes.types +++ b/tests/baselines/reference/reverseMappedPartiallyInferableTypes.types @@ -299,10 +299,10 @@ const obj2 = id({ // No properties have inferable types const obj3 = id({ ->obj3 : Mapped -> : ^^^^^^^^^^^^^^^ ->id({ foo: { contains(k) { return k.length > 0; } }}) : Mapped -> : ^^^^^^^^^^^^^^^ +>obj3 : Mapped<{ foo: unknown; }> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>id({ foo: { contains(k) { return k.length > 0; } }}) : Mapped<{ foo: unknown; }> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ >id : (arg: Mapped) => Mapped > : ^ ^^ ^^ ^^^^^ >{ foo: { contains(k) { return k.length > 0; } }} : { foo: { contains(k: unknown): boolean; }; } diff --git a/tests/baselines/reference/reverseMappedPartiallyInferableTypes2.symbols b/tests/baselines/reference/reverseMappedPartiallyInferableTypes2.symbols new file mode 100644 index 0000000000000..abfe74d249c12 --- /dev/null +++ b/tests/baselines/reference/reverseMappedPartiallyInferableTypes2.symbols @@ -0,0 +1,82 @@ +//// [tests/cases/compiler/reverseMappedPartiallyInferableTypes2.ts] //// + +=== reverseMappedPartiallyInferableTypes2.ts === +declare function fn(arg: { +>fn : Symbol(fn, Decl(reverseMappedPartiallyInferableTypes2.ts, 0, 0)) +>T : Symbol(T, Decl(reverseMappedPartiallyInferableTypes2.ts, 0, 20)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 0, 23)) + + [K in keyof T]: T[K] & ((arg: string) => {}); +>K : Symbol(K, Decl(reverseMappedPartiallyInferableTypes2.ts, 1, 3)) +>T : Symbol(T, Decl(reverseMappedPartiallyInferableTypes2.ts, 0, 20)) +>T : Symbol(T, Decl(reverseMappedPartiallyInferableTypes2.ts, 0, 20)) +>K : Symbol(K, Decl(reverseMappedPartiallyInferableTypes2.ts, 1, 3)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 1, 27)) + +}): T; +>T : Symbol(T, Decl(reverseMappedPartiallyInferableTypes2.ts, 0, 20)) + +const res1 = fn({ +>res1 : Symbol(res1, Decl(reverseMappedPartiallyInferableTypes2.ts, 4, 5)) +>fn : Symbol(fn, Decl(reverseMappedPartiallyInferableTypes2.ts, 0, 0)) + + a: (arg) => arg, +>a : Symbol(a, Decl(reverseMappedPartiallyInferableTypes2.ts, 4, 17)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 5, 6)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 5, 6)) + + b: (arg) => [arg], +>b : Symbol(b, Decl(reverseMappedPartiallyInferableTypes2.ts, 5, 18)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 6, 6)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 6, 6)) + +}); + +const res2 = fn({ +>res2 : Symbol(res2, Decl(reverseMappedPartiallyInferableTypes2.ts, 9, 5)) +>fn : Symbol(fn, Decl(reverseMappedPartiallyInferableTypes2.ts, 0, 0)) + + a: (arg: string) => arg, +>a : Symbol(a, Decl(reverseMappedPartiallyInferableTypes2.ts, 9, 17)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 10, 6)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 10, 6)) + + b: (arg: string) => [arg], +>b : Symbol(b, Decl(reverseMappedPartiallyInferableTypes2.ts, 10, 26)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 11, 6)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 11, 6)) + +}); + +const res3 = fn({ +>res3 : Symbol(res3, Decl(reverseMappedPartiallyInferableTypes2.ts, 14, 5)) +>fn : Symbol(fn, Decl(reverseMappedPartiallyInferableTypes2.ts, 0, 0)) + + a: (arg: string) => arg, +>a : Symbol(a, Decl(reverseMappedPartiallyInferableTypes2.ts, 14, 17)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 15, 6)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 15, 6)) + + b: (arg) => [arg], +>b : Symbol(b, Decl(reverseMappedPartiallyInferableTypes2.ts, 15, 26)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 16, 6)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 16, 6)) + +}); + +const res4 = fn({ +>res4 : Symbol(res4, Decl(reverseMappedPartiallyInferableTypes2.ts, 19, 5)) +>fn : Symbol(fn, Decl(reverseMappedPartiallyInferableTypes2.ts, 0, 0)) + + a: (arg) => arg, +>a : Symbol(a, Decl(reverseMappedPartiallyInferableTypes2.ts, 19, 17)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 20, 6)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 20, 6)) + + b: (arg: string) => [arg], +>b : Symbol(b, Decl(reverseMappedPartiallyInferableTypes2.ts, 20, 18)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 21, 6)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes2.ts, 21, 6)) + +}); + diff --git a/tests/baselines/reference/reverseMappedPartiallyInferableTypes2.types b/tests/baselines/reference/reverseMappedPartiallyInferableTypes2.types new file mode 100644 index 0000000000000..c874ed0f5ef5e --- /dev/null +++ b/tests/baselines/reference/reverseMappedPartiallyInferableTypes2.types @@ -0,0 +1,151 @@ +//// [tests/cases/compiler/reverseMappedPartiallyInferableTypes2.ts] //// + +=== reverseMappedPartiallyInferableTypes2.ts === +declare function fn(arg: { +>fn : (arg: { [K in keyof T]: T[K] & ((arg: string) => {}); }) => T +> : ^ ^^ ^^ ^^^^^ +>arg : { [K in keyof T]: T[K] & ((arg: string) => {}); } +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^ ^^^^ + + [K in keyof T]: T[K] & ((arg: string) => {}); +>arg : string +> : ^^^^^^ + +}): T; + +const res1 = fn({ +>res1 : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>fn({ a: (arg) => arg, b: (arg) => [arg],}) : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>fn : (arg: { [K in keyof T]: T[K] & ((arg: string) => {}); }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a: (arg) => arg, b: (arg) => [arg],} : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ + + a: (arg) => arg, +>a : (arg: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(arg) => arg : (arg: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>arg : string +> : ^^^^^^ +>arg : string +> : ^^^^^^ + + b: (arg) => [arg], +>b : (arg: string) => string[] +> : ^ ^^^^^^^^^^^^^^^^^^^^^ +>(arg) => [arg] : (arg: string) => string[] +> : ^ ^^^^^^^^^^^^^^^^^^^^^ +>arg : string +> : ^^^^^^ +>[arg] : string[] +> : ^^^^^^^^ +>arg : string +> : ^^^^^^ + +}); + +const res2 = fn({ +>res2 : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^ ^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^ +>fn({ a: (arg: string) => arg, b: (arg: string) => [arg],}) : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^ ^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^ +>fn : (arg: { [K in keyof T]: T[K] & ((arg: string) => {}); }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a: (arg: string) => arg, b: (arg: string) => [arg],} : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^ ^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^ + + a: (arg: string) => arg, +>a : (arg: string) => string +> : ^ ^^ ^^^^^^^^^^^ +>(arg: string) => arg : (arg: string) => string +> : ^ ^^ ^^^^^^^^^^^ +>arg : string +> : ^^^^^^ +>arg : string +> : ^^^^^^ + + b: (arg: string) => [arg], +>b : (arg: string) => string[] +> : ^ ^^ ^^^^^^^^^^^^^ +>(arg: string) => [arg] : (arg: string) => string[] +> : ^ ^^ ^^^^^^^^^^^^^ +>arg : string +> : ^^^^^^ +>[arg] : string[] +> : ^^^^^^^^ +>arg : string +> : ^^^^^^ + +}); + +const res3 = fn({ +>res3 : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>fn({ a: (arg: string) => arg, b: (arg) => [arg],}) : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>fn : (arg: { [K in keyof T]: T[K] & ((arg: string) => {}); }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a: (arg: string) => arg, b: (arg) => [arg],} : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ + + a: (arg: string) => arg, +>a : (arg: string) => string +> : ^ ^^ ^^^^^^^^^^^ +>(arg: string) => arg : (arg: string) => string +> : ^ ^^ ^^^^^^^^^^^ +>arg : string +> : ^^^^^^ +>arg : string +> : ^^^^^^ + + b: (arg) => [arg], +>b : (arg: string) => string[] +> : ^ ^^^^^^^^^^^^^^^^^^^^^ +>(arg) => [arg] : (arg: string) => string[] +> : ^ ^^^^^^^^^^^^^^^^^^^^^ +>arg : string +> : ^^^^^^ +>[arg] : string[] +> : ^^^^^^^^ +>arg : string +> : ^^^^^^ + +}); + +const res4 = fn({ +>res4 : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^ +>fn({ a: (arg) => arg, b: (arg: string) => [arg],}) : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^ +>fn : (arg: { [K in keyof T]: T[K] & ((arg: string) => {}); }) => T +> : ^ ^^ ^^ ^^^^^ +>{ a: (arg) => arg, b: (arg: string) => [arg],} : { a: (arg: string) => string; b: (arg: string) => string[]; } +> : ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^ + + a: (arg) => arg, +>a : (arg: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>(arg) => arg : (arg: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>arg : string +> : ^^^^^^ +>arg : string +> : ^^^^^^ + + b: (arg: string) => [arg], +>b : (arg: string) => string[] +> : ^ ^^ ^^^^^^^^^^^^^ +>(arg: string) => [arg] : (arg: string) => string[] +> : ^ ^^ ^^^^^^^^^^^^^ +>arg : string +> : ^^^^^^ +>[arg] : string[] +> : ^^^^^^^^ +>arg : string +> : ^^^^^^ + +}); + diff --git a/tests/baselines/reference/reverseMappedPartiallyInferableTypes3.symbols b/tests/baselines/reference/reverseMappedPartiallyInferableTypes3.symbols new file mode 100644 index 0000000000000..36245f31b6fba --- /dev/null +++ b/tests/baselines/reference/reverseMappedPartiallyInferableTypes3.symbols @@ -0,0 +1,108 @@ +//// [tests/cases/compiler/reverseMappedPartiallyInferableTypes3.ts] //// + +=== reverseMappedPartiallyInferableTypes3.ts === +declare function setup(arg: { +>setup : Symbol(setup, Decl(reverseMappedPartiallyInferableTypes3.ts, 0, 0)) +>TAction : Symbol(TAction, Decl(reverseMappedPartiallyInferableTypes3.ts, 0, 23)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes3.ts, 0, 37)) + + actions?: { +>actions : Symbol(actions, Decl(reverseMappedPartiallyInferableTypes3.ts, 0, 43)) + + [K in keyof TAction]: ( +>K : Symbol(K, Decl(reverseMappedPartiallyInferableTypes3.ts, 2, 5)) +>TAction : Symbol(TAction, Decl(reverseMappedPartiallyInferableTypes3.ts, 0, 23)) + + params: TAction[K], +>params : Symbol(params, Decl(reverseMappedPartiallyInferableTypes3.ts, 2, 27)) +>TAction : Symbol(TAction, Decl(reverseMappedPartiallyInferableTypes3.ts, 0, 23)) +>K : Symbol(K, Decl(reverseMappedPartiallyInferableTypes3.ts, 2, 5)) + + exec: (arg: TAction) => void, +>exec : Symbol(exec, Decl(reverseMappedPartiallyInferableTypes3.ts, 3, 25)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes3.ts, 4, 13)) +>TAction : Symbol(TAction, Decl(reverseMappedPartiallyInferableTypes3.ts, 0, 23)) + + ) => void; + }; +}): TAction; +>TAction : Symbol(TAction, Decl(reverseMappedPartiallyInferableTypes3.ts, 0, 23)) + +const result1 = setup({ +>result1 : Symbol(result1, Decl(reverseMappedPartiallyInferableTypes3.ts, 9, 5)) +>setup : Symbol(setup, Decl(reverseMappedPartiallyInferableTypes3.ts, 0, 0)) + + actions: { +>actions : Symbol(actions, Decl(reverseMappedPartiallyInferableTypes3.ts, 9, 23)) + + first: (params: { count: number }, enqueue) => {}, +>first : Symbol(first, Decl(reverseMappedPartiallyInferableTypes3.ts, 10, 12)) +>params : Symbol(params, Decl(reverseMappedPartiallyInferableTypes3.ts, 11, 12)) +>count : Symbol(count, Decl(reverseMappedPartiallyInferableTypes3.ts, 11, 21)) +>enqueue : Symbol(enqueue, Decl(reverseMappedPartiallyInferableTypes3.ts, 11, 38)) + + second: (params: { foo: string }, enqueue) => {}, +>second : Symbol(second, Decl(reverseMappedPartiallyInferableTypes3.ts, 11, 54)) +>params : Symbol(params, Decl(reverseMappedPartiallyInferableTypes3.ts, 12, 13)) +>foo : Symbol(foo, Decl(reverseMappedPartiallyInferableTypes3.ts, 12, 22)) +>enqueue : Symbol(enqueue, Decl(reverseMappedPartiallyInferableTypes3.ts, 12, 37)) + + }, +}); + +const result2 = setup({ +>result2 : Symbol(result2, Decl(reverseMappedPartiallyInferableTypes3.ts, 16, 5)) +>setup : Symbol(setup, Decl(reverseMappedPartiallyInferableTypes3.ts, 0, 0)) + + actions: { +>actions : Symbol(actions, Decl(reverseMappedPartiallyInferableTypes3.ts, 16, 23)) + + foo: (params: { count: number }) => {}, +>foo : Symbol(foo, Decl(reverseMappedPartiallyInferableTypes3.ts, 17, 12)) +>params : Symbol(params, Decl(reverseMappedPartiallyInferableTypes3.ts, 18, 10)) +>count : Symbol(count, Decl(reverseMappedPartiallyInferableTypes3.ts, 18, 19)) + + first: (params: { count: number }, enqueue) => {}, +>first : Symbol(first, Decl(reverseMappedPartiallyInferableTypes3.ts, 18, 43)) +>params : Symbol(params, Decl(reverseMappedPartiallyInferableTypes3.ts, 19, 12)) +>count : Symbol(count, Decl(reverseMappedPartiallyInferableTypes3.ts, 19, 21)) +>enqueue : Symbol(enqueue, Decl(reverseMappedPartiallyInferableTypes3.ts, 19, 38)) + + second: (params: { foo: string }, enqueue) => {}, +>second : Symbol(second, Decl(reverseMappedPartiallyInferableTypes3.ts, 19, 54)) +>params : Symbol(params, Decl(reverseMappedPartiallyInferableTypes3.ts, 20, 13)) +>foo : Symbol(foo, Decl(reverseMappedPartiallyInferableTypes3.ts, 20, 22)) +>enqueue : Symbol(enqueue, Decl(reverseMappedPartiallyInferableTypes3.ts, 20, 37)) + + }, +}); + +const result3 = setup({ +>result3 : Symbol(result3, Decl(reverseMappedPartiallyInferableTypes3.ts, 24, 5)) +>setup : Symbol(setup, Decl(reverseMappedPartiallyInferableTypes3.ts, 0, 0)) + + actions: { +>actions : Symbol(actions, Decl(reverseMappedPartiallyInferableTypes3.ts, 24, 23)) + + foo: (params: { count: number }) => {}, +>foo : Symbol(foo, Decl(reverseMappedPartiallyInferableTypes3.ts, 25, 12)) +>params : Symbol(params, Decl(reverseMappedPartiallyInferableTypes3.ts, 26, 10)) +>count : Symbol(count, Decl(reverseMappedPartiallyInferableTypes3.ts, 26, 19)) + + first: (params: { count: number }, enqueue: (arg: never) => void) => {}, +>first : Symbol(first, Decl(reverseMappedPartiallyInferableTypes3.ts, 26, 43)) +>params : Symbol(params, Decl(reverseMappedPartiallyInferableTypes3.ts, 27, 12)) +>count : Symbol(count, Decl(reverseMappedPartiallyInferableTypes3.ts, 27, 21)) +>enqueue : Symbol(enqueue, Decl(reverseMappedPartiallyInferableTypes3.ts, 27, 38)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes3.ts, 27, 49)) + + second: (params: { foo: string }, enqueue: (arg: never) => void) => {}, +>second : Symbol(second, Decl(reverseMappedPartiallyInferableTypes3.ts, 27, 76)) +>params : Symbol(params, Decl(reverseMappedPartiallyInferableTypes3.ts, 28, 13)) +>foo : Symbol(foo, Decl(reverseMappedPartiallyInferableTypes3.ts, 28, 22)) +>enqueue : Symbol(enqueue, Decl(reverseMappedPartiallyInferableTypes3.ts, 28, 37)) +>arg : Symbol(arg, Decl(reverseMappedPartiallyInferableTypes3.ts, 28, 48)) + + }, +}); + diff --git a/tests/baselines/reference/reverseMappedPartiallyInferableTypes3.types b/tests/baselines/reference/reverseMappedPartiallyInferableTypes3.types new file mode 100644 index 0000000000000..3a49c3110c2b3 --- /dev/null +++ b/tests/baselines/reference/reverseMappedPartiallyInferableTypes3.types @@ -0,0 +1,181 @@ +//// [tests/cases/compiler/reverseMappedPartiallyInferableTypes3.ts] //// + +=== reverseMappedPartiallyInferableTypes3.ts === +declare function setup(arg: { +>setup : (arg: { actions?: { [K in keyof TAction]: (params: TAction[K], exec: (arg: TAction) => void) => void; }; }) => TAction +> : ^ ^^^^^^^ ^^ ^^^^^ +>arg : { actions?: { [K in keyof TAction]: (params: TAction[K], exec: (arg: TAction) => void) => void; }; } +> : ^^^^^^^^^^^^ ^^^ + + actions?: { +>actions : { [K in keyof TAction]: (params: TAction[K], exec: (arg: TAction) => void) => void; } | undefined +> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^ + + [K in keyof TAction]: ( + params: TAction[K], +>params : TAction[K] +> : ^^^^^^^^^^ + + exec: (arg: TAction) => void, +>exec : (arg: TAction) => void +> : ^ ^^ ^^^^^ +>arg : TAction +> : ^^^^^^^ + + ) => void; + }; +}): TAction; + +const result1 = setup({ +>result1 : { first: { count: number; }; second: { foo: string; }; } +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>setup({ actions: { first: (params: { count: number }, enqueue) => {}, second: (params: { foo: string }, enqueue) => {}, },}) : { first: { count: number; }; second: { foo: string; }; } +> : ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>setup : (arg: { actions?: { [K in keyof TAction]: (params: TAction[K], exec: (arg: TAction) => void) => void; }; }) => TAction +> : ^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { first: (params: { count: number }, enqueue) => {}, second: (params: { foo: string }, enqueue) => {}, },} : { actions: { first: (params: { count: number; }, enqueue: (arg: { first: { count: number; }; second: { foo: string; }; }) => void) => void; second: (params: { foo: string; }, enqueue: (arg: { first: { count: number; }; second: { foo: string; }; }) => void) => void; }; } +> : ^^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + + actions: { +>actions : { first: (params: { count: number; }, enqueue: (arg: { first: { count: number; }; second: { foo: string; }; }) => void) => void; second: (params: { foo: string; }, enqueue: (arg: { first: { count: number; }; second: { foo: string; }; }) => void) => void; } +> : ^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^ +>{ first: (params: { count: number }, enqueue) => {}, second: (params: { foo: string }, enqueue) => {}, } : { first: (params: { count: number; }, enqueue: (arg: { first: { count: number; }; second: { foo: string; }; }) => void) => void; second: (params: { foo: string; }, enqueue: (arg: { first: { count: number; }; second: { foo: string; }; }) => void) => void; } +> : ^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^ + + first: (params: { count: number }, enqueue) => {}, +>first : (params: { count: number; }, enqueue: (arg: { first: { count: number; }; second: { foo: string; }; }) => void) => void +> : ^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^ +>(params: { count: number }, enqueue) => {} : (params: { count: number; }, enqueue: (arg: { first: { count: number; }; second: { foo: string; }; }) => void) => void +> : ^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^ +>params : { count: number; } +> : ^^^^^^^^^ ^^^ +>count : number +> : ^^^^^^ +>enqueue : (arg: { first: { count: number; }; second: { foo: string; }; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ + + second: (params: { foo: string }, enqueue) => {}, +>second : (params: { foo: string; }, enqueue: (arg: { first: { count: number; }; second: { foo: string; }; }) => void) => void +> : ^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^ +>(params: { foo: string }, enqueue) => {} : (params: { foo: string; }, enqueue: (arg: { first: { count: number; }; second: { foo: string; }; }) => void) => void +> : ^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^ +>params : { foo: string; } +> : ^^^^^^^ ^^^ +>foo : string +> : ^^^^^^ +>enqueue : (arg: { first: { count: number; }; second: { foo: string; }; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ + + }, +}); + +const result2 = setup({ +>result2 : { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; } +> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>setup({ actions: { foo: (params: { count: number }) => {}, first: (params: { count: number }, enqueue) => {}, second: (params: { foo: string }, enqueue) => {}, },}) : { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; } +> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>setup : (arg: { actions?: { [K in keyof TAction]: (params: TAction[K], exec: (arg: TAction) => void) => void; }; }) => TAction +> : ^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { foo: (params: { count: number }) => {}, first: (params: { count: number }, enqueue) => {}, second: (params: { foo: string }, enqueue) => {}, },} : { actions: { foo: (params: { count: number; }) => void; first: (params: { count: number; }, enqueue: (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void) => void; second: (params: { foo: string; }, enqueue: (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void) => void; }; } +> : ^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + + actions: { +>actions : { foo: (params: { count: number; }) => void; first: (params: { count: number; }, enqueue: (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void) => void; second: (params: { foo: string; }, enqueue: (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void) => void; } +> : ^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^ +>{ foo: (params: { count: number }) => {}, first: (params: { count: number }, enqueue) => {}, second: (params: { foo: string }, enqueue) => {}, } : { foo: (params: { count: number; }) => void; first: (params: { count: number; }, enqueue: (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void) => void; second: (params: { foo: string; }, enqueue: (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void) => void; } +> : ^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^ + + foo: (params: { count: number }) => {}, +>foo : (params: { count: number; }) => void +> : ^ ^^ ^^^^^^^^^ +>(params: { count: number }) => {} : (params: { count: number; }) => void +> : ^ ^^ ^^^^^^^^^ +>params : { count: number; } +> : ^^^^^^^^^ ^^^ +>count : number +> : ^^^^^^ + + first: (params: { count: number }, enqueue) => {}, +>first : (params: { count: number; }, enqueue: (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void) => void +> : ^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^ +>(params: { count: number }, enqueue) => {} : (params: { count: number; }, enqueue: (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void) => void +> : ^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^ +>params : { count: number; } +> : ^^^^^^^^^ ^^^ +>count : number +> : ^^^^^^ +>enqueue : (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ + + second: (params: { foo: string }, enqueue) => {}, +>second : (params: { foo: string; }, enqueue: (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void) => void +> : ^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^ +>(params: { foo: string }, enqueue) => {} : (params: { foo: string; }, enqueue: (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void) => void +> : ^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^ +>params : { foo: string; } +> : ^^^^^^^ ^^^ +>foo : string +> : ^^^^^^ +>enqueue : (arg: { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ + + }, +}); + +const result3 = setup({ +>result3 : { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; } +> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>setup({ actions: { foo: (params: { count: number }) => {}, first: (params: { count: number }, enqueue: (arg: never) => void) => {}, second: (params: { foo: string }, enqueue: (arg: never) => void) => {}, },}) : { foo: { count: number; }; first: { count: number; }; second: { foo: string; }; } +> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>setup : (arg: { actions?: { [K in keyof TAction]: (params: TAction[K], exec: (arg: TAction) => void) => void; }; }) => TAction +> : ^ ^^^^^^^ ^^ ^^^^^ +>{ actions: { foo: (params: { count: number }) => {}, first: (params: { count: number }, enqueue: (arg: never) => void) => {}, second: (params: { foo: string }, enqueue: (arg: never) => void) => {}, },} : { actions: { foo: (params: { count: number; }) => void; first: (params: { count: number; }, enqueue: (arg: never) => void) => void; second: (params: { foo: string; }, enqueue: (arg: never) => void) => void; }; } +> : ^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^ + + actions: { +>actions : { foo: (params: { count: number; }) => void; first: (params: { count: number; }, enqueue: (arg: never) => void) => void; second: (params: { foo: string; }, enqueue: (arg: never) => void) => void; } +> : ^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ +>{ foo: (params: { count: number }) => {}, first: (params: { count: number }, enqueue: (arg: never) => void) => {}, second: (params: { foo: string }, enqueue: (arg: never) => void) => {}, } : { foo: (params: { count: number; }) => void; first: (params: { count: number; }, enqueue: (arg: never) => void) => void; second: (params: { foo: string; }, enqueue: (arg: never) => void) => void; } +> : ^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^ + + foo: (params: { count: number }) => {}, +>foo : (params: { count: number; }) => void +> : ^ ^^ ^^^^^^^^^ +>(params: { count: number }) => {} : (params: { count: number; }) => void +> : ^ ^^ ^^^^^^^^^ +>params : { count: number; } +> : ^^^^^^^^^ ^^^ +>count : number +> : ^^^^^^ + + first: (params: { count: number }, enqueue: (arg: never) => void) => {}, +>first : (params: { count: number; }, enqueue: (arg: never) => void) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>(params: { count: number }, enqueue: (arg: never) => void) => {} : (params: { count: number; }, enqueue: (arg: never) => void) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>params : { count: number; } +> : ^^^^^^^^^ ^^^ +>count : number +> : ^^^^^^ +>enqueue : (arg: never) => void +> : ^ ^^ ^^^^^ +>arg : never +> : ^^^^^ + + second: (params: { foo: string }, enqueue: (arg: never) => void) => {}, +>second : (params: { foo: string; }, enqueue: (arg: never) => void) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>(params: { foo: string }, enqueue: (arg: never) => void) => {} : (params: { foo: string; }, enqueue: (arg: never) => void) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>params : { foo: string; } +> : ^^^^^^^ ^^^ +>foo : string +> : ^^^^^^ +>enqueue : (arg: never) => void +> : ^ ^^ ^^^^^ +>arg : never +> : ^^^^^ + + }, +}); + diff --git a/tests/cases/compiler/reverseMappedInferenceWithCircularConstraint.ts b/tests/cases/compiler/reverseMappedInferenceWithCircularConstraint.ts new file mode 100644 index 0000000000000..dae226e89632e --- /dev/null +++ b/tests/cases/compiler/reverseMappedInferenceWithCircularConstraint.ts @@ -0,0 +1,60 @@ +// @strict: true +// @noEmit: true + +// repro from https://github.com/microsoft/TypeScript/issues/48798 + +type AnyFunction = (...args: any[]) => any; + +type InferNarrowest = T extends any + ? T extends AnyFunction + ? T + : T extends object + ? InferNarrowestObject + : T + : never; + +type InferNarrowestObject = { + readonly [K in keyof T]: InferNarrowest; +}; + +type Config> = { + states: { + [StateKey in keyof TState]: { + on?: {}; + }; + }; +} & { + initial: keyof TState; +}; + +type Prop = K extends keyof T ? T[K] : never; + +const createMachine = >( + _config: InferNarrowestObject +): void => {}; + +createMachine({ + initial: "pending", + states: { + pending: { + on: { + done() { + return "noData"; + }, + }, + }, + }, +}); + +createMachine({ + initial: "unknown", // error + states: { + pending: { + on: { + done() { + return "noData"; + }, + }, + }, + }, +}); diff --git a/tests/cases/compiler/reverseMappedPartiallyInferableTypes2.ts b/tests/cases/compiler/reverseMappedPartiallyInferableTypes2.ts new file mode 100644 index 0000000000000..fbb221b4eab74 --- /dev/null +++ b/tests/cases/compiler/reverseMappedPartiallyInferableTypes2.ts @@ -0,0 +1,26 @@ +// @strict: true +// @noEmit: true + +declare function fn(arg: { + [K in keyof T]: T[K] & ((arg: string) => {}); +}): T; + +const res1 = fn({ + a: (arg) => arg, + b: (arg) => [arg], +}); + +const res2 = fn({ + a: (arg: string) => arg, + b: (arg: string) => [arg], +}); + +const res3 = fn({ + a: (arg: string) => arg, + b: (arg) => [arg], +}); + +const res4 = fn({ + a: (arg) => arg, + b: (arg: string) => [arg], +}); diff --git a/tests/cases/compiler/reverseMappedPartiallyInferableTypes3.ts b/tests/cases/compiler/reverseMappedPartiallyInferableTypes3.ts new file mode 100644 index 0000000000000..13b97b8e0254a --- /dev/null +++ b/tests/cases/compiler/reverseMappedPartiallyInferableTypes3.ts @@ -0,0 +1,34 @@ +// @strict: true +// @noEmit: true + +declare function setup(arg: { + actions?: { + [K in keyof TAction]: ( + params: TAction[K], + exec: (arg: TAction) => void, + ) => void; + }; +}): TAction; + +const result1 = setup({ + actions: { + first: (params: { count: number }, enqueue) => {}, + second: (params: { foo: string }, enqueue) => {}, + }, +}); + +const result2 = setup({ + actions: { + foo: (params: { count: number }) => {}, + first: (params: { count: number }, enqueue) => {}, + second: (params: { foo: string }, enqueue) => {}, + }, +}); + +const result3 = setup({ + actions: { + foo: (params: { count: number }) => {}, + first: (params: { count: number }, enqueue: (arg: never) => void) => {}, + second: (params: { foo: string }, enqueue: (arg: never) => void) => {}, + }, +}); diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesReverseMappedTypes.ts b/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesReverseMappedTypes.ts new file mode 100644 index 0000000000000..dcf3e1e2c042d --- /dev/null +++ b/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesReverseMappedTypes.ts @@ -0,0 +1,291 @@ +// @strict: true +// @declaration: true + +// repro cases based on https://github.com/microsoft/TypeScript/issues/53018 + +declare function f( + arg: { + [K in keyof T]: { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + } +): T; + +const res1 = f({ + a: { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }, + b: { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }, +}); + +const res2 = f({ + a: { + produce: function () { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + }, + b: { + produce: function () { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + }, +}); + +const res3 = f({ + a: { + produce() { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + }, + b: { + produce() { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + }, +}); + +declare function f2( + arg: [ + ...{ + [K in keyof T]: { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + } + ] +): T; + +const res4 = f2([ + { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }, + { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }, +]); + +const res5 = f2([ + { + produce: function () { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + }, + { + produce: function () { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + }, +]); + +const res6 = f2([ + { + produce() { + return "hello"; + }, + consume: (x) => x.toLowerCase(), + }, + { + produce() { + return { v: "hello" }; + }, + consume: (x) => x.v.toLowerCase(), + }, +]); + +declare function f3( + arg: { + [K in keyof T]: { + other: number, + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; + } +): T; + +const res7 = f3({ + a: { + other: 42, + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }, + b: { + other: 100, + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }, +}); + +declare function f4( + arg: { + [K in keyof T]: [ + (n: string) => T[K], + (x: T[K]) => void + ]; + } +): T; + +const res8 = f4({ + a: [ + (n) => n, + (x) => x.toLowerCase(), + ], + b: [ + (n) => ({ v: n }), + (x) => x.v.toLowerCase(), + ], +}); + +declare function f5( + arg: { + [K in keyof T1]: { + produce1: (n: string) => T1[K]; + consume1: (x: T1[K]) => void; + }; + } & { + [K in keyof T2]: { + produce2: (n: string) => T2[K]; + consume2: (x: T2[K]) => void; + }; + }, +): [T1, T2]; + +const res9 = f5({ + a: { + produce1: (n) => n, + consume1: (x) => x.toLowerCase(), + produce2: (n) => [n], + consume2: (x) => x[0].toLowerCase(), + }, + b: { + produce1: (n) => ({ v: n }), + consume1: (x) => x.v.toLowerCase(), + produce2: (n) => ({ v: [n] }), + consume2: (x) => x.v[0].toLowerCase(), + }, +}); + +declare function f6(arg: { + [K in keyof T]: () => { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; +}): T; + +const res10 = f6({ + a() { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b() { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, +}); + +const res11 = f6({ + a: () => { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b: () => { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, +}); + +declare function f7(arg: { + [K in keyof T]: (arg: boolean) => { + produce: (n: string) => T[K]; + consume: (x: T[K]) => void; + }; +}): T; + +const res12 = f7({ + a(arg) { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b(arg) { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, +}); + +const res13 = f7({ + a: (arg) => { + return { + produce: (n) => n, + consume: (x) => x.toLowerCase(), + }; + }, + b: (arg) => { + return { + produce: (n) => ({ v: n }), + consume: (x) => x.v.toLowerCase(), + }; + }, +}); + +declare function f8(arg: { + [K in keyof T]: () => [(n: string) => T[K], (x: T[K]) => void]; +}): T; + +const res14 = f8({ + a() { + return [(n) => n, (x) => x.toLowerCase()]; + }, + b() { + return [(n) => ({ v: n }), (x) => x.v.toLowerCase()]; + }, +}); + +declare function f9( + arg: { + [K in keyof T1]: { + produce: (n: string) => [T1[K], any]; + consume: (x: T1[K]) => void; + }; + } & { + a: { + produce: (n: string) => [any, T2]; + consume2: (x: T2) => void; + }; + }, +): [T1, T2]; + +const res15 = f9({ + a: { + produce: (n) => [n, [n]], + consume2: (x) => x[0].toLowerCase(), + consume: (x) => x.toLowerCase(), + }, + b: { + produce: (n) => [{ v: n }, null], + consume: (x) => x.v.toLowerCase(), + }, +});