Repository: TypeScript
Issue: Callback parameter inference not working when part of an inferred tuple type
Labels: Bug,Help Wanted

# Bug Report

Been experiencing the below problem with `no-implicit-any` on callback parameter types, when the callback is part of a tuple function-argument, whose type I am inferring.

Was thinking it could be a case of unsupported/incorrect usage on my end, however the type suggestion does appear to be correct on-mouse-hover, so wondering if there's something extra at play.

Might be somewhat related to https://github.com/microsoft/TypeScript/issues/44476 but not sure.

### 🔎 Search Terms

Tuple, callback, generic, inference

### 🕗 Version & Regression Information

This is the behavior in every version I tried since 4.0 that brought support for variadic tuples, and I reviewed the FAQ for entries about generics/tuples/callbacks

### ⏯ Playground Link

[Playground link with relevant code](https://www.typescriptlang.org/play?ts=5.0.0-dev.20221229#code/C4TwDgpgBA8mwEsD2A7AzgHgCpQLxQFcUBrFJAdxQD48oBvAKCigRTAOABEBDYbgLihYA3EygALbigAmAGwgAnQQApggrAEo8NAG5IE0hgF8GDAGZEAxolRQzSJAHUEwcQElgEALbZaRUhTUygBG3Eqw8Mjo2FRajMwKEMAECijGpgD0GVAACtxoaBBoUKCQALSW4hCWxFD5UBAAHpDWEIb2Ti7unl7K8SxsHDx8ggDkaMAKrADmowA0YpIy8uHKjYITUyjTWrg0dCZGGpnZAGLcCLLFpRAVVTV1xU0tnu0Ozq4e3n1irOxcvAEUHGkxm80WUjkihU6ygKAIXmCil2+0OxxOUAAgsF5CUkAMzIpHg1mtVXuZ3l0vr1+n8hoCxpswQtmEsoatGij6GjTDcoABReReOA2aJYGj4HBNTwyYp0Ab-YZA1iEhRQAAaUCMUAA-BFRZh1TRBCgIDpFLzwNAsAQwPIRVFMGIpY0ZdJilIQABtAC6CwlQhJbuKXpVRMF3h9Yj1XojwsiqEwcaoUeY6lMFhQ1iidkprhtdogvmlEFldRQ3p9VBCYUEiW40lQshAUC9ADoOwX7QmxSm4mJEslUukGFlcvlCtcrXdqrV6s8yW0KZ187b5MovbTBgCRsCmdtwazISsYRtQdsuQdjD70WPzpcp+VKrPiQvWm8V+IuxAN1vFQy93PWYWQkY9oSgNYTQRJEFEvQ4b1MUdsgACQoM0iSIbgcWgYB8TDBRlw+L81x-Tdfm3JVGSAw8oDHPIFG4LwkiJUZGlGFgvDtBBLBcZtQI9FBgU9dibjbMQx3QwTXCQAhpnECQkHNLZpigRSiQAAzZFZ1KgSwkAURJrD42QsIgK4WGAYlNLA1Y1Cgfcdm0KA9AMdSIWWcC1jg69jiAA)

(for context, if the above example feels a bit contrived: the actual use-case involves typing/checking a function argument that can be a variadic tuple with multiple complex elements, using a more complex utility type. If interested [here's a second playground link](https://www.typescriptlang.org/play?#code/C4TwDgpgBA8mwEsD2A7AzgHgCpQLxQFcUBrFJAdxQBooBVPQksygPgYG8AoKKBFMAsAAiAQ2AiAjAC4oWANzcoACxEoAJgBsIAJxkAKYDKwBKPGwBuSBGsV8BwsSIBMAfhm0FAX06cAZkQBjRFQoXyQkAHUEYCUASWAIAFtsGloWPQAjEV1YeGR0FLoWUy4ebQhgAm0UTm9OAHp6qAAFETQ0CDQoUEgAWgClCADiKDaoCAAPSCCIGzDI6LiExL1S3n5BUXFpKAByNGBtPgBzXapFFXUtHL0JmQOjlGPTXDZ2b09jH0aoADERBAaLo9CD9QbDUZdSbTBJzcJRGLxJKrWwbBzbGT7Q4nM4XVSaHT6O5QFAERIZHQvN4fL7fJoAQQyWm6SHWvh0kPGUyGsL88MWSJWazsm0cOyxj1O5x4lwJNwmVKg71qtJBUAAolpEnBggUsGx8DhJgl1F0dflMHx2dooAANGhWjkATTYLlyusw9qgLqgMhQEHMOh8aqwBDAWnNqEwiiNExNai6qhAAG0ALrSqAAJU6BA0wC58cTKBTqYYafOBtkBYgpqgacUbvrPCM1drycdNoAEhARGpUw26wA6YfZtC54A0TVJSMFbu9lj95tV401hN1jtQOdqGjDwcbrAAjSLqBu0PhiAzzDJ3cHwHpocjnN5yday8YLcLliKIw+fwoIL5KE-IxGeWjYK2a5Jmm6RZDk5S9qgGggA+g6gReeRRtgC4lIo5SVNUtR0i0bQdMC4CggMQwjGM0I8rMfILCBYZaHoybCmiWySJiDw4hmsrXES9zYk8irKp4qa0j8-yAmRfSURCNHcjMcKMUoaGsex9iceKPFPLiMr4gJUC3H6ZIUtookfBJPgNE0nYUAGHJECITLQMArIdgxCJqcxEAaaiWlitxwlSooPytNoIiJBUHK7BMuy8Ik4YIAE0RIcoYyqHsSYJSCg5hU0jkoN0ShIAQxxKMoSCBpKUDVRyAAG-E6A1UABEg2jlEE6UaC5EBArw+ZjE1hmEsZhhQLpzxmFAljWA1eJXGNtyWbU1lAA) with the whole shebang - but in the first one I've tried to pare it down to the most basic example with just 1 element on the tuple)

### 💻 Code

<!-- Please post the relevant code sample here as well-->
```ts

type Options<T = unknown> = {
  inputData: T;
  handler: (t: T) => void
}

type ElemOptions<T> = T extends { inputData: infer X } ? Options<X> : never

type TupleOptions<
  T extends any[],
> = T extends [infer Elem]
  ? [ElemOptions<Elem>]
  : T
  
function fooWithTuple<T extends any[]>(bar: readonly [...TupleOptions<T>]) {
  return
}

fooWithTuple([{
  inputData: 'string',
  // Error: Parameter 'x' implicitly has an 'any' type.
  // even though hovering over `handler` correctly labels it as `handler: (t: string) => void`
  handler: (x) => {}
}])

// included in the playground link but not shown here:
//  (1) type-inference all works fine when you're not dealing with a tuple, and
//  (2) type-checking in a tuple works correctly when you add the param type explicitly

```

### 🙁 Actual behavior

Handler complains about no-implicit-any, even though type-suggestion work as expected, and type-checking works if you add the param type explicitly.

### 🙂 Expected behavior

Handler parameter type can be inferred automatically; no no-implicit-any complaints.