Skip to content

StyleProps are not considered as props and dashed props doesn't autocomplete properly #1743

@paoloricciuti

Description

@paoloricciuti

Describe the bug

I have a component where i define the $$Props type like this

<script lang="ts">
  export let text: string;

  type $$Props = {
    text: string;
    "--bg": string;
  };
</script>

<p>{text}</p>

<style>
  p {
    background-color: var(--bg);
  }
</style>

this is to provide autocompletion for the --bg css variable in the parent component. This actually works but there are a couple of problems:

  1. The autocomplete it's actually there but when you press enter it autocompletes with the quotes around giving you errors:
    image image
  2. When you remove the strings it still gives you an error because it's not actually a props being passed (this is probably because it actually get's de-sugared to a div with a style props around the component
    image

Reproduction

  1. clone https://github.com/paoloricciuti/typescript-styleprops-bug
  2. observe that the Child component used in +page.svelte errors out

Expected behaviour

  1. The autocomplete should not include the strings when a dash is present in the name.
  2. The props should also be recognized as a correct prop passed to the component.

System Info

  • OS: Windows
  • IDE: VSCode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

I guess this is for the Svelte for VSCode extension but it could also be a language-server issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions