Skip to content

Astro doesn't aware about svelte props #14681

@Leniorko

Description

@Leniorko

What version of astro are you using?

2.8.3

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm

What operating system are you using?

Linux

What browser are you using?

Chrome

Describe the Bug

I add svelte into my new project with pnpm astro add svelte

After writing some component with svelte using TS, I have a couple of typed props like position and whereTo:

<script lang="ts">
  import Home from "svelte-material-icons/Home.svelte"; 

  export let position:
    | "top-left"
    | "top-right"
    | "bottom-left"
    | "bottom-right" = "bottom-right";

  export let whereTo: string = "#";

  const positionClass = `FAB-${position}`;
</script>

I'm adding this component directly to Astro page. But Astro doesn't seem to be aware about defined props because when I'm hovering over a component in .astro file typing looks like this:

(alias) function FAB(_props: any): any
import FAB

Types when importing svelte component into another svelte component works perfectly fine. Type when hovering over looks like this:

(alias) class FAB
import FAB

What's the expected result?

Proper types in .astro file. Or at least the opportunity to define them manually. I'm sorry if there is one, but I can't find information about it.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-njqqdd?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P2: has workaroundAn edge case that only affects very specific usage, but has a trivial workaround (priority)ecosystem: upstreamUpstream package has issuepkg: language-toolsRelated to language-tooling (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions