diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 75be36474222f..a5a7529b48931 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1758,7 +1758,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const node = getParseTreeNode(nodeIn, isJsxAttributeLike); return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined); }, - isContextSensitive, + containsContextSensitive, getTypeOfPropertyOfContextualType, getFullyQualifiedName, getResolvedSignature: (node, candidatesOutArray, argumentCount) => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, CheckMode.Normal), @@ -6213,7 +6213,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function symbolValueDeclarationIsContextSensitive(symbol: Symbol): boolean { - return symbol && !!symbol.valueDeclaration && isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + return symbol && !!symbol.valueDeclaration && isExpression(symbol.valueDeclaration) && !containsContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags = TypeFormatFlags.None): NodeBuilderFlags { @@ -13000,7 +13000,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { case SyntaxKind.MappedType: case SyntaxKind.ConditionalType: { const outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if ((kind === SyntaxKind.FunctionExpression || kind === SyntaxKind.ArrowFunction || isObjectLiteralMethod(node)) && isContextSensitive(node as Expression | MethodDeclaration)) { + if ((kind === SyntaxKind.FunctionExpression || kind === SyntaxKind.ArrowFunction || isObjectLiteralMethod(node)) && containsContextSensitive(node as Expression | MethodDeclaration)) { const signature = firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfDeclaration(node as FunctionLikeDeclaration)), SignatureKind.Call)); if (signature && signature.typeParameters) { return [...(outerTypeParameters || emptyArray), ...signature.typeParameters]; @@ -21104,47 +21104,56 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return createIndexInfo(info.keyType, instantiateType(info.type, mapper), info.isReadonly, info.declaration, info.components); } - // Returns true if the given expression contains (at any level of nesting) a function or arrow expression - // that is subject to contextual typing. - function isContextSensitive(node: Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike | JsxChild): boolean { + function containsContextRelatedNode(node: Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike | JsxChild, predicate: (node: Node) => boolean): boolean { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); switch (node.kind) { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: case SyntaxKind.MethodDeclaration: - case SyntaxKind.FunctionDeclaration: // Function declarations can have context when annotated with a jsdoc @type - return isContextSensitiveFunctionLikeDeclaration(node as FunctionExpression | ArrowFunction | MethodDeclaration); + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.CallExpression: + case SyntaxKind.NewExpression: + return predicate(node); case SyntaxKind.ObjectLiteralExpression: - return some((node as ObjectLiteralExpression).properties, isContextSensitive); + return some((node as ObjectLiteralExpression).properties, p => containsContextRelatedNode(p, predicate)); case SyntaxKind.ArrayLiteralExpression: - return some((node as ArrayLiteralExpression).elements, isContextSensitive); + return some((node as ArrayLiteralExpression).elements, e => containsContextRelatedNode(e, predicate)); case SyntaxKind.ConditionalExpression: - return isContextSensitive((node as ConditionalExpression).whenTrue) || - isContextSensitive((node as ConditionalExpression).whenFalse); + return containsContextRelatedNode((node as ConditionalExpression).whenTrue, predicate) || + containsContextRelatedNode((node as ConditionalExpression).whenFalse, predicate); case SyntaxKind.BinaryExpression: return ((node as BinaryExpression).operatorToken.kind === SyntaxKind.BarBarToken || (node as BinaryExpression).operatorToken.kind === SyntaxKind.QuestionQuestionToken) && - (isContextSensitive((node as BinaryExpression).left) || isContextSensitive((node as BinaryExpression).right)); + (containsContextRelatedNode((node as BinaryExpression).left, predicate) || containsContextRelatedNode((node as BinaryExpression).right, predicate)); case SyntaxKind.PropertyAssignment: - return isContextSensitive((node as PropertyAssignment).initializer); + return containsContextRelatedNode((node as PropertyAssignment).initializer, predicate); case SyntaxKind.ParenthesizedExpression: - return isContextSensitive((node as ParenthesizedExpression).expression); + return containsContextRelatedNode((node as ParenthesizedExpression).expression, predicate); case SyntaxKind.JsxAttributes: - return some((node as JsxAttributes).properties, isContextSensitive) || isJsxOpeningElement(node.parent) && some(node.parent.parent.children, isContextSensitive); + return some((node as JsxAttributes).properties, p => containsContextRelatedNode(p, predicate)) || isJsxOpeningElement(node.parent) && some(node.parent.parent.children, c => containsContextRelatedNode(c, predicate)); case SyntaxKind.JsxAttribute: { - // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. const { initializer } = node as JsxAttribute; - return !!initializer && isContextSensitive(initializer); + return !!initializer && containsContextRelatedNode(initializer, predicate); } case SyntaxKind.JsxExpression: { // It is possible to that node.expression is undefined (e.g
) const { expression } = node as JsxExpression; - return !!expression && isContextSensitive(expression); + return !!expression && containsContextRelatedNode(expression, predicate); } } return false; } + // Returns true if the given expression contains (at any level of nesting) a function or arrow expression + // that is subject to contextual typing. + function containsContextSensitive(node: Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike | JsxChild): boolean { + return containsContextRelatedNode(node, isContextSensitiveFunctionOrObjectLiteralMethod); + } + + function containsContextSensitiveOrCallOrNewExpression(node: Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike | JsxChild): boolean { + return containsContextRelatedNode(node, n => isContextSensitiveFunctionOrObjectLiteralMethod(n) || isCallOrNewExpression(n)); + } + function isContextSensitiveFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { return hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node); } @@ -21154,9 +21163,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return false; } if (node.body.kind !== SyntaxKind.Block) { - return isContextSensitive(node.body); + return containsContextSensitive(node.body); } - return !!forEachReturnStatement(node.body as Block, statement => !!statement.expression && isContextSensitive(statement.expression)); + return !!forEachReturnStatement(node.body as Block, statement => !!statement.expression && containsContextSensitive(statement.expression)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | ArrowFunction | MethodDeclaration { @@ -33264,7 +33273,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const type = checkExpressionForMutableLocation(e, checkMode, forceTuple); elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); elementFlags.push(hasOmittedExpression ? ElementFlags.Optional : ElementFlags.Required); - if (inTupleContext && checkMode && checkMode & CheckMode.Inferential && !(checkMode & CheckMode.SkipContextSensitive) && isContextSensitive(e)) { + if (inTupleContext && checkMode && checkMode & CheckMode.Inferential && !(checkMode & CheckMode.SkipContextSensitive) && containsContextSensitiveOrCallOrNewExpression(e)) { const inferenceContext = getInferenceContext(node); Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context addIntraExpressionInferenceSite(inferenceContext, e, type); @@ -33505,7 +33514,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if ( contextualType && checkMode & CheckMode.Inferential && !(checkMode & CheckMode.SkipContextSensitive) && - (memberDecl.kind === SyntaxKind.PropertyAssignment || memberDecl.kind === SyntaxKind.MethodDeclaration) && isContextSensitive(memberDecl) + (memberDecl.kind === SyntaxKind.PropertyAssignment || memberDecl.kind === SyntaxKind.MethodDeclaration) && containsContextSensitiveOrCallOrNewExpression(memberDecl) ) { const inferenceContext = getInferenceContext(node); Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context @@ -33744,7 +33753,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText as string); } } - if (contextualType && checkMode & CheckMode.Inferential && !(checkMode & CheckMode.SkipContextSensitive) && isContextSensitive(attributeDecl)) { + if (contextualType && checkMode & CheckMode.Inferential && !(checkMode & CheckMode.SkipContextSensitive) && containsContextSensitiveOrCallOrNewExpression(attributeDecl)) { const inferenceContext = getInferenceContext(attributes); Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context const inferenceNode = (attributeDecl.initializer as JsxExpression).expression!; @@ -36507,7 +36516,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; - if (!isDecorator && !isSingleNonGenericCandidate && some(args, isContextSensitive)) { + if (!isDecorator && !isSingleNonGenericCandidate && some(args, containsContextSensitive)) { argCheckMode = CheckMode.SkipContextSensitive; } @@ -39494,7 +39503,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // The identityMapper object is used to indicate that function expressions are wildcards - if (checkMode && checkMode & CheckMode.SkipContextSensitive && isContextSensitive(node)) { + if (checkMode && checkMode & CheckMode.SkipContextSensitive && containsContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage if (!getEffectiveReturnTypeNode(node) && !hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type @@ -39539,7 +39548,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!signature) { return; } - if (isContextSensitive(node)) { + if (containsContextSensitive(node)) { if (contextualSignature) { const inferenceContext = getInferenceContext(node); let instantiatedContextualSignature: Signature | undefined; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1cfe3e04ba68d..2cef5a142af76 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5238,7 +5238,7 @@ export interface TypeChecker { /** @internal */ getContextualTypeForObjectLiteralElement(element: ObjectLiteralElementLike): Type | undefined; /** @internal */ getContextualTypeForArgumentAtIndex(call: CallLikeExpression, argIndex: number): Type | undefined; /** @internal */ getContextualTypeForJsxAttribute(attribute: JsxAttribute | JsxSpreadAttribute): Type | undefined; - /** @internal */ isContextSensitive(node: Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike): boolean; + /** @internal */ containsContextSensitive(node: Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike): boolean; /** @internal */ getTypeOfPropertyOfContextualType(type: Type, name: __String): Type | undefined; /** diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index 2d59e42c433d6..b4fa0cecaf29f 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -1379,7 +1379,7 @@ function extractConstantInScope( const localNameText = getIdentifierForNode(node, scope, checker, file); const isJS = isInJSFile(scope); - let variableType = isJS || !checker.isContextSensitive(node) + let variableType = isJS || !checker.containsContextSensitive(node) ? undefined : checker.typeToTypeNode(checker.getContextualType(node)!, scope, NodeBuilderFlags.NoTruncation, InternalNodeBuilderFlags.AllowUnresolvedNames); // TODO: GH#18217 diff --git a/tests/baselines/reference/intraExpressionInferences.errors.txt b/tests/baselines/reference/intraExpressionInferences.errors.txt index 82da18c788e9b..5e29182af2f2a 100644 --- a/tests/baselines/reference/intraExpressionInferences.errors.txt +++ b/tests/baselines/reference/intraExpressionInferences.errors.txt @@ -344,4 +344,27 @@ intraExpressionInferences.ts(133,26): error TS2339: Property 'nonexistent' does }, consumer: (val) => {}, }); + + type ErrorFn = (error: unknown) => void; + + declare const genericFn: (args: { + parser: (p: unknown, errorFn: ErrorFn) => T; + handler: (data: { body: T }) => unknown; + }) => T; + + declare const createParser: (arg: T) => (p: unknown, errorFn: ErrorFn) => T; + + genericFn({ + parser: createParser(1 as const), + handler: ({ body: _ }) => {}, + }); + + declare const genericFnTuple: ( + args: [ + parser: (p: unknown, errorFn: ErrorFn) => T, + handler: (data: { body: T }) => unknown + ] + ) => T; + + genericFnTuple([createParser(1 as const), ({ body: _ }) => {}]); \ No newline at end of file diff --git a/tests/baselines/reference/intraExpressionInferences.js b/tests/baselines/reference/intraExpressionInferences.js index fbdd0e64bd30e..ee7f8bbaeb1f8 100644 --- a/tests/baselines/reference/intraExpressionInferences.js +++ b/tests/baselines/reference/intraExpressionInferences.js @@ -331,6 +331,29 @@ const distantRes = distant({ }, consumer: (val) => {}, }); + +type ErrorFn = (error: unknown) => void; + +declare const genericFn: (args: { + parser: (p: unknown, errorFn: ErrorFn) => T; + handler: (data: { body: T }) => unknown; +}) => T; + +declare const createParser: (arg: T) => (p: unknown, errorFn: ErrorFn) => T; + +genericFn({ + parser: createParser(1 as const), + handler: ({ body: _ }) => {}, +}); + +declare const genericFnTuple: ( + args: [ + parser: (p: unknown, errorFn: ErrorFn) => T, + handler: (data: { body: T }) => unknown + ] +) => T; + +genericFnTuple([createParser(1 as const), ({ body: _ }) => {}]); //// [intraExpressionInferences.js] @@ -518,6 +541,15 @@ var distantRes = distant({ }, consumer: function (val) { }, }); +genericFn({ + parser: createParser(1), + handler: function (_b) { + var _ = _b.body; + }, +}); +genericFnTuple([createParser(1), function (_b) { + var _ = _b.body; + }]); //// [intraExpressionInferences.d.ts] @@ -648,3 +680,17 @@ declare function distant(args: { consumer: (val: T) => unknown; }): T; declare const distantRes: number; +type ErrorFn = (error: unknown) => void; +declare const genericFn: (args: { + parser: (p: unknown, errorFn: ErrorFn) => T; + handler: (data: { + body: T; + }) => unknown; +}) => T; +declare const createParser: (arg: T) => (p: unknown, errorFn: ErrorFn) => T; +declare const genericFnTuple: (args: [ + parser: (p: unknown, errorFn: ErrorFn) => T, + handler: (data: { + body: T; + }) => unknown +]) => T; diff --git a/tests/baselines/reference/intraExpressionInferences.symbols b/tests/baselines/reference/intraExpressionInferences.symbols index f0a01515373d5..a9721855e0609 100644 --- a/tests/baselines/reference/intraExpressionInferences.symbols +++ b/tests/baselines/reference/intraExpressionInferences.symbols @@ -1076,3 +1076,82 @@ const distantRes = distant({ }); +type ErrorFn = (error: unknown) => void; +>ErrorFn : Symbol(ErrorFn, Decl(intraExpressionInferences.ts, 329, 3)) +>error : Symbol(error, Decl(intraExpressionInferences.ts, 331, 16)) + +declare const genericFn: (args: { +>genericFn : Symbol(genericFn, Decl(intraExpressionInferences.ts, 333, 13)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 333, 26)) +>args : Symbol(args, Decl(intraExpressionInferences.ts, 333, 29)) + + parser: (p: unknown, errorFn: ErrorFn) => T; +>parser : Symbol(parser, Decl(intraExpressionInferences.ts, 333, 36)) +>p : Symbol(p, Decl(intraExpressionInferences.ts, 334, 11)) +>errorFn : Symbol(errorFn, Decl(intraExpressionInferences.ts, 334, 22)) +>ErrorFn : Symbol(ErrorFn, Decl(intraExpressionInferences.ts, 329, 3)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 333, 26)) + + handler: (data: { body: T }) => unknown; +>handler : Symbol(handler, Decl(intraExpressionInferences.ts, 334, 46)) +>data : Symbol(data, Decl(intraExpressionInferences.ts, 335, 12)) +>body : Symbol(body, Decl(intraExpressionInferences.ts, 335, 19)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 333, 26)) + +}) => T; +>T : Symbol(T, Decl(intraExpressionInferences.ts, 333, 26)) + +declare const createParser: (arg: T) => (p: unknown, errorFn: ErrorFn) => T; +>createParser : Symbol(createParser, Decl(intraExpressionInferences.ts, 338, 13)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 338, 29)) +>arg : Symbol(arg, Decl(intraExpressionInferences.ts, 338, 32)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 338, 29)) +>p : Symbol(p, Decl(intraExpressionInferences.ts, 338, 44)) +>errorFn : Symbol(errorFn, Decl(intraExpressionInferences.ts, 338, 55)) +>ErrorFn : Symbol(ErrorFn, Decl(intraExpressionInferences.ts, 329, 3)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 338, 29)) + +genericFn({ +>genericFn : Symbol(genericFn, Decl(intraExpressionInferences.ts, 333, 13)) + + parser: createParser(1 as const), +>parser : Symbol(parser, Decl(intraExpressionInferences.ts, 340, 11)) +>createParser : Symbol(createParser, Decl(intraExpressionInferences.ts, 338, 13)) +>const : Symbol(const) + + handler: ({ body: _ }) => {}, +>handler : Symbol(handler, Decl(intraExpressionInferences.ts, 341, 35)) +>body : Symbol(body, Decl(intraExpressionInferences.ts, 335, 19)) +>_ : Symbol(_, Decl(intraExpressionInferences.ts, 342, 13)) + +}); + +declare const genericFnTuple: ( +>genericFnTuple : Symbol(genericFnTuple, Decl(intraExpressionInferences.ts, 345, 13)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 345, 31)) + + args: [ +>args : Symbol(args, Decl(intraExpressionInferences.ts, 345, 34)) + + parser: (p: unknown, errorFn: ErrorFn) => T, +>p : Symbol(p, Decl(intraExpressionInferences.ts, 347, 13)) +>errorFn : Symbol(errorFn, Decl(intraExpressionInferences.ts, 347, 24)) +>ErrorFn : Symbol(ErrorFn, Decl(intraExpressionInferences.ts, 329, 3)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 345, 31)) + + handler: (data: { body: T }) => unknown +>data : Symbol(data, Decl(intraExpressionInferences.ts, 348, 14)) +>body : Symbol(body, Decl(intraExpressionInferences.ts, 348, 21)) +>T : Symbol(T, Decl(intraExpressionInferences.ts, 345, 31)) + + ] +) => T; +>T : Symbol(T, Decl(intraExpressionInferences.ts, 345, 31)) + +genericFnTuple([createParser(1 as const), ({ body: _ }) => {}]); +>genericFnTuple : Symbol(genericFnTuple, Decl(intraExpressionInferences.ts, 345, 13)) +>createParser : Symbol(createParser, Decl(intraExpressionInferences.ts, 338, 13)) +>const : Symbol(const) +>body : Symbol(body, Decl(intraExpressionInferences.ts, 348, 21)) +>_ : Symbol(_, Decl(intraExpressionInferences.ts, 352, 44)) + diff --git a/tests/baselines/reference/intraExpressionInferences.types b/tests/baselines/reference/intraExpressionInferences.types index 37c49da2a03a3..570fdbf20d4f3 100644 --- a/tests/baselines/reference/intraExpressionInferences.types +++ b/tests/baselines/reference/intraExpressionInferences.types @@ -1743,3 +1743,120 @@ const distantRes = distant({ }); +type ErrorFn = (error: unknown) => void; +>ErrorFn : ErrorFn +> : ^^^^^^^ +>error : unknown +> : ^^^^^^^ + +declare const genericFn: (args: { +>genericFn : (args: { parser: (p: unknown, errorFn: ErrorFn) => T; handler: (data: { body: T; }) => unknown; }) => T +> : ^ ^^ ^^ ^^^^^ +>args : { parser: (p: unknown, errorFn: ErrorFn) => T; handler: (data: { body: T; }) => unknown; } +> : ^^^^^^^^^^ ^^^^^^^^^^^ ^^^ + + parser: (p: unknown, errorFn: ErrorFn) => T; +>parser : (p: unknown, errorFn: ErrorFn) => T +> : ^ ^^ ^^ ^^ ^^^^^ +>p : unknown +> : ^^^^^^^ +>errorFn : ErrorFn +> : ^^^^^^^ + + handler: (data: { body: T }) => unknown; +>handler : (data: { body: T; }) => unknown +> : ^ ^^ ^^^^^ +>data : { body: T; } +> : ^^^^^^^^ ^^^ +>body : T +> : ^ + +}) => T; + +declare const createParser: (arg: T) => (p: unknown, errorFn: ErrorFn) => T; +>createParser : (arg: T) => (p: unknown, errorFn: ErrorFn) => T +> : ^ ^^ ^^ ^^^^^ +>arg : T +> : ^ +>p : unknown +> : ^^^^^^^ +>errorFn : ErrorFn +> : ^^^^^^^ + +genericFn({ +>genericFn({ parser: createParser(1 as const), handler: ({ body: _ }) => {},}) : 1 +> : ^ +>genericFn : (args: { parser: (p: unknown, errorFn: ErrorFn) => T; handler: (data: { body: T; }) => unknown; }) => T +> : ^ ^^ ^^ ^^^^^ +>{ parser: createParser(1 as const), handler: ({ body: _ }) => {},} : { parser: (p: unknown, errorFn: ErrorFn) => 1; handler: ({ body: _ }: { body: 1; }) => void; } +> : ^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + + parser: createParser(1 as const), +>parser : (p: unknown, errorFn: ErrorFn) => 1 +> : ^ ^^ ^^ ^^ ^^^^^^ +>createParser(1 as const) : (p: unknown, errorFn: ErrorFn) => 1 +> : ^ ^^ ^^ ^^ ^^^^^^ +>createParser : (arg: T) => (p: unknown, errorFn: ErrorFn) => T +> : ^ ^^ ^^ ^^^^^ +>1 as const : 1 +> : ^ +>1 : 1 +> : ^ + + handler: ({ body: _ }) => {}, +>handler : ({ body: _ }: { body: 1; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ +>({ body: _ }) => {} : ({ body: _ }: { body: 1; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ +>body : any +> : ^^^ +>_ : 1 +> : ^ + +}); + +declare const genericFnTuple: ( +>genericFnTuple : (args: [parser: (p: unknown, errorFn: ErrorFn) => T, handler: (data: { body: T; }) => unknown]) => T +> : ^ ^^ ^^ ^^^^^ + + args: [ +>args : [parser: (p: unknown, errorFn: ErrorFn) => T, handler: (data: { body: T; }) => unknown] +> : ^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^ ^^ ^^^^^ ^ + + parser: (p: unknown, errorFn: ErrorFn) => T, +>p : unknown +> : ^^^^^^^ +>errorFn : ErrorFn +> : ^^^^^^^ + + handler: (data: { body: T }) => unknown +>data : { body: T; } +> : ^^^^^^^^ ^^^ +>body : T +> : ^ + + ] +) => T; + +genericFnTuple([createParser(1 as const), ({ body: _ }) => {}]); +>genericFnTuple([createParser(1 as const), ({ body: _ }) => {}]) : 1 +> : ^ +>genericFnTuple : (args: [parser: (p: unknown, errorFn: ErrorFn) => T, handler: (data: { body: T; }) => unknown]) => T +> : ^ ^^ ^^ ^^^^^ +>[createParser(1 as const), ({ body: _ }) => {}] : [(p: unknown, errorFn: ErrorFn) => 1, ({ body: _ }: { body: 1; }) => void] +> : ^^ ^^ ^^ ^^ ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>createParser(1 as const) : (p: unknown, errorFn: ErrorFn) => 1 +> : ^ ^^ ^^ ^^ ^^^^^^ +>createParser : (arg: T) => (p: unknown, errorFn: ErrorFn) => T +> : ^ ^^ ^^ ^^^^^ +>1 as const : 1 +> : ^ +>1 : 1 +> : ^ +>({ body: _ }) => {} : ({ body: _ }: { body: 1; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ +>body : any +> : ^^^ +>_ : 1 +> : ^ + diff --git a/tests/baselines/reference/intraExpressionInferencesJsx.symbols b/tests/baselines/reference/intraExpressionInferencesJsx.symbols index ca7efab1b40bd..7c310035b1c83 100644 --- a/tests/baselines/reference/intraExpressionInferencesJsx.symbols +++ b/tests/baselines/reference/intraExpressionInferencesJsx.symbols @@ -274,3 +274,48 @@ function Foo(props: Props) { }} />; +type ErrorFn = (error: unknown) => void; +>ErrorFn : Symbol(ErrorFn, Decl(intraExpressionInferencesJsx.tsx, 107, 6)) +>error : Symbol(error, Decl(intraExpressionInferencesJsx.tsx, 109, 16)) + +function GenericComp(props: { +>GenericComp : Symbol(GenericComp, Decl(intraExpressionInferencesJsx.tsx, 109, 40)) +>T : Symbol(T, Decl(intraExpressionInferencesJsx.tsx, 111, 21)) +>props : Symbol(props, Decl(intraExpressionInferencesJsx.tsx, 111, 24)) + + parser: (p: unknown, errorFn: ErrorFn) => T; +>parser : Symbol(parser, Decl(intraExpressionInferencesJsx.tsx, 111, 32)) +>p : Symbol(p, Decl(intraExpressionInferencesJsx.tsx, 112, 11)) +>errorFn : Symbol(errorFn, Decl(intraExpressionInferencesJsx.tsx, 112, 22)) +>ErrorFn : Symbol(ErrorFn, Decl(intraExpressionInferencesJsx.tsx, 107, 6)) +>T : Symbol(T, Decl(intraExpressionInferencesJsx.tsx, 111, 21)) + + handler: (data: { body: T }) => unknown; +>handler : Symbol(handler, Decl(intraExpressionInferencesJsx.tsx, 112, 46)) +>data : Symbol(data, Decl(intraExpressionInferencesJsx.tsx, 113, 12)) +>body : Symbol(body, Decl(intraExpressionInferencesJsx.tsx, 113, 19)) +>T : Symbol(T, Decl(intraExpressionInferencesJsx.tsx, 111, 21)) + +}) { + return null; +} + +declare const createParser: (arg: T) => (p: unknown, errorFn: ErrorFn) => T; +>createParser : Symbol(createParser, Decl(intraExpressionInferencesJsx.tsx, 118, 13)) +>T : Symbol(T, Decl(intraExpressionInferencesJsx.tsx, 118, 29)) +>arg : Symbol(arg, Decl(intraExpressionInferencesJsx.tsx, 118, 32)) +>T : Symbol(T, Decl(intraExpressionInferencesJsx.tsx, 118, 29)) +>p : Symbol(p, Decl(intraExpressionInferencesJsx.tsx, 118, 44)) +>errorFn : Symbol(errorFn, Decl(intraExpressionInferencesJsx.tsx, 118, 55)) +>ErrorFn : Symbol(ErrorFn, Decl(intraExpressionInferencesJsx.tsx, 107, 6)) +>T : Symbol(T, Decl(intraExpressionInferencesJsx.tsx, 118, 29)) + + {}} />; +>GenericComp : Symbol(GenericComp, Decl(intraExpressionInferencesJsx.tsx, 109, 40)) +>parser : Symbol(parser, Decl(intraExpressionInferencesJsx.tsx, 120, 12)) +>createParser : Symbol(createParser, Decl(intraExpressionInferencesJsx.tsx, 118, 13)) +>const : Symbol(const) +>handler : Symbol(handler, Decl(intraExpressionInferencesJsx.tsx, 120, 46)) +>body : Symbol(body, Decl(intraExpressionInferencesJsx.tsx, 113, 19)) +>_ : Symbol(_, Decl(intraExpressionInferencesJsx.tsx, 120, 58)) + diff --git a/tests/baselines/reference/intraExpressionInferencesJsx.types b/tests/baselines/reference/intraExpressionInferencesJsx.types index 54aaf495a218e..6e90b85ec4b4a 100644 --- a/tests/baselines/reference/intraExpressionInferencesJsx.types +++ b/tests/baselines/reference/intraExpressionInferencesJsx.types @@ -432,3 +432,69 @@ function Foo(props: Props) { }} />; +type ErrorFn = (error: unknown) => void; +>ErrorFn : ErrorFn +> : ^^^^^^^ +>error : unknown +> : ^^^^^^^ + +function GenericComp(props: { +>GenericComp : (props: { parser: (p: unknown, errorFn: ErrorFn) => T; handler: (data: { body: T; }) => unknown; }) => null +> : ^ ^^ ^^ ^^^^^^^^^ +>props : { parser: (p: unknown, errorFn: ErrorFn) => T; handler: (data: { body: T; }) => unknown; } +> : ^^^^^^^^^^ ^^^^^^^^^^^ ^^^ + + parser: (p: unknown, errorFn: ErrorFn) => T; +>parser : (p: unknown, errorFn: ErrorFn) => T +> : ^ ^^ ^^ ^^ ^^^^^ +>p : unknown +> : ^^^^^^^ +>errorFn : ErrorFn +> : ^^^^^^^ + + handler: (data: { body: T }) => unknown; +>handler : (data: { body: T; }) => unknown +> : ^ ^^ ^^^^^ +>data : { body: T; } +> : ^^^^^^^^ ^^^ +>body : T +> : ^ + +}) { + return null; +} + +declare const createParser: (arg: T) => (p: unknown, errorFn: ErrorFn) => T; +>createParser : (arg: T) => (p: unknown, errorFn: ErrorFn) => T +> : ^ ^^ ^^ ^^^^^ +>arg : T +> : ^ +>p : unknown +> : ^^^^^^^ +>errorFn : ErrorFn +> : ^^^^^^^ + + {}} />; +> {}} /> : JSX.Element +> : ^^^^^^^^^^^ +>GenericComp : (props: { parser: (p: unknown, errorFn: ErrorFn) => T; handler: (data: { body: T; }) => unknown; }) => null +> : ^ ^^ ^^ ^^^^^^^^^ +>parser : (p: unknown, errorFn: ErrorFn) => 1 +> : ^ ^^ ^^ ^^ ^^^^^^ +>createParser(1 as const) : (p: unknown, errorFn: ErrorFn) => 1 +> : ^ ^^ ^^ ^^ ^^^^^^ +>createParser : (arg: T) => (p: unknown, errorFn: ErrorFn) => T +> : ^ ^^ ^^ ^^^^^ +>1 as const : 1 +> : ^ +>1 : 1 +> : ^ +>handler : ({ body: _ }: { body: 1; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ +>({ body: _ }) => {} : ({ body: _ }: { body: 1; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ +>body : any +> : ^^^ +>_ : 1 +> : ^ + diff --git a/tests/baselines/reference/intraExpressionInferencesNestedGenericCall1.symbols b/tests/baselines/reference/intraExpressionInferencesNestedGenericCall1.symbols new file mode 100644 index 0000000000000..e809776607ef0 --- /dev/null +++ b/tests/baselines/reference/intraExpressionInferencesNestedGenericCall1.symbols @@ -0,0 +1,554 @@ +//// [tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesNestedGenericCall1.ts] //// + +=== intraExpressionInferencesNestedGenericCall1.ts === +interface FastifyTypeProvider { +>FastifyTypeProvider : Symbol(FastifyTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 0, 0)) + + readonly input: unknown; +>input : Symbol(FastifyTypeProvider.input, Decl(intraExpressionInferencesNestedGenericCall1.ts, 0, 31)) + + readonly output: unknown; +>output : Symbol(FastifyTypeProvider.output, Decl(intraExpressionInferencesNestedGenericCall1.ts, 1, 26)) +} + +export interface FastifyTypeProviderDefault extends FastifyTypeProvider {} +>FastifyTypeProviderDefault : Symbol(FastifyTypeProviderDefault, Decl(intraExpressionInferencesNestedGenericCall1.ts, 3, 1)) +>FastifyTypeProvider : Symbol(FastifyTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 0, 0)) + +type CallTypeProvider = (F & { +>CallTypeProvider : Symbol(CallTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 5, 74)) +>F : Symbol(F, Decl(intraExpressionInferencesNestedGenericCall1.ts, 7, 22)) +>FastifyTypeProvider : Symbol(FastifyTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 0, 0)) +>I : Symbol(I, Decl(intraExpressionInferencesNestedGenericCall1.ts, 7, 52)) +>F : Symbol(F, Decl(intraExpressionInferencesNestedGenericCall1.ts, 7, 22)) + + input: I; +>input : Symbol(input, Decl(intraExpressionInferencesNestedGenericCall1.ts, 7, 64)) +>I : Symbol(I, Decl(intraExpressionInferencesNestedGenericCall1.ts, 7, 52)) + +})["output"]; +type UndefinedToUnknown = [T] extends [undefined] ? unknown : T; +>UndefinedToUnknown : Symbol(UndefinedToUnknown, Decl(intraExpressionInferencesNestedGenericCall1.ts, 9, 13)) +>T : Symbol(T, Decl(intraExpressionInferencesNestedGenericCall1.ts, 10, 24)) +>T : Symbol(T, Decl(intraExpressionInferencesNestedGenericCall1.ts, 10, 24)) +>T : Symbol(T, Decl(intraExpressionInferencesNestedGenericCall1.ts, 10, 24)) + +interface RouteGenericInterface { +>RouteGenericInterface : Symbol(RouteGenericInterface, Decl(intraExpressionInferencesNestedGenericCall1.ts, 10, 67)) + + Querystring?: unknown; +>Querystring : Symbol(RouteGenericInterface.Querystring, Decl(intraExpressionInferencesNestedGenericCall1.ts, 12, 33)) +} + +interface FastifySchema { +>FastifySchema : Symbol(FastifySchema, Decl(intraExpressionInferencesNestedGenericCall1.ts, 14, 1)) + + querystring?: unknown; +>querystring : Symbol(FastifySchema.querystring, Decl(intraExpressionInferencesNestedGenericCall1.ts, 16, 25)) + + headers?: unknown; +>headers : Symbol(FastifySchema.headers, Decl(intraExpressionInferencesNestedGenericCall1.ts, 17, 24)) +} + +interface FastifyRequestType { +>FastifyRequestType : Symbol(FastifyRequestType, Decl(intraExpressionInferencesNestedGenericCall1.ts, 19, 1)) +>Querystring : Symbol(Querystring, Decl(intraExpressionInferencesNestedGenericCall1.ts, 21, 29)) + + query: Querystring; +>query : Symbol(FastifyRequestType.query, Decl(intraExpressionInferencesNestedGenericCall1.ts, 21, 53)) +>Querystring : Symbol(Querystring, Decl(intraExpressionInferencesNestedGenericCall1.ts, 21, 29)) +} + +type ResolveRequestQuerystring< +>ResolveRequestQuerystring : Symbol(ResolveRequestQuerystring, Decl(intraExpressionInferencesNestedGenericCall1.ts, 23, 1)) + + TypeProvider extends FastifyTypeProvider, +>TypeProvider : Symbol(TypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 25, 31)) +>FastifyTypeProvider : Symbol(FastifyTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 0, 0)) + + SchemaCompiler extends FastifySchema, +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 26, 43)) +>FastifySchema : Symbol(FastifySchema, Decl(intraExpressionInferencesNestedGenericCall1.ts, 14, 1)) + +> = UndefinedToUnknown< +>UndefinedToUnknown : Symbol(UndefinedToUnknown, Decl(intraExpressionInferencesNestedGenericCall1.ts, 9, 13)) + + CallTypeProvider +>CallTypeProvider : Symbol(CallTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 5, 74)) +>TypeProvider : Symbol(TypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 25, 31)) +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 26, 43)) + +>; + +interface ResolveFastifyRequestType< +>ResolveFastifyRequestType : Symbol(ResolveFastifyRequestType, Decl(intraExpressionInferencesNestedGenericCall1.ts, 30, 2)) + + TypeProvider extends FastifyTypeProvider, +>TypeProvider : Symbol(TypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 32, 36)) +>FastifyTypeProvider : Symbol(FastifyTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 0, 0)) + + SchemaCompiler extends FastifySchema, +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 33, 43)) +>FastifySchema : Symbol(FastifySchema, Decl(intraExpressionInferencesNestedGenericCall1.ts, 14, 1)) + +> { + query: ResolveRequestQuerystring; +>query : Symbol(ResolveFastifyRequestType.query, Decl(intraExpressionInferencesNestedGenericCall1.ts, 35, 3)) +>ResolveRequestQuerystring : Symbol(ResolveRequestQuerystring, Decl(intraExpressionInferencesNestedGenericCall1.ts, 23, 1)) +>TypeProvider : Symbol(TypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 32, 36)) +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 33, 43)) +} + +interface FastifyRequest< +>FastifyRequest : Symbol(FastifyRequest, Decl(intraExpressionInferencesNestedGenericCall1.ts, 37, 1)) + + RouteGeneric extends RouteGenericInterface = RouteGenericInterface, +>RouteGeneric : Symbol(RouteGeneric, Decl(intraExpressionInferencesNestedGenericCall1.ts, 39, 25)) +>RouteGenericInterface : Symbol(RouteGenericInterface, Decl(intraExpressionInferencesNestedGenericCall1.ts, 10, 67)) +>RouteGenericInterface : Symbol(RouteGenericInterface, Decl(intraExpressionInferencesNestedGenericCall1.ts, 10, 67)) + + SchemaCompiler extends FastifySchema = FastifySchema, +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 40, 69)) +>FastifySchema : Symbol(FastifySchema, Decl(intraExpressionInferencesNestedGenericCall1.ts, 14, 1)) +>FastifySchema : Symbol(FastifySchema, Decl(intraExpressionInferencesNestedGenericCall1.ts, 14, 1)) + + TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, +>TypeProvider : Symbol(TypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 41, 55)) +>FastifyTypeProvider : Symbol(FastifyTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 0, 0)) +>FastifyTypeProviderDefault : Symbol(FastifyTypeProviderDefault, Decl(intraExpressionInferencesNestedGenericCall1.ts, 3, 1)) + + RequestType extends FastifyRequestType = ResolveFastifyRequestType< +>RequestType : Symbol(RequestType, Decl(intraExpressionInferencesNestedGenericCall1.ts, 42, 72)) +>FastifyRequestType : Symbol(FastifyRequestType, Decl(intraExpressionInferencesNestedGenericCall1.ts, 19, 1)) +>ResolveFastifyRequestType : Symbol(ResolveFastifyRequestType, Decl(intraExpressionInferencesNestedGenericCall1.ts, 30, 2)) + + TypeProvider, +>TypeProvider : Symbol(TypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 41, 55)) + + SchemaCompiler +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 40, 69)) + + >, +> { + query: RequestType["query"]; +>query : Symbol(FastifyRequest.query, Decl(intraExpressionInferencesNestedGenericCall1.ts, 47, 3)) +>RequestType : Symbol(RequestType, Decl(intraExpressionInferencesNestedGenericCall1.ts, 42, 72)) +} + +interface RouteOptions< +>RouteOptions : Symbol(RouteOptions, Decl(intraExpressionInferencesNestedGenericCall1.ts, 49, 1)) + + RouteGeneric extends RouteGenericInterface, +>RouteGeneric : Symbol(RouteGeneric, Decl(intraExpressionInferencesNestedGenericCall1.ts, 51, 23)) +>RouteGenericInterface : Symbol(RouteGenericInterface, Decl(intraExpressionInferencesNestedGenericCall1.ts, 10, 67)) + + SchemaCompiler extends FastifySchema, +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 52, 45)) +>FastifySchema : Symbol(FastifySchema, Decl(intraExpressionInferencesNestedGenericCall1.ts, 14, 1)) + + TypeProvider extends FastifyTypeProvider, +>TypeProvider : Symbol(TypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 53, 39)) +>FastifyTypeProvider : Symbol(FastifyTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 0, 0)) + +> { + schema?: SchemaCompiler; +>schema : Symbol(RouteOptions.schema, Decl(intraExpressionInferencesNestedGenericCall1.ts, 55, 3)) +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 52, 45)) + + onRequest?: ( +>onRequest : Symbol(RouteOptions.onRequest, Decl(intraExpressionInferencesNestedGenericCall1.ts, 56, 26)) + + request: FastifyRequest, +>request : Symbol(request, Decl(intraExpressionInferencesNestedGenericCall1.ts, 57, 15)) +>FastifyRequest : Symbol(FastifyRequest, Decl(intraExpressionInferencesNestedGenericCall1.ts, 37, 1)) +>RouteGeneric : Symbol(RouteGeneric, Decl(intraExpressionInferencesNestedGenericCall1.ts, 51, 23)) +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 52, 45)) +>TypeProvider : Symbol(TypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 53, 39)) + + ) => void; + method: "GET" | "POST"; +>method : Symbol(RouteOptions.method, Decl(intraExpressionInferencesNestedGenericCall1.ts, 59, 12)) + + url: string; +>url : Symbol(RouteOptions.url, Decl(intraExpressionInferencesNestedGenericCall1.ts, 60, 25)) + + handler: ( +>handler : Symbol(RouteOptions.handler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 61, 14)) + + request: FastifyRequest, +>request : Symbol(request, Decl(intraExpressionInferencesNestedGenericCall1.ts, 62, 12)) +>FastifyRequest : Symbol(FastifyRequest, Decl(intraExpressionInferencesNestedGenericCall1.ts, 37, 1)) +>RouteGeneric : Symbol(RouteGeneric, Decl(intraExpressionInferencesNestedGenericCall1.ts, 51, 23)) +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 52, 45)) +>TypeProvider : Symbol(TypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 53, 39)) + + ) => void; +} + +interface FastifyInstance { +>FastifyInstance : Symbol(FastifyInstance, Decl(intraExpressionInferencesNestedGenericCall1.ts, 65, 1)) +>TypeProvider : Symbol(TypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 67, 26)) +>FastifyTypeProvider : Symbol(FastifyTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 0, 0)) + + route< +>route : Symbol(FastifyInstance.route, Decl(intraExpressionInferencesNestedGenericCall1.ts, 67, 69)) + + RouteGeneric extends RouteGenericInterface, +>RouteGeneric : Symbol(RouteGeneric, Decl(intraExpressionInferencesNestedGenericCall1.ts, 68, 8)) +>RouteGenericInterface : Symbol(RouteGenericInterface, Decl(intraExpressionInferencesNestedGenericCall1.ts, 10, 67)) + + SchemaCompiler extends FastifySchema, +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 69, 47)) +>FastifySchema : Symbol(FastifySchema, Decl(intraExpressionInferencesNestedGenericCall1.ts, 14, 1)) + + >( + opts: RouteOptions, +>opts : Symbol(opts, Decl(intraExpressionInferencesNestedGenericCall1.ts, 71, 4)) +>RouteOptions : Symbol(RouteOptions, Decl(intraExpressionInferencesNestedGenericCall1.ts, 49, 1)) +>RouteGeneric : Symbol(RouteGeneric, Decl(intraExpressionInferencesNestedGenericCall1.ts, 68, 8)) +>SchemaCompiler : Symbol(SchemaCompiler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 69, 47)) +>TypeProvider : Symbol(TypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 67, 26)) + + ): void; +} + +type Type = { +>Type : Symbol(Type, Decl(intraExpressionInferencesNestedGenericCall1.ts, 74, 1)) +>Output : Symbol(Output, Decl(intraExpressionInferencesNestedGenericCall1.ts, 76, 10)) + + _output: Output; +>_output : Symbol(_output, Decl(intraExpressionInferencesNestedGenericCall1.ts, 76, 21)) +>Output : Symbol(Output, Decl(intraExpressionInferencesNestedGenericCall1.ts, 76, 10)) + +}; + +declare function string(): Type; +>string : Symbol(string, Decl(intraExpressionInferencesNestedGenericCall1.ts, 78, 2)) +>Type : Symbol(Type, Decl(intraExpressionInferencesNestedGenericCall1.ts, 74, 1)) + +interface ZodTypeProvider extends FastifyTypeProvider { +>ZodTypeProvider : Symbol(ZodTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 80, 40)) +>FastifyTypeProvider : Symbol(FastifyTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 0, 0)) + + output: this["input"] extends { _output: unknown } +>output : Symbol(ZodTypeProvider.output, Decl(intraExpressionInferencesNestedGenericCall1.ts, 82, 55)) +>_output : Symbol(_output, Decl(intraExpressionInferencesNestedGenericCall1.ts, 83, 33)) + + ? this["input"]["_output"] + : never; +} + +const verifyAuth = +>verifyAuth : Symbol(verifyAuth, Decl(intraExpressionInferencesNestedGenericCall1.ts, 88, 5)) + + () => +>T : Symbol(T, Decl(intraExpressionInferencesNestedGenericCall1.ts, 89, 3)) +>FastifyRequest : Symbol(FastifyRequest, Decl(intraExpressionInferencesNestedGenericCall1.ts, 37, 1)) + + (req: T) => {}; +>req : Symbol(req, Decl(intraExpressionInferencesNestedGenericCall1.ts, 90, 3)) +>T : Symbol(T, Decl(intraExpressionInferencesNestedGenericCall1.ts, 89, 3)) + +declare const server: FastifyInstance; +>server : Symbol(server, Decl(intraExpressionInferencesNestedGenericCall1.ts, 92, 13)) +>FastifyInstance : Symbol(FastifyInstance, Decl(intraExpressionInferencesNestedGenericCall1.ts, 65, 1)) +>ZodTypeProvider : Symbol(ZodTypeProvider, Decl(intraExpressionInferencesNestedGenericCall1.ts, 80, 40)) + +server.route({ +>server.route : Symbol(FastifyInstance.route, Decl(intraExpressionInferencesNestedGenericCall1.ts, 67, 69)) +>server : Symbol(server, Decl(intraExpressionInferencesNestedGenericCall1.ts, 92, 13)) +>route : Symbol(FastifyInstance.route, Decl(intraExpressionInferencesNestedGenericCall1.ts, 67, 69)) + + url: "/config", +>url : Symbol(url, Decl(intraExpressionInferencesNestedGenericCall1.ts, 94, 14)) + + method: "GET", +>method : Symbol(method, Decl(intraExpressionInferencesNestedGenericCall1.ts, 95, 17)) + + schema: { +>schema : Symbol(schema, Decl(intraExpressionInferencesNestedGenericCall1.ts, 96, 16)) + + querystring: string(), +>querystring : Symbol(querystring, Decl(intraExpressionInferencesNestedGenericCall1.ts, 97, 11)) +>string : Symbol(string, Decl(intraExpressionInferencesNestedGenericCall1.ts, 78, 2)) + + }, + onRequest: verifyAuth(), +>onRequest : Symbol(onRequest, Decl(intraExpressionInferencesNestedGenericCall1.ts, 99, 4)) +>verifyAuth : Symbol(verifyAuth, Decl(intraExpressionInferencesNestedGenericCall1.ts, 88, 5)) + + handler: async (req) => { +>handler : Symbol(handler, Decl(intraExpressionInferencesNestedGenericCall1.ts, 100, 26)) +>req : Symbol(req, Decl(intraExpressionInferencesNestedGenericCall1.ts, 101, 18)) + + const query: string = req.query; +>query : Symbol(query, Decl(intraExpressionInferencesNestedGenericCall1.ts, 102, 9)) +>req.query : Symbol(FastifyRequest.query, Decl(intraExpressionInferencesNestedGenericCall1.ts, 47, 3)) +>req : Symbol(req, Decl(intraExpressionInferencesNestedGenericCall1.ts, 101, 18)) +>query : Symbol(FastifyRequest.query, Decl(intraExpressionInferencesNestedGenericCall1.ts, 47, 3)) + + }, +}); + +interface Container { +>Container : Symbol(Container, Decl(intraExpressionInferencesNestedGenericCall1.ts, 104, 3)) +>V : Symbol(V, Decl(intraExpressionInferencesNestedGenericCall1.ts, 106, 20)) + + v: V; +>v : Symbol(Container.v, Decl(intraExpressionInferencesNestedGenericCall1.ts, 106, 24)) +>V : Symbol(V, Decl(intraExpressionInferencesNestedGenericCall1.ts, 106, 20)) +} + +declare function makeWith(options: { +>makeWith : Symbol(makeWith, Decl(intraExpressionInferencesNestedGenericCall1.ts, 108, 1)) +>Key : Symbol(Key, Decl(intraExpressionInferencesNestedGenericCall1.ts, 110, 26)) +>Value : Symbol(Value, Decl(intraExpressionInferencesNestedGenericCall1.ts, 110, 30)) +>options : Symbol(options, Decl(intraExpressionInferencesNestedGenericCall1.ts, 110, 38)) + + readonly lookup: (key: Key) => Value; +>lookup : Symbol(lookup, Decl(intraExpressionInferencesNestedGenericCall1.ts, 110, 48)) +>key : Symbol(key, Decl(intraExpressionInferencesNestedGenericCall1.ts, 111, 20)) +>Key : Symbol(Key, Decl(intraExpressionInferencesNestedGenericCall1.ts, 110, 26)) +>Value : Symbol(Value, Decl(intraExpressionInferencesNestedGenericCall1.ts, 110, 30)) + + readonly timeToLive: (exit: Container) => number; +>timeToLive : Symbol(timeToLive, Decl(intraExpressionInferencesNestedGenericCall1.ts, 111, 39)) +>exit : Symbol(exit, Decl(intraExpressionInferencesNestedGenericCall1.ts, 112, 24)) +>Container : Symbol(Container, Decl(intraExpressionInferencesNestedGenericCall1.ts, 104, 3)) +>Value : Symbol(Value, Decl(intraExpressionInferencesNestedGenericCall1.ts, 110, 30)) + +}): [Key, Value]; +>Key : Symbol(Key, Decl(intraExpressionInferencesNestedGenericCall1.ts, 110, 26)) +>Value : Symbol(Value, Decl(intraExpressionInferencesNestedGenericCall1.ts, 110, 30)) + +declare function fn(fn: (arg: A) => R): (arg: A) => R; +>fn : Symbol(fn, Decl(intraExpressionInferencesNestedGenericCall1.ts, 113, 17)) +>A : Symbol(A, Decl(intraExpressionInferencesNestedGenericCall1.ts, 115, 20)) +>R : Symbol(R, Decl(intraExpressionInferencesNestedGenericCall1.ts, 115, 22)) +>fn : Symbol(fn, Decl(intraExpressionInferencesNestedGenericCall1.ts, 115, 26)) +>arg : Symbol(arg, Decl(intraExpressionInferencesNestedGenericCall1.ts, 115, 31)) +>A : Symbol(A, Decl(intraExpressionInferencesNestedGenericCall1.ts, 115, 20)) +>R : Symbol(R, Decl(intraExpressionInferencesNestedGenericCall1.ts, 115, 22)) +>arg : Symbol(arg, Decl(intraExpressionInferencesNestedGenericCall1.ts, 115, 47)) +>A : Symbol(A, Decl(intraExpressionInferencesNestedGenericCall1.ts, 115, 20)) +>R : Symbol(R, Decl(intraExpressionInferencesNestedGenericCall1.ts, 115, 22)) + +const result1 = makeWith({ +>result1 : Symbol(result1, Decl(intraExpressionInferencesNestedGenericCall1.ts, 117, 5)) +>makeWith : Symbol(makeWith, Decl(intraExpressionInferencesNestedGenericCall1.ts, 108, 1)) + + lookup: fn((key: string) => key), +>lookup : Symbol(lookup, Decl(intraExpressionInferencesNestedGenericCall1.ts, 117, 26)) +>fn : Symbol(fn, Decl(intraExpressionInferencesNestedGenericCall1.ts, 113, 17)) +>key : Symbol(key, Decl(intraExpressionInferencesNestedGenericCall1.ts, 118, 14)) +>key : Symbol(key, Decl(intraExpressionInferencesNestedGenericCall1.ts, 118, 14)) + + timeToLive: () => 10, +>timeToLive : Symbol(timeToLive, Decl(intraExpressionInferencesNestedGenericCall1.ts, 118, 35)) + +}); + +const result2 = makeWith({ +>result2 : Symbol(result2, Decl(intraExpressionInferencesNestedGenericCall1.ts, 122, 5)) +>makeWith : Symbol(makeWith, Decl(intraExpressionInferencesNestedGenericCall1.ts, 108, 1)) + + lookup: fn((key: string) => key), +>lookup : Symbol(lookup, Decl(intraExpressionInferencesNestedGenericCall1.ts, 122, 26)) +>fn : Symbol(fn, Decl(intraExpressionInferencesNestedGenericCall1.ts, 113, 17)) +>key : Symbol(key, Decl(intraExpressionInferencesNestedGenericCall1.ts, 123, 14)) +>key : Symbol(key, Decl(intraExpressionInferencesNestedGenericCall1.ts, 123, 14)) + + timeToLive: (exit) => exit.v.length, +>timeToLive : Symbol(timeToLive, Decl(intraExpressionInferencesNestedGenericCall1.ts, 123, 35)) +>exit : Symbol(exit, Decl(intraExpressionInferencesNestedGenericCall1.ts, 124, 15)) +>exit.v.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>exit.v : Symbol(Container.v, Decl(intraExpressionInferencesNestedGenericCall1.ts, 106, 24)) +>exit : Symbol(exit, Decl(intraExpressionInferencesNestedGenericCall1.ts, 124, 15)) +>v : Symbol(Container.v, Decl(intraExpressionInferencesNestedGenericCall1.ts, 106, 24)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + +}); + +// https://github.com/microsoft/TypeScript/issues/53776 +function deferQuery({}: { +>deferQuery : Symbol(deferQuery, Decl(intraExpressionInferencesNestedGenericCall1.ts, 125, 3)) +>TData : Symbol(TData, Decl(intraExpressionInferencesNestedGenericCall1.ts, 128, 20)) + + queryFn: () => Promise; +>queryFn : Symbol(queryFn, Decl(intraExpressionInferencesNestedGenericCall1.ts, 128, 32)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>TData : Symbol(TData, Decl(intraExpressionInferencesNestedGenericCall1.ts, 128, 20)) + + onSuccess: (data: TData) => void; +>onSuccess : Symbol(onSuccess, Decl(intraExpressionInferencesNestedGenericCall1.ts, 129, 32)) +>data : Symbol(data, Decl(intraExpressionInferencesNestedGenericCall1.ts, 130, 14)) +>TData : Symbol(TData, Decl(intraExpressionInferencesNestedGenericCall1.ts, 128, 20)) + +}) {} + +export function decorate( +>decorate : Symbol(decorate, Decl(intraExpressionInferencesNestedGenericCall1.ts, 131, 5)) +>TParams : Symbol(TParams, Decl(intraExpressionInferencesNestedGenericCall1.ts, 133, 25)) +>TResult : Symbol(TResult, Decl(intraExpressionInferencesNestedGenericCall1.ts, 133, 51)) + + func: (...params: TParams) => Promise, +>func : Symbol(func, Decl(intraExpressionInferencesNestedGenericCall1.ts, 133, 61)) +>params : Symbol(params, Decl(intraExpressionInferencesNestedGenericCall1.ts, 134, 9)) +>TParams : Symbol(TParams, Decl(intraExpressionInferencesNestedGenericCall1.ts, 133, 25)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>TResult : Symbol(TResult, Decl(intraExpressionInferencesNestedGenericCall1.ts, 133, 51)) + + ...params: TParams +>params : Symbol(params, Decl(intraExpressionInferencesNestedGenericCall1.ts, 134, 49)) +>TParams : Symbol(TParams, Decl(intraExpressionInferencesNestedGenericCall1.ts, 133, 25)) + +): () => Promise { +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>TResult : Symbol(TResult, Decl(intraExpressionInferencesNestedGenericCall1.ts, 133, 51)) + + return () => { + return func(...params); +>func : Symbol(func, Decl(intraExpressionInferencesNestedGenericCall1.ts, 133, 61)) +>params : Symbol(params, Decl(intraExpressionInferencesNestedGenericCall1.ts, 134, 49)) + + }; +} + +type ArbitraryData = { +>ArbitraryData : Symbol(ArbitraryData, Decl(intraExpressionInferencesNestedGenericCall1.ts, 140, 1)) + + property: string; +>property : Symbol(property, Decl(intraExpressionInferencesNestedGenericCall1.ts, 142, 22)) + +}; + +export function getArbitraryData(_id: number): Promise { +>getArbitraryData : Symbol(getArbitraryData, Decl(intraExpressionInferencesNestedGenericCall1.ts, 144, 2)) +>_id : Symbol(_id, Decl(intraExpressionInferencesNestedGenericCall1.ts, 146, 33)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>ArbitraryData : Symbol(ArbitraryData, Decl(intraExpressionInferencesNestedGenericCall1.ts, 140, 1)) + + return Promise.resolve([{ property: "123" }]); +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>property : Symbol(property, Decl(intraExpressionInferencesNestedGenericCall1.ts, 147, 27)) +} + +deferQuery({ +>deferQuery : Symbol(deferQuery, Decl(intraExpressionInferencesNestedGenericCall1.ts, 125, 3)) + + queryFn: decorate(getArbitraryData, 10), +>queryFn : Symbol(queryFn, Decl(intraExpressionInferencesNestedGenericCall1.ts, 150, 12)) +>decorate : Symbol(decorate, Decl(intraExpressionInferencesNestedGenericCall1.ts, 131, 5)) +>getArbitraryData : Symbol(getArbitraryData, Decl(intraExpressionInferencesNestedGenericCall1.ts, 144, 2)) + + onSuccess(data) { +>onSuccess : Symbol(onSuccess, Decl(intraExpressionInferencesNestedGenericCall1.ts, 151, 42)) +>data : Symbol(data, Decl(intraExpressionInferencesNestedGenericCall1.ts, 152, 12)) + + data.forEach((item) => {}); +>data.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>data : Symbol(data, Decl(intraExpressionInferencesNestedGenericCall1.ts, 152, 12)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(intraExpressionInferencesNestedGenericCall1.ts, 153, 18)) + + }, +}); + +const getData = decorate(getArbitraryData, 10); +>getData : Symbol(getData, Decl(intraExpressionInferencesNestedGenericCall1.ts, 157, 5)) +>decorate : Symbol(decorate, Decl(intraExpressionInferencesNestedGenericCall1.ts, 131, 5)) +>getArbitraryData : Symbol(getArbitraryData, Decl(intraExpressionInferencesNestedGenericCall1.ts, 144, 2)) + +deferQuery({ +>deferQuery : Symbol(deferQuery, Decl(intraExpressionInferencesNestedGenericCall1.ts, 125, 3)) + + queryFn: getData, +>queryFn : Symbol(queryFn, Decl(intraExpressionInferencesNestedGenericCall1.ts, 158, 12)) +>getData : Symbol(getData, Decl(intraExpressionInferencesNestedGenericCall1.ts, 157, 5)) + + onSuccess(data) { +>onSuccess : Symbol(onSuccess, Decl(intraExpressionInferencesNestedGenericCall1.ts, 159, 19)) +>data : Symbol(data, Decl(intraExpressionInferencesNestedGenericCall1.ts, 160, 12)) + + data.forEach((item) => {}); +>data.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>data : Symbol(data, Decl(intraExpressionInferencesNestedGenericCall1.ts, 160, 12)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(intraExpressionInferencesNestedGenericCall1.ts, 161, 18)) + + }, +}); + +// https://github.com/microsoft/TypeScript/issues/52114 +export type ActionReducer = (state: State | undefined) => State; +>ActionReducer : Symbol(ActionReducer, Decl(intraExpressionInferencesNestedGenericCall1.ts, 163, 3)) +>State : Symbol(State, Decl(intraExpressionInferencesNestedGenericCall1.ts, 166, 26)) +>state : Symbol(state, Decl(intraExpressionInferencesNestedGenericCall1.ts, 166, 36)) +>State : Symbol(State, Decl(intraExpressionInferencesNestedGenericCall1.ts, 166, 26)) +>State : Symbol(State, Decl(intraExpressionInferencesNestedGenericCall1.ts, 166, 26)) + +export function createReducer( +>createReducer : Symbol(createReducer, Decl(intraExpressionInferencesNestedGenericCall1.ts, 166, 71)) +>State : Symbol(State, Decl(intraExpressionInferencesNestedGenericCall1.ts, 168, 30)) + + initialState: State, +>initialState : Symbol(initialState, Decl(intraExpressionInferencesNestedGenericCall1.ts, 168, 37)) +>State : Symbol(State, Decl(intraExpressionInferencesNestedGenericCall1.ts, 168, 30)) + +): ActionReducer { +>ActionReducer : Symbol(ActionReducer, Decl(intraExpressionInferencesNestedGenericCall1.ts, 163, 3)) +>State : Symbol(State, Decl(intraExpressionInferencesNestedGenericCall1.ts, 168, 30)) + + return {} as any; +} + +export function createFeature(config: { +>createFeature : Symbol(createFeature, Decl(intraExpressionInferencesNestedGenericCall1.ts, 172, 1)) +>State : Symbol(State, Decl(intraExpressionInferencesNestedGenericCall1.ts, 174, 30)) +>config : Symbol(config, Decl(intraExpressionInferencesNestedGenericCall1.ts, 174, 37)) + + reducer: ActionReducer; +>reducer : Symbol(reducer, Decl(intraExpressionInferencesNestedGenericCall1.ts, 174, 46)) +>ActionReducer : Symbol(ActionReducer, Decl(intraExpressionInferencesNestedGenericCall1.ts, 163, 3)) +>State : Symbol(State, Decl(intraExpressionInferencesNestedGenericCall1.ts, 174, 30)) + + selectors: (state: State) => unknown; +>selectors : Symbol(selectors, Decl(intraExpressionInferencesNestedGenericCall1.ts, 175, 32)) +>state : Symbol(state, Decl(intraExpressionInferencesNestedGenericCall1.ts, 176, 14)) +>State : Symbol(State, Decl(intraExpressionInferencesNestedGenericCall1.ts, 174, 30)) + +}) {} + +createFeature({ +>createFeature : Symbol(createFeature, Decl(intraExpressionInferencesNestedGenericCall1.ts, 172, 1)) + + reducer: createReducer(""), +>reducer : Symbol(reducer, Decl(intraExpressionInferencesNestedGenericCall1.ts, 179, 15)) +>createReducer : Symbol(createReducer, Decl(intraExpressionInferencesNestedGenericCall1.ts, 166, 71)) + + selectors: (state) => ({}), +>selectors : Symbol(selectors, Decl(intraExpressionInferencesNestedGenericCall1.ts, 180, 29)) +>state : Symbol(state, Decl(intraExpressionInferencesNestedGenericCall1.ts, 181, 14)) + +}); + +const reducer = createReducer(true); +>reducer : Symbol(reducer, Decl(intraExpressionInferencesNestedGenericCall1.ts, 184, 5)) +>createReducer : Symbol(createReducer, Decl(intraExpressionInferencesNestedGenericCall1.ts, 166, 71)) + +createFeature({ +>createFeature : Symbol(createFeature, Decl(intraExpressionInferencesNestedGenericCall1.ts, 172, 1)) + + reducer, +>reducer : Symbol(reducer, Decl(intraExpressionInferencesNestedGenericCall1.ts, 185, 15)) + + selectors: (state) => ({}), +>selectors : Symbol(selectors, Decl(intraExpressionInferencesNestedGenericCall1.ts, 186, 10)) +>state : Symbol(state, Decl(intraExpressionInferencesNestedGenericCall1.ts, 187, 14)) + +}); + +export {}; + diff --git a/tests/baselines/reference/intraExpressionInferencesNestedGenericCall1.types b/tests/baselines/reference/intraExpressionInferencesNestedGenericCall1.types new file mode 100644 index 0000000000000..fb574ee92d768 --- /dev/null +++ b/tests/baselines/reference/intraExpressionInferencesNestedGenericCall1.types @@ -0,0 +1,646 @@ +//// [tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesNestedGenericCall1.ts] //// + +=== intraExpressionInferencesNestedGenericCall1.ts === +interface FastifyTypeProvider { + readonly input: unknown; +>input : unknown +> : ^^^^^^^ + + readonly output: unknown; +>output : unknown +> : ^^^^^^^ +} + +export interface FastifyTypeProviderDefault extends FastifyTypeProvider {} + +type CallTypeProvider = (F & { +>CallTypeProvider : CallTypeProvider +> : ^^^^^^^^^^^^^^^^^^^^^^ + + input: I; +>input : I +> : ^ + +})["output"]; +type UndefinedToUnknown = [T] extends [undefined] ? unknown : T; +>UndefinedToUnknown : UndefinedToUnknown +> : ^^^^^^^^^^^^^^^^^^^^^ + +interface RouteGenericInterface { + Querystring?: unknown; +>Querystring : unknown +> : ^^^^^^^ +} + +interface FastifySchema { + querystring?: unknown; +>querystring : unknown +> : ^^^^^^^ + + headers?: unknown; +>headers : unknown +> : ^^^^^^^ +} + +interface FastifyRequestType { + query: Querystring; +>query : Querystring +> : ^^^^^^^^^^^ +} + +type ResolveRequestQuerystring< +>ResolveRequestQuerystring : ResolveRequestQuerystring +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + TypeProvider extends FastifyTypeProvider, + SchemaCompiler extends FastifySchema, +> = UndefinedToUnknown< + CallTypeProvider +>; + +interface ResolveFastifyRequestType< + TypeProvider extends FastifyTypeProvider, + SchemaCompiler extends FastifySchema, +> { + query: ResolveRequestQuerystring; +>query : UndefinedToUnknown> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +interface FastifyRequest< + RouteGeneric extends RouteGenericInterface = RouteGenericInterface, + SchemaCompiler extends FastifySchema = FastifySchema, + TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, + RequestType extends FastifyRequestType = ResolveFastifyRequestType< + TypeProvider, + SchemaCompiler + >, +> { + query: RequestType["query"]; +>query : RequestType["query"] +> : ^^^^^^^^^^^^^^^^^^^^ +} + +interface RouteOptions< + RouteGeneric extends RouteGenericInterface, + SchemaCompiler extends FastifySchema, + TypeProvider extends FastifyTypeProvider, +> { + schema?: SchemaCompiler; +>schema : SchemaCompiler | undefined +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ + + onRequest?: ( +>onRequest : ((request: FastifyRequest) => void) | undefined +> : ^^ ^^ ^^^^^ ^^^^^^^^^^^^^ + + request: FastifyRequest, +>request : FastifyRequest> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + ) => void; + method: "GET" | "POST"; +>method : "GET" | "POST" +> : ^^^^^^^^^^^^^^ + + url: string; +>url : string +> : ^^^^^^ + + handler: ( +>handler : (request: FastifyRequest) => void +> : ^ ^^ ^^^^^ + + request: FastifyRequest, +>request : FastifyRequest> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + ) => void; +} + +interface FastifyInstance { + route< +>route : (opts: RouteOptions) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ + + RouteGeneric extends RouteGenericInterface, + SchemaCompiler extends FastifySchema, + >( + opts: RouteOptions, +>opts : RouteOptions +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + ): void; +} + +type Type = { +>Type : Type +> : ^^^^^^^^^^^^ + + _output: Output; +>_output : Output +> : ^^^^^^ + +}; + +declare function string(): Type; +>string : () => Type +> : ^^^^^^ + +interface ZodTypeProvider extends FastifyTypeProvider { + output: this["input"] extends { _output: unknown } +>output : this["input"] extends { _output: unknown; } ? this["input"]["_output"] : never +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>_output : unknown +> : ^^^^^^^ + + ? this["input"]["_output"] + : never; +} + +const verifyAuth = +>verifyAuth : () => (req: T) => void +> : ^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ + + () => +>() => (req: T) => {} : () => (req: T) => void +> : ^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ + + (req: T) => {}; +>(req: T) => {} : (req: T) => void +> : ^ ^^ ^^^^^^^^^ +>req : T +> : ^ + +declare const server: FastifyInstance; +>server : FastifyInstance +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +server.route({ +>server.route({ url: "/config", method: "GET", schema: { querystring: string(), }, onRequest: verifyAuth(), handler: async (req) => { const query: string = req.query; },}) : void +> : ^^^^ +>server.route : (opts: RouteOptions) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>server : FastifyInstance +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>route : (opts: RouteOptions) => void +> : ^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ url: "/config", method: "GET", schema: { querystring: string(), }, onRequest: verifyAuth(), handler: async (req) => { const query: string = req.query; },} : { url: string; method: "GET"; schema: { querystring: Type; }; onRequest: (req: FastifyRequest>) => void; handler: (req: FastifyRequest; }, ZodTypeProvider, ResolveFastifyRequestType; }>>) => Promise; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + url: "/config", +>url : string +> : ^^^^^^ +>"/config" : "/config" +> : ^^^^^^^^^ + + method: "GET", +>method : "GET" +> : ^^^^^ +>"GET" : "GET" +> : ^^^^^ + + schema: { +>schema : { querystring: Type; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ querystring: string(), } : { querystring: Type; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + querystring: string(), +>querystring : Type +> : ^^^^^^^^^^^^ +>string() : Type +> : ^^^^^^^^^^^^ +>string : () => Type +> : ^^^^^^ + + }, + onRequest: verifyAuth(), +>onRequest : (req: FastifyRequest>) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>verifyAuth() : (req: FastifyRequest>) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>verifyAuth : () => (req: T) => void +> : ^ ^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^ + + handler: async (req) => { +>handler : (req: FastifyRequest; }, ZodTypeProvider, ResolveFastifyRequestType; }>>) => Promise +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>async (req) => { const query: string = req.query; } : (req: FastifyRequest; }, ZodTypeProvider, ResolveFastifyRequestType; }>>) => Promise +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>req : FastifyRequest; }, ZodTypeProvider, ResolveFastifyRequestType; }>> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const query: string = req.query; +>query : string +> : ^^^^^^ +>req.query : string +> : ^^^^^^ +>req : FastifyRequest; }, ZodTypeProvider, ResolveFastifyRequestType; }>> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>query : string +> : ^^^^^^ + + }, +}); + +interface Container { + v: V; +>v : V +> : ^ +} + +declare function makeWith(options: { +>makeWith : (options: { readonly lookup: (key: Key) => Value; readonly timeToLive: (exit: Container) => number; }) => [Key, Value] +> : ^ ^^ ^^ ^^ ^^^^^ +>options : { readonly lookup: (key: Key) => Value; readonly timeToLive: (exit: Container) => number; } +> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^ + + readonly lookup: (key: Key) => Value; +>lookup : (key: Key) => Value +> : ^ ^^ ^^^^^ +>key : Key +> : ^^^ + + readonly timeToLive: (exit: Container) => number; +>timeToLive : (exit: Container) => number +> : ^ ^^ ^^^^^ +>exit : Container +> : ^^^^^^^^^^^^^^^^ + +}): [Key, Value]; + +declare function fn(fn: (arg: A) => R): (arg: A) => R; +>fn : (fn: (arg: A) => R) => (arg: A) => R +> : ^ ^^ ^^ ^^ ^^^^^ +>fn : (arg: A) => R +> : ^ ^^ ^^^^^ +>arg : A +> : ^ +>arg : A +> : ^ + +const result1 = makeWith({ +>result1 : [string, string] +> : ^^^^^^^^^^^^^^^^ +>makeWith({ lookup: fn((key: string) => key), timeToLive: () => 10,}) : [string, string] +> : ^^^^^^^^^^^^^^^^ +>makeWith : (options: { readonly lookup: (key: Key) => Value; readonly timeToLive: (exit: Container) => number; }) => [Key, Value] +> : ^ ^^ ^^ ^^ ^^^^^ +>{ lookup: fn((key: string) => key), timeToLive: () => 10,} : { lookup: (arg: string) => string; timeToLive: () => number; } +> : ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + lookup: fn((key: string) => key), +>lookup : (arg: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>fn((key: string) => key) : (arg: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>fn : (fn: (arg: A) => R) => (arg: A) => R +> : ^ ^^ ^^ ^^ ^^^^^ +>(key: string) => key : (key: string) => string +> : ^ ^^ ^^^^^^^^^^^ +>key : string +> : ^^^^^^ +>key : string +> : ^^^^^^ + + timeToLive: () => 10, +>timeToLive : () => number +> : ^^^^^^^^^^^^ +>() => 10 : () => number +> : ^^^^^^^^^^^^ +>10 : 10 +> : ^^ + +}); + +const result2 = makeWith({ +>result2 : [string, string] +> : ^^^^^^^^^^^^^^^^ +>makeWith({ lookup: fn((key: string) => key), timeToLive: (exit) => exit.v.length,}) : [string, string] +> : ^^^^^^^^^^^^^^^^ +>makeWith : (options: { readonly lookup: (key: Key) => Value; readonly timeToLive: (exit: Container) => number; }) => [Key, Value] +> : ^ ^^ ^^ ^^ ^^^^^ +>{ lookup: fn((key: string) => key), timeToLive: (exit) => exit.v.length,} : { lookup: (arg: string) => string; timeToLive: (exit: Container) => number; } +> : ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + lookup: fn((key: string) => key), +>lookup : (arg: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>fn((key: string) => key) : (arg: string) => string +> : ^ ^^^^^^^^^^^^^^^^^^^ +>fn : (fn: (arg: A) => R) => (arg: A) => R +> : ^ ^^ ^^ ^^ ^^^^^ +>(key: string) => key : (key: string) => string +> : ^ ^^ ^^^^^^^^^^^ +>key : string +> : ^^^^^^ +>key : string +> : ^^^^^^ + + timeToLive: (exit) => exit.v.length, +>timeToLive : (exit: Container) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>(exit) => exit.v.length : (exit: Container) => number +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>exit : Container +> : ^^^^^^^^^^^^^^^^^ +>exit.v.length : number +> : ^^^^^^ +>exit.v : string +> : ^^^^^^ +>exit : Container +> : ^^^^^^^^^^^^^^^^^ +>v : string +> : ^^^^^^ +>length : number +> : ^^^^^^ + +}); + +// https://github.com/microsoft/TypeScript/issues/53776 +function deferQuery({}: { +>deferQuery : ({}: { queryFn: () => Promise; onSuccess: (data: TData) => void; }) => void +> : ^ ^^ ^^ ^^^^^^^^^ + + queryFn: () => Promise; +>queryFn : () => Promise +> : ^^^^^^ + + onSuccess: (data: TData) => void; +>onSuccess : (data: TData) => void +> : ^ ^^ ^^^^^ +>data : TData +> : ^^^^^ + +}) {} + +export function decorate( +>decorate : (func: (...params: TParams) => Promise, ...params: TParams) => () => Promise +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^ ^^^^^ + + func: (...params: TParams) => Promise, +>func : (...params: TParams) => Promise +> : ^^^^ ^^ ^^^^^ +>params : TParams +> : ^^^^^^^ + + ...params: TParams +>params : TParams +> : ^^^^^^^ + +): () => Promise { + return () => { +>() => { return func(...params); } : () => Promise +> : ^^^^^^^^^^^^^^^^^^^^^^ + + return func(...params); +>func(...params) : Promise +> : ^^^^^^^^^^^^^^^^ +>func : (...params: TParams) => Promise +> : ^^^^ ^^ ^^^^^ +>...params : unknown +> : ^^^^^^^ +>params : TParams +> : ^^^^^^^ + + }; +} + +type ArbitraryData = { +>ArbitraryData : ArbitraryData +> : ^^^^^^^^^^^^^ + + property: string; +>property : string +> : ^^^^^^ + +}; + +export function getArbitraryData(_id: number): Promise { +>getArbitraryData : (_id: number) => Promise +> : ^ ^^ ^^^^^ +>_id : number +> : ^^^^^^ + + return Promise.resolve([{ property: "123" }]); +>Promise.resolve([{ property: "123" }]) : Promise<{ property: string; }[]> +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Promise.resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } +> : ^^^^^^ ^^^ ^^ ^^ ^^^ ^^^ ^^ ^^ ^^^ ^^^ +>Promise : PromiseConstructor +> : ^^^^^^^^^^^^^^^^^^ +>resolve : { (): Promise; (value: T): Promise>; (value: T | PromiseLike): Promise>; } +> : ^^^^^^ ^^^ ^^ ^^ ^^^ ^^^ ^^ ^^ ^^^ ^^^ +>[{ property: "123" }] : { property: string; }[] +> : ^^^^^^^^^^^^^^^^^^^^^^^ +>{ property: "123" } : { property: string; } +> : ^^^^^^^^^^^^^^^^^^^^^ +>property : string +> : ^^^^^^ +>"123" : "123" +> : ^^^^^ +} + +deferQuery({ +>deferQuery({ queryFn: decorate(getArbitraryData, 10), onSuccess(data) { data.forEach((item) => {}); },}) : void +> : ^^^^ +>deferQuery : ({}: { queryFn: () => Promise; onSuccess: (data: TData) => void; }) => void +> : ^ ^^ ^^ ^^^^^^^^^ +>{ queryFn: decorate(getArbitraryData, 10), onSuccess(data) { data.forEach((item) => {}); },} : { queryFn: () => Promise; onSuccess(data: ArbitraryData[]): void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + queryFn: decorate(getArbitraryData, 10), +>queryFn : () => Promise +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>decorate(getArbitraryData, 10) : () => Promise +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>decorate : (func: (...params: TParams) => Promise, ...params: TParams) => () => Promise +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^ ^^^^^ +>getArbitraryData : (_id: number) => Promise +> : ^ ^^ ^^^^^ +>10 : 10 +> : ^^ + + onSuccess(data) { +>onSuccess : (data: ArbitraryData[]) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>data : ArbitraryData[] +> : ^^^^^^^^^^^^^^^ + + data.forEach((item) => {}); +>data.forEach((item) => {}) : void +> : ^^^^ +>data.forEach : (callbackfn: (value: ArbitraryData, index: number, array: ArbitraryData[]) => void, thisArg?: any) => void +> : ^ ^^^ ^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^ +>data : ArbitraryData[] +> : ^^^^^^^^^^^^^^^ +>forEach : (callbackfn: (value: ArbitraryData, index: number, array: ArbitraryData[]) => void, thisArg?: any) => void +> : ^ ^^^ ^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^ +>(item) => {} : (item: ArbitraryData) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>item : ArbitraryData +> : ^^^^^^^^^^^^^ + + }, +}); + +const getData = decorate(getArbitraryData, 10); +>getData : () => Promise +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>decorate(getArbitraryData, 10) : () => Promise +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>decorate : (func: (...params: TParams) => Promise, ...params: TParams) => () => Promise +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^ ^^^^^ +>getArbitraryData : (_id: number) => Promise +> : ^ ^^ ^^^^^ +>10 : 10 +> : ^^ + +deferQuery({ +>deferQuery({ queryFn: getData, onSuccess(data) { data.forEach((item) => {}); },}) : void +> : ^^^^ +>deferQuery : ({}: { queryFn: () => Promise; onSuccess: (data: TData) => void; }) => void +> : ^ ^^ ^^ ^^^^^^^^^ +>{ queryFn: getData, onSuccess(data) { data.forEach((item) => {}); },} : { queryFn: () => Promise; onSuccess(data: ArbitraryData[]): void; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + queryFn: getData, +>queryFn : () => Promise +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>getData : () => Promise +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + onSuccess(data) { +>onSuccess : (data: ArbitraryData[]) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>data : ArbitraryData[] +> : ^^^^^^^^^^^^^^^ + + data.forEach((item) => {}); +>data.forEach((item) => {}) : void +> : ^^^^ +>data.forEach : (callbackfn: (value: ArbitraryData, index: number, array: ArbitraryData[]) => void, thisArg?: any) => void +> : ^ ^^^ ^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^ +>data : ArbitraryData[] +> : ^^^^^^^^^^^^^^^ +>forEach : (callbackfn: (value: ArbitraryData, index: number, array: ArbitraryData[]) => void, thisArg?: any) => void +> : ^ ^^^ ^^^^^^^^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^ +>(item) => {} : (item: ArbitraryData) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>item : ArbitraryData +> : ^^^^^^^^^^^^^ + + }, +}); + +// https://github.com/microsoft/TypeScript/issues/52114 +export type ActionReducer = (state: State | undefined) => State; +>ActionReducer : ActionReducer +> : ^^^^^^^^^^^^^^^^^^^^ +>state : State | undefined +> : ^^^^^^^^^^^^^^^^^ + +export function createReducer( +>createReducer : (initialState: State) => ActionReducer +> : ^ ^^ ^^ ^^^^^ + + initialState: State, +>initialState : State +> : ^^^^^ + +): ActionReducer { + return {} as any; +>{} as any : any +>{} : {} +> : ^^ +} + +export function createFeature(config: { +>createFeature : (config: { reducer: ActionReducer; selectors: (state: State) => unknown; }) => void +> : ^ ^^ ^^ ^^^^^^^^^ +>config : { reducer: ActionReducer; selectors: (state: State) => unknown; } +> : ^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^ + + reducer: ActionReducer; +>reducer : ActionReducer +> : ^^^^^^^^^^^^^^^^^^^^ + + selectors: (state: State) => unknown; +>selectors : (state: State) => unknown +> : ^ ^^ ^^^^^ +>state : State +> : ^^^^^ + +}) {} + +createFeature({ +>createFeature({ reducer: createReducer(""), selectors: (state) => ({}),}) : void +> : ^^^^ +>createFeature : (config: { reducer: ActionReducer; selectors: (state: State) => unknown; }) => void +> : ^ ^^ ^^ ^^^^^^^^^ +>{ reducer: createReducer(""), selectors: (state) => ({}),} : { reducer: ActionReducer; selectors: (state: string) => {}; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ + + reducer: createReducer(""), +>reducer : ActionReducer +> : ^^^^^^^^^^^^^^^^^^^^^ +>createReducer("") : ActionReducer +> : ^^^^^^^^^^^^^^^^^^^^^ +>createReducer : (initialState: State) => ActionReducer +> : ^ ^^ ^^ ^^^^^ +>"" : "" +> : ^^ + + selectors: (state) => ({}), +>selectors : (state: string) => {} +> : ^ ^^^^^^^^^^^^^^^ +>(state) => ({}) : (state: string) => {} +> : ^ ^^^^^^^^^^^^^^^ +>state : string +> : ^^^^^^ +>({}) : {} +> : ^^ +>{} : {} +> : ^^ + +}); + +const reducer = createReducer(true); +>reducer : ActionReducer +> : ^^^^^^^^^^^^^^^^^^^^^^ +>createReducer(true) : ActionReducer +> : ^^^^^^^^^^^^^^^^^^^^^^ +>createReducer : (initialState: State) => ActionReducer +> : ^ ^^ ^^ ^^^^^ +>true : true +> : ^^^^ + +createFeature({ +>createFeature({ reducer, selectors: (state) => ({}),}) : void +> : ^^^^ +>createFeature : (config: { reducer: ActionReducer; selectors: (state: State) => unknown; }) => void +> : ^ ^^ ^^ ^^^^^^^^^ +>{ reducer, selectors: (state) => ({}),} : { reducer: ActionReducer; selectors: (state: boolean) => {}; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ + + reducer, +>reducer : ActionReducer +> : ^^^^^^^^^^^^^^^^^^^^^^ + + selectors: (state) => ({}), +>selectors : (state: boolean) => {} +> : ^ ^^^^^^^^^^^^^^^^ +>(state) => ({}) : (state: boolean) => {} +> : ^ ^^^^^^^^^^^^^^^^ +>state : boolean +> : ^^^^^^^ +>({}) : {} +> : ^^ +>{} : {} +> : ^^ + +}); + +export {}; + diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts b/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts index 6d23f571d41f3..988529c883fec 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts @@ -331,3 +331,26 @@ const distantRes = distant({ }, consumer: (val) => {}, }); + +type ErrorFn = (error: unknown) => void; + +declare const genericFn: (args: { + parser: (p: unknown, errorFn: ErrorFn) => T; + handler: (data: { body: T }) => unknown; +}) => T; + +declare const createParser: (arg: T) => (p: unknown, errorFn: ErrorFn) => T; + +genericFn({ + parser: createParser(1 as const), + handler: ({ body: _ }) => {}, +}); + +declare const genericFnTuple: ( + args: [ + parser: (p: unknown, errorFn: ErrorFn) => T, + handler: (data: { body: T }) => unknown + ] +) => T; + +genericFnTuple([createParser(1 as const), ({ body: _ }) => {}]); diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.tsx b/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.tsx index 4ecd4f9e4b62f..63886451a8112 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.tsx +++ b/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.tsx @@ -110,3 +110,16 @@ function Foo(props: Props) { a: (x) => 10, b: (arg) => { arg.toString(); }, }} />; + +type ErrorFn = (error: unknown) => void; + +function GenericComp(props: { + parser: (p: unknown, errorFn: ErrorFn) => T; + handler: (data: { body: T }) => unknown; +}) { + return null; +} + +declare const createParser: (arg: T) => (p: unknown, errorFn: ErrorFn) => T; + + {}} />; diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesNestedGenericCall1.ts b/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesNestedGenericCall1.ts new file mode 100644 index 0000000000000..27d62fcffee65 --- /dev/null +++ b/tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesNestedGenericCall1.ts @@ -0,0 +1,195 @@ +// @strict: true +// @lib: esnext +// @noEmit: true + +interface FastifyTypeProvider { + readonly input: unknown; + readonly output: unknown; +} + +export interface FastifyTypeProviderDefault extends FastifyTypeProvider {} + +type CallTypeProvider = (F & { + input: I; +})["output"]; +type UndefinedToUnknown = [T] extends [undefined] ? unknown : T; + +interface RouteGenericInterface { + Querystring?: unknown; +} + +interface FastifySchema { + querystring?: unknown; + headers?: unknown; +} + +interface FastifyRequestType { + query: Querystring; +} + +type ResolveRequestQuerystring< + TypeProvider extends FastifyTypeProvider, + SchemaCompiler extends FastifySchema, +> = UndefinedToUnknown< + CallTypeProvider +>; + +interface ResolveFastifyRequestType< + TypeProvider extends FastifyTypeProvider, + SchemaCompiler extends FastifySchema, +> { + query: ResolveRequestQuerystring; +} + +interface FastifyRequest< + RouteGeneric extends RouteGenericInterface = RouteGenericInterface, + SchemaCompiler extends FastifySchema = FastifySchema, + TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, + RequestType extends FastifyRequestType = ResolveFastifyRequestType< + TypeProvider, + SchemaCompiler + >, +> { + query: RequestType["query"]; +} + +interface RouteOptions< + RouteGeneric extends RouteGenericInterface, + SchemaCompiler extends FastifySchema, + TypeProvider extends FastifyTypeProvider, +> { + schema?: SchemaCompiler; + onRequest?: ( + request: FastifyRequest, + ) => void; + method: "GET" | "POST"; + url: string; + handler: ( + request: FastifyRequest, + ) => void; +} + +interface FastifyInstance { + route< + RouteGeneric extends RouteGenericInterface, + SchemaCompiler extends FastifySchema, + >( + opts: RouteOptions, + ): void; +} + +type Type = { + _output: Output; +}; + +declare function string(): Type; + +interface ZodTypeProvider extends FastifyTypeProvider { + output: this["input"] extends { _output: unknown } + ? this["input"]["_output"] + : never; +} + +const verifyAuth = + () => + (req: T) => {}; + +declare const server: FastifyInstance; + +server.route({ + url: "/config", + method: "GET", + schema: { + querystring: string(), + }, + onRequest: verifyAuth(), + handler: async (req) => { + const query: string = req.query; + }, +}); + +interface Container { + v: V; +} + +declare function makeWith(options: { + readonly lookup: (key: Key) => Value; + readonly timeToLive: (exit: Container) => number; +}): [Key, Value]; + +declare function fn(fn: (arg: A) => R): (arg: A) => R; + +const result1 = makeWith({ + lookup: fn((key: string) => key), + timeToLive: () => 10, +}); + +const result2 = makeWith({ + lookup: fn((key: string) => key), + timeToLive: (exit) => exit.v.length, +}); + +// https://github.com/microsoft/TypeScript/issues/53776 +function deferQuery({}: { + queryFn: () => Promise; + onSuccess: (data: TData) => void; +}) {} + +export function decorate( + func: (...params: TParams) => Promise, + ...params: TParams +): () => Promise { + return () => { + return func(...params); + }; +} + +type ArbitraryData = { + property: string; +}; + +export function getArbitraryData(_id: number): Promise { + return Promise.resolve([{ property: "123" }]); +} + +deferQuery({ + queryFn: decorate(getArbitraryData, 10), + onSuccess(data) { + data.forEach((item) => {}); + }, +}); + +const getData = decorate(getArbitraryData, 10); +deferQuery({ + queryFn: getData, + onSuccess(data) { + data.forEach((item) => {}); + }, +}); + +// https://github.com/microsoft/TypeScript/issues/52114 +export type ActionReducer = (state: State | undefined) => State; + +export function createReducer( + initialState: State, +): ActionReducer { + return {} as any; +} + +export function createFeature(config: { + reducer: ActionReducer; + selectors: (state: State) => unknown; +}) {} + +createFeature({ + reducer: createReducer(""), + selectors: (state) => ({}), +}); + +const reducer = createReducer(true); +createFeature({ + reducer, + selectors: (state) => ({}), +}); + +export {};