Skip to content
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

Code comlpetion not working for variables #54654

Closed
Ilyat1337 opened this issue Jun 15, 2023 · 7 comments Β· Fixed by #54656
Closed

Code comlpetion not working for variables #54654

Ilyat1337 opened this issue Jun 15, 2023 · 7 comments Β· Fixed by #54656
Labels
Bug A bug in TypeScript Help Wanted You can do this

Comments

@Ilyat1337
Copy link

Bug Report

πŸ”Ž Search Terms

Completion, IntelliSense

πŸ•— Version & Regression Information

Tested in 'Nightly' version - the problem is not fixed.

  • This changed between versions 5.0.4 and 5.1.3

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

let foo: number = 1
fo

πŸ™ Actual behavior

Completion list ater fo does not contain foo item.

πŸ™‚ Expected behavior

Completion list ater fo contains foo item.

@Andarist
Copy link
Contributor

Andarist commented Jun 15, 2023

This has been changed in [email protected] so the likely culprit is #52690 (new commits included in this version can be seen on this diff), cc @zardoy

@zardoy
Copy link
Contributor

zardoy commented Jun 15, 2023

Thank you so much for the mention! I checked this and you're totally right. I was also annoyed with this recently, but didn't know that PR is culprit. It happens because you don't have semicolon and contextToken is numeric literal 1 (so here code thinks you're inside of variable declaration for some reason) though I'm looking at #52690 (comment) and it seems we just didn't have such test

@fatcerberus
Copy link

Huh, odd - you'd expect that ASI would kick in and have the parser act as if there's a semicolon after the 1

@svipas
Copy link

svipas commented Jul 18, 2023

@DanielRosenwasser @zardoy @RyanCavanaugh issue still exists:

const obj = {
  name: '',
} as const // <- missing semicolon
image

If I add ; (semicolon) it starts to work:

const obj = {
  name: '',
} as const; // <- added semicolon
image

TS Version: 5.2.0-dev.20230717 and same with 5.1.6
Playground: https://www.typescriptlang.org/play?ts=5.1.6#code/MYewdgzgLgBCBGArGBeGBvAUDGYCGAtgKYBcMA5OQDSYC+MeEMoksA9GzAIIAmPMAbgZh+AS1gB3EACcA1hEyYgA

@svipas
Copy link

svipas commented Jul 18, 2023

@RyanCavanaugh @DanielRosenwasser Let me know if I should open a new issue or we re-open this one

@zardoy
Copy link
Contributor

zardoy commented Jul 18, 2023

@svipas I don't think it is related to this issue. This issue is about regression that started to happen from 5.1.x and was patched in 5.1.6. But your issue is happening in 5.0 and in older version as well.

The root of the issue is the same as in #54729 completions are being blocked in that position

@svipas
Copy link

svipas commented Jul 18, 2023

Thanks @zardoy, you're right. I wrote a comment in your issue to include this case as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants