Skip to content

Request: Support Svelte JS labels #5367

Open
@n-smits

Description

@n-smits

There was no need for JS labels before, but Svelte found a good use for the syntax. Currently it can only be passed with backticks, but it's very limited and unwieldy.

`$: {`
foo 'hi' # must not properly indent
`}`

All other fail

`$:` foo 'hi'
# produces ({ $: foo 'hi' })

`$:`
foo 'hi'
# erroneous
# $:;
# foo('hi');

`$: {` foo 'hi' `}`
# won't compile

Simplest and very Coffee solution would be to spell out the syntax name, but honestly whatevs, whatever names you have left reserved or can reappropriate such as case outside of switch.

label $: foo 'hi' # or = or space
label $
  foo 'hi'
  foo 'hi'

It's true this label use isn't idiomatic and that it's a solitary kinda-framework example. But, it is actually using the standard syntax, and its unidiomatic use became innovative, because unlike before, it's actually a good use. Past addition of JSX could be considered similar, and a good place for it in documentation (since it is after all a rare good example of Js labels, so it's mostly about Svelte).

In my very humble general opinion here, Coffeescript should adapt here and there because Javascript is a hackable text based language for better and for worse. Otherwise is excessively conservative and necessarily keeps the bad part of Js (Js is what it is), while losing the better part (it's hackable, here for the better). Good guideline for when is enough of offshoots should include standard syntax when it's a good use even if an unconventional one. (So-so unconvencional actually, it's not like Svelte is so unheard of.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions