Microsoft/TypeScript

IntelliSense autocomplete doesn't provide suggestions for contextual types in nested functions

Open

#50.478 geöffnet am 26. Aug. 2022

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
Experience 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

intellisense autocomplete nested

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about intellisense.

⏯ Playground Link

Playground link with relevant code

💻 Code

// EXAMPLE

declare function create<T extends 'foo' | 'bar'>(value: T): T;

declare function a<T>(value: T): T;
declare function b<T>(value: T): T;

// autocomplete works
create(a('foo'));

// autocomplete doesn't work
create(a(b('foo')));

// PARTIAL WORKAROUND

type NoInfer<T> = T extends infer U ? U : never;

declare function a2<T>(value: NoInfer<T>): T;

// autocomplete works but type becomes unknown
create(a2(b('foo')));

🙁 Actual behavior

When functions are nested the types flow through and are checked correctly but autocomplete doesn't provide suggestions.

🙂 Expected behavior

I would like autocomplete to provide suggestions for arguments in nested functions, based on the underlying return type. My actual use case involves more complex functions that are used to build nested objects.

Contributor Guide