sveltejs / svelte-preprocess

A ✨ magical ✨ Svelte preprocessor with sensible defaults and support for: PostCSS, SCSS, Less, Stylus, Coffeescript, TypeScript, Pug and much more.
MIT License
1.73k stars 147 forks source link

Add @const support to preprocessed scripting languages #567

Open LeoDog896 opened 1 year ago

LeoDog896 commented 1 year ago

In svelte, you can use {@const variable = element} to declare variables. Unfortunately, this lacks typescript type support, for example:

{@const var = someGenericMethod<string>()}

Maybe a configuration option for using typescript / coffeescript (not sure how that would look) notation for @const statements, and possibly any others that may also do this.

or, what would probably work better is, with the template tag, specify what script it should use:

<template lang="pug" script="typescript">
    <!-- stuff goes here -->
</template>