Skip to content

Clear (Current) TypeScript Support #4171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DakotaLarson opened this issue Dec 26, 2019 · 11 comments
Closed

Clear (Current) TypeScript Support #4171

DakotaLarson opened this issue Dec 26, 2019 · 11 comments

Comments

@DakotaLarson
Copy link

Is your feature request related to a problem? Please describe.
As a user of Svelte, I cannot easily integrate TypeScript, even though the technology exists.

Describe the solution you'd like
I was able to find a working (as of 12/19) template after A LOT of googling: https://github.com/pyoner/svelte-typescript/tree/master/packages/template. I would like to see information for this in Svelte documentation. The solution probably is a little rough, but using this template, and VSCode with svelte extensions gives me full editor support.

Describe alternatives you've considered
Currently, searching for TS support leads to an open issue about official support of the language, which I found confusing. SO answers were only somewhat helpful.

How important is this feature to you?
Now that I got it working... not that important, but for other devs searching for TS support in Svelte, this is probably the answer they are looking for to start building something with Svelte.

Additional context
N/A

@swyxio
Copy link
Contributor

swyxio commented Dec 26, 2019

to be clear, we mean two things when we talk about typescript support - support in <script> tags, and support in <template>. the former is solved with preprocessors, the latter isn't solved yet (mostly due to lack of time for working on it) - you're welcome to try!

as for documenting TS support in script tags, thats something that is ideal for the Recipes section of the community site.

@benbot
Copy link

benbot commented Jan 3, 2020

@sw-yx I think there was a typo in your response. What is the 2nd thing we mean regarding typescript?

@swyxio
Copy link
Contributor

swyxio commented Jan 3, 2020

edited - i wrote <template>, github markdown swallowed it

@zmitry
Copy link

zmitry commented Jan 3, 2020

can we consider some alternative api which will have typescript support out of the box.
for instance, we can add something like script template which should have definition for render function.

<script>
let i =0;
</script>
<script template>
let render =()=>(<div onClick={i=>i++}>
{i}
</div>)
</script>

It complicates some ast anylisys but on the other handl you don't need to write own language server to make it type safe.
@sw-yx what do you think?

@zmitry
Copy link

zmitry commented Jan 3, 2020

Though more about this approach and got some more ideas for api.
Here we use jsx tag on script.

<script jsx>
let i = 0;
render: <div onClick={i=>i++}> {i} </div>
</script>

Here we're using $ notation for template values.

<script>
let i =0;
</script>
<script template>
$:(<div onClick={i=>i++}>counter:{i}</div>)
// we can have multiple elements
$:(<span onClick={i=>i++}>click me</span>)
</script>

Obviously, this apporach will have less optimizations than template based approach but I think it makes sense to invest more in this approach rather than in language server for templates.

@swyxio
Copy link
Contributor

swyxio commented Jan 3, 2020

i simply dont think this is what svelte wants to do, the maintainers have been very clear about why we use the html-like template syntax.

vue has proven the language server approach can work.

@zmitry
Copy link

zmitry commented Jan 3, 2020

@sw-yx It can work with a huge amount of time investments, same for angular language server, it took them almost 1 year to give decent DX and it still not ideal, even with the fulltime team working on that.
I think it's possible to achieve typescript support just by simply allowing to write your own component renderers within a dedicated block of code.

@pngwn
Copy link
Member

pngwn commented Jan 3, 2020

There isn't any realistic chance of us supporting a second syntax that is limited to just typescript users and will deliver a watered-down version of svelte.

@zmitry
Copy link

zmitry commented Jan 4, 2020

Does it sound easier to maintain a reliable language server for svelte?

@theword
Copy link

theword commented Jan 29, 2020

Does it sound easier to maintain a reliable language server for svelte?

Having no experience with these things, could you explain why that is so difficult?

@antony
Copy link
Member

antony commented Apr 9, 2020

Closing in favour of #4518

@antony antony closed this as completed Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants