Search code examples
typescriptsvelteastrojs

Astro, Typescript and svelte-check


I'm building a frontend project using Astro. For some dynamic components I added svelte as a UI framework.

Now I want to integrate svelte-check but the command is failing because of: Type annotations can only be used in TypeScript files.

E.g. export let languageCode: string doesn't seem to be correct, even though the Astro project compiles fine using npm run build.

Any ideas on how to fix this error? Thanks.


Solution

  • I figured out the issue can be fixed when removing comments in the svelte component.

    E.g. having this in the svelte component shows the above error

    <!--
      Some comment…
    -->
    

    When removing these lines, the error is gone.