Skip to content

Code completion stopped working for a few scenarios in typescript 5.1 #54710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pedrodurek opened this issue Jun 19, 2023 · 1 comment · Fixed by #54714
Closed

Code completion stopped working for a few scenarios in typescript 5.1 #54710

pedrodurek opened this issue Jun 19, 2023 · 1 comment · Fixed by #54714

Comments

@pedrodurek
Copy link

pedrodurek commented Jun 19, 2023

Bug Report

Scenario 1: Code completion stopped working by adding an undefined as the default value for the generic type. TypeScript narrows down the range of expected argument types, and as a result, the code completion doesn't work correctly. It works fine in Typescript 5.0 or below.

Scenario 2: Code completion stopped when using an overloaded function type that combines union types with named tuples containing a generic type parameter. it works fine in Typescript 5.0 or below.

🔎 Search Terms

Code completion issues in typescript 5.1

🕗 Version & Regression Information

The Issue started occurring on typescript 5.1 and beyond. It works fine in versions 5.0 or below.

⏯ Playground Link

Scenario 1: https://tsplay.dev/w1xZGW
Scenario 2: https://tsplay.dev/WKvGZm

💻 Code

Scenario 1:

declare function func<
  const T extends 'a' | 'b' | undefined = undefined,
>(arg?: T): string;

// Code completion does not work
func('')

Scenario 2:

interface Func {
  <Key extends 'a' | 'b'>(
    ...args:
      | [key: Key, options?: any]
      | [key: Key, defaultValue: string, options?: any]
  ): string;
}

declare const func: Func;

// Code completion does not work
func('');

🙁 Actual behavior

Code completion doesn't work

🙂 Expected behavior

Code completion should work as in the images below:

Screenshot 2023-06-19 at 2 20 43 PM Screenshot 2023-06-19 at 2 21 31 PM
@pedrodurek pedrodurek changed the title Code completion stopped working for a few scenarios after typescript 5.1 Code completion stopped working for a few scenarios in typescript 5.1 Jun 19, 2023
@Andarist
Copy link
Contributor

Both are already fixed by #54588 and that PR is being cherry-picked into 5.1 release line here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants