feat: twoslash-svelte#2028
Conversation
|
@Hugos68 is attempting to deploy a commit to the Svelte Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
While most snippets work out of the box by simply replacing the import for
|
There was a problem hiding this comment.
We probably need to enable banners for Svelte codeblocks so that we can easily inject types/expected error statements https://github.com/hugos68/svelte.dev/blob/feature/twoslash-svelte/packages/site-kit/src/lib/markdown/renderer.ts#L448-L449 However, it seems like the twoslash syntax only works inside the script blocks, so we can't just prepend the banner like we do in js/ts files.
The docs in each repo also need to be modified with the correct ambient types or // @errors:.
I've tried ensuring the banners get prepended but it seems to make the hover behaviour break.
|
Hey @teemingc, thanks for your swift response! So essentially looking for <script> tag and injecting the banners there? And if a |
Yeah, that’s what I tried but it didn’t seem to work similarly to the original twoslash. It might be better to fix it from that side so that it recognises the syntax from outside the script block, allowing us to declare multiple files at a time |
I think that should be the svelte2tsx's job in that case. Although allowing top level ts style comments in the markdown bit of svelte seems quote odd no? |
I guess twoslash was originally designed for js/ts so for twoslash-svelte it could expect html comment syntax instead? Or for consistency, stick to ts style comments |
|
I've partially solved some issues by creating a PR for allowing cuts: twoslashes/twoslash#91 This still leaves us to implement the banner stuff, but it does help with some of the errors while implementing this. |
|
@teemingc Is it maybe a good idea to add a |
|
How would that work if we had multiple svelte files declared in a single code block using cut? Would it inject the same banners into each of the svelte script blocks? |
Svelte are Single File Components, how do you add multiple svelte files to a single code block? |
Issue
Closes #649
Description
NOTE:
twoslash-svelte@0.0.0has a blocking bug, wait for twoslashes/twoslash#90 until we can merge.Replaces the default
twoslasherinstance totwoslash-sveltewhich supports "twoslashing".sveltesnippets:Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.