Skip to content

Autocompletion is working in TS 4.7 to 4.9 but broken/gone in TS 5 #53475

New issue

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

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

Already on GitHub? # to your account

Closed
jgoux opened this issue Mar 23, 2023 · 3 comments · Fixed by #53481
Closed

Autocompletion is working in TS 4.7 to 4.9 but broken/gone in TS 5 #53475

jgoux opened this issue Mar 23, 2023 · 3 comments · Fixed by #53481

Comments

@jgoux
Copy link

jgoux commented Mar 23, 2023

Bug Report

🔎 Search Terms

autocompletion

🕗 Version & Regression Information

  • This changed between versions ^4.7.0 and ^5
  • I was unable to test this on prior versions because some type features such as string literal manipulation are not available before 4.7

⏯ Playground Link

Playground link with relevant code

💻 Code

Please go to the end of the code and try the defineConfig function:

defineConfig({
  exclude: {
    data: ["<cursor here, ctrl+space>"],
    structure: {
      schemas: ["secret", "<cursor here, ctrl+space>"],
      tables: ["<cursor here, ctrl+space>"]
    }
  }
})

🙁 Actual behavior

Between TS 4.7 and 4.9, we have autocompletion available for all array values under the exclude key
At TS 5 and above (I tried nightly as well), the autocompletion is gone

🙂 Expected behavior

The autocompletion should work the same as with TS 4.7 and 4.9

@Andarist
Copy link
Contributor

Could you specify what exact completions you expect at given positions? I'm guessing that string completions are broken here (although some work in extensions). On top of that, I can see some inconsistencies between string completions and regular ones (in 4.9 as well)

@Andarist
Copy link
Contributor

This was broken by this PR of mine although I've hoped to fix its regressions with #52875 . Gonna have to investigate what is different about this one here.

@jgoux
Copy link
Author

jgoux commented Mar 23, 2023

@Andarist As exclude.data, exclude.structure.schemas and exclude.structure.tables are the generics I need to pick up, when the array is empty it's typed as never[] | undefined, so the normal autocompletion is not working in both 4.9 and 5 (I think there is no way I can make it works, or I'm too dumb to figure it out 😄).
But if I use quotes in those like "<cursor here, ctrl+space>" it works in 4.9 but not in 5.
What's even stranger is that in 5, if you do ""<cursor here, ctrl+space> (so the cursor after the empty quotes) it will provide autocompletion.

Edit: It seems like introducing an item that isn't part of the expected union switch the type of the array to the union itself so the autocompletion works:
image

The empty string being "wrong", works in both 4.9 and 5:
image

The only difference between 4.9 and 5 then it's that the suggestions are showing when the cursor is between the quotes ["<cursor, ctrl+space>"], but not anymore in 5.

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

Successfully merging a pull request may close this issue.

2 participants