I have function that takes list of tuples, I want to make second tuple element’s type dependent on the first

type Tuple<T> = [
  Foo<T> | Bar<T>,
  T // I want to have different type here, depending on whether first element is Foo or Bar,
    // How do I do that?
type ListOfTuples<T> = [Tuple<T>, ...Tuple<T>[]]

function thatWorksWithListOfTuples<T>(lst: ListOfTuples<T>) {
  // ...
john Asked question May 13, 2021