HoudiniGraphql / houdini

The disappearing GraphQL framework
http://www.houdinigraphql.com
MIT License
913 stars 99 forks source link

Svelte data is not typed #1394

Closed AThilenius closed 3 days ago

AThilenius commented 3 days ago

Describe the bug

I've setup Houdini per the getting started docs. Runtime Houdini is working correctly, but I get a typing error from the Svelte LSP (in NeoVim or VSCode) image

I've tried using Runes as well, but same issue. It's driving me rather mad, hoping that I'm just doing something less-than-smart? Possibly of note, npx houdini@latest init adds a non-existent version of houdini-svelte, so I changed it to 2.0.0

Reproduction

https://github.com/AThilenius/houdini-type-issue

SeppahBaws commented 3 days ago

Ah so jsdoc syntax has an additional asterisk in the opening comment: /** ... */. But since you've defined the component to use typescript anyways, you can also do this:

<script lang="ts">
  import type { PageData } from "./$houdini";

  export let data: PageData;
</script>

or, if you want to use svelte 5 syntax:

<script lang="ts">
  import type { PageData } from "./$houdini";

  interface Props {
    data: PageData;
  }
  let { data }: Props = $props();

  let { Countries } = $derived(data);
</script>
AThilenius commented 3 days ago

Ahhh. Yep. I should have walked away from the problem for a bit; I was just being stupid. I really appreciate the reply, a huge thank you!