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

Overly aggressive autocomplete with arrow function parameter names #17055

Closed
danvk opened this issue Dec 7, 2022 · 1 comment · Fixed by #17225
Closed

Overly aggressive autocomplete with arrow function parameter names #17055

danvk opened this issue Dec 7, 2022 · 1 comment · Fixed by #17225
Assignees
Labels
bug Something isn't working correctly lsp related to the language server node compat

Comments

@danvk
Copy link
Contributor

danvk commented Dec 7, 2022

Describe the bug

Typing a , in this context adds the top autocomplete suggestion and auto-imports it:

image

This is the result after I hit the , key:
image

This is bad on a few levels:

  1. There's no reason for Deno to think I want to name my function parameter xor instead of x, which is what I typed.
  2. That auto-import is crazy and breaks at runtime.

To Reproduce

  1. Write an arrow function that takes multiple parameters.
  2. Type , after the first parameter
  3. Observe that the first autocomplete suggestion is used.

Expected behavior

If I type (x, i) => to define an arrow function, I expect it to come out as (x, i) => rather than (xor, i) =>.

Screenshots

image

image

Here's the code from the screenshots:

declare let num: number[];

const squares = num.map((x

The xor symbol is coming from lodash, which I've imported in a deps.ts file:

// deps.ts

// @deno-types="npm:@types/lodash"
import {default as ld} from "npm:lodash";
export const _ = ld;

TypeScript alone doesn't seem to have this issue -- I can't reproduce it on the TypeScript playground and have never run into this in non-Deno TypeScript in VS Code.

Versions

  • vscode: 1.72.1
  • deno: deno 1.28.3 (release, aarch64-apple-darwin) / v8 10.9.194.5 / typescript 4.8.3
  • extension: v3.14.1
@dsherret dsherret transferred this issue from denoland/vscode_deno Dec 15, 2022
@dsherret dsherret added bug Something isn't working correctly lsp related to the language server node compat labels Dec 15, 2022
@dsherret
Copy link
Member

Small reproduction:

const xor = () => {};

const squares = num.map((

Then type x, at the end of that.

Two issues here:

  1. We shouldn't be doing auto-import suggestions using a relative path to the npm cache.
  2. The deno language server does seem super aggressive compared to the regular typescript lanuage server. The above doesn't fill in xor when using typescript's.

As a sidenote, the reason it does completions in this case, is because typescript thinks that's a parenthesized expression rather than an arrow function parameter list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly lsp related to the language server node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants