Microsoft/TypeScript

Type where type of second tuple item is dependent on the type of the first doesn't get filtered completion lists after the first item has been entered

Open

#49.711 geöffnet am 28. Juni 2022

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
Domain: LS: Completion ListsExperience EnhancementHelp WantedSuggestion

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

Bug Report

🔎 Search Terms

recursive tuples the joint type

🕗 Version & Regression Information

"typescript": "4.6.4"

⏯ Playground Link

Playground link with relevant code

💻 Code


type Item = {
  a: {
    b: 2;
    c: boolean;
  };
  d: {
    e: 3
  }
  f: 1;
}

type GetKeys<T> = {
  [K in keyof T]: [K, ...(T[K] extends object ? GetKeys<T[K]> : [])]
}[keyof T]

type To<T> = {
  index: GetKeys<T>; // Looking forward to ['a', 'b'] | ['a', 'c'] | ['d', 'e'] | ['f']
}

const obj: To<Item> = {
  index: ['d', 'e'], // Parameter 2 Prompt b | c | e | f Expected to prompt e
}

🙁 Actual behavior

obj.index Parameter 2 Prompt b | c | e | f

🙂 Expected behavior

Expected to prompt e

Contributor Guide