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

Showing proper suggestion for function props. #2606

Open
HighFunctioningSociopathSH opened this issue Nov 25, 2024 · 2 comments
Open

Showing proper suggestion for function props. #2606

HighFunctioningSociopathSH opened this issue Nov 25, 2024 · 2 comments

Comments

@HighFunctioningSociopathSH

Describe the problem

When passing a function prop to a component that uses typescript, typescript will show an extra suggestion as an autocomplete for the method as it would do for normal TS objects but this doesn't make sense for Svelte components.
image
Note that this extra suggestion only shows up if you start typing without first manually popping the suggestions up (pressing CTRL + Space).

Describe the proposed solution

I was wondering if there is anyway to change this to either show a proper autocomplete suggestion for Svelte components like:
image
Or to not show that default typescript extra suggestion at all.

I wouldn't mind writing an extra property like I did in the top image, but what annoys me is that extra typescript suggestion which makes the suggestions look like this:
image

I'm not aware if this default behavior of typescript can be disabled or not, but since its used pretty often during development it can be a bit annoying.

Importance

nice to have

@dummdidumm dummdidumm transferred this issue from sveltejs/svelte Nov 25, 2024
@jasonlyu123
Copy link
Member

jasonlyu123 commented Nov 30, 2024

I tried it and it is possible to rewrite it to an inline handler. But I am not really sure if it is useful enough or if it is more of an extra noise and we should just filter it out.

  1. This isn't always suggested due to some problem with the source mapping of generated code. Some people might rarely see it because of how they usually type out the attribute.
  2. Arrow function can have various forms. Different use cases and preferences can lead to very different results. Is it really useful enough to have it? Like sometimes I might not care about the parameter or don't want a block for the arrow function body. Removing the stuff I don't want might cause the same time as typing out the whole thing by hand.

@HighFunctioningSociopathSH
Copy link
Author

You have a point there. One other thing I noticed is that unless you can detect if the typescript suggestion is being shown for the component itself and not a variable that is assigned the component's props type in the script tag, removing the suggestion entirely also doesn't make sense. In other words, users might like that default suggestion when they are creating their props with typescript.
image
In the above case, typescript's suggestion makes sense.

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

No branches or pull requests

2 participants