microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.7k stars 12.45k forks source link

TypeScript Intellisense Issue: Autocomplete Not Recognizing Numeric String Literal Types #60220

Open tylim88 opened 3 days ago

tylim88 commented 3 days ago

🔎 Search Terms

generic autocomplete numeric string

🕗 Version & Regression Information

TypeScript Version: 5.6.3

⏯ Playground Link

https://www.typescriptlang.org/play/?exactOptionalPropertyTypes=false&ts=5.6.3#code/MYewdgzgLgBAhgXgDwBUYFMAeV1gCYQwDkAjEQD5FwDWAbhUSAOYBGDATJ0QHwAUAlAm4BvAL4AoUJFgsEcJER5A

💻 Code

const a=<T extends '1'|'akv'|'ogb'|'222'>()=>{}
const b=a<''> // try the autocomplete here

🙁 Actual behavior

Autocomplete suggestions include all possible string values, ignoring the specific string literals in the constraint. This behavior diminishes the effectiveness of the autocompletion feature, as shown in the attached screenshot.Image

🙂 Expected behavior

Autocomplete should provide suggestions only for the specific string literals defined in the type constraint ('1', 'akv', 'ogb', '222') without additional unrelated strings.

Additional information about the issue

No response

Andarist commented 3 days ago

Duplicate of https://github.com/microsoft/TypeScript/issues/52898