sveltejs / language-tools

The Svelte Language Server, and official extensions which use it
MIT License
1.18k stars 189 forks source link

VSCode suggestions only shows the default value of a generic prop when one is supplied #2358

Open HighFunctioningSociopathSH opened 2 months ago

HighFunctioningSociopathSH commented 2 months ago

Describe the bug

When using a generic in a component, vscode suggestion list only shows the default value of the generic instead of what it extends.

Reproduction

Test.svelte

<script lang="ts" generics="Element extends keyof HTMLElementTagNameMap = 'div'">
  let { element, ...restProps }: { element?: Element } = $props();
</script>

+page.svelte

<script lang="ts">
  import Test from "$components/Test/Test.svelte";
</script>

<Test element=""></Test>

image

Expected behaviour

Here's what it's supposed to suggest: Test.svelte

<script lang="ts" generics="Element extends keyof HTMLElementTagNameMap">
  let { element, ...restProps }: { element?: Element } = $props();
</script>

+page.svelte

<script lang="ts">
  import Test from "$components/Test/Test.svelte";
</script>

<Test element=""></Test>

When using the above code the following result is shown. image

System Info

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

jasonlyu123 commented 1 month ago

Upstream issue https://github.com/microsoft/TypeScript/issues/52516