News for hackers. Stuff that matters.
Re:The Svelte Compiler Handbook by xellisx on Sunday April 05, 2020 @08:16AM (#22785217)
I'm surprised Apprun nor Solid have been mentioned yet.

Are there any TypeScript reactive frameworks? I know you can use TS with the others, but finding tutorials can be a pain since it all these are JS first frameworks.

Re:The Svelte Compiler Handbook by Trufa on Sunday April 05, 2020 @08:27AM (#22785250)
I'm actually working on one. I don't know what will come out of it, but it's an interesting endeavor. As soon as it's shareable I will share it on Github.

I'm basically trying to do a superset of typescript where you create elements so:

  const root = c({
    el: 'div',
    children: [
      `hello, ${store.user.name}`
    ],
    attr: {
      class: 'bold smart',
      id: 'abc',
      bla: true,
    },
    evts: {
      click: () => {
        console.log("Clicked")
      }
    }
  });
And store store.user.name is "magically" reactive.

Was that what you meant?

Re:The Svelte Compiler Handbook by chrismorgan on Sunday April 05, 2020 @11:41AM (#22786183)
What you’ve written there couldn’t possibly be reactive without compilation or wrapping it in a function. Is there something else wrapping it (a function), or is it being compiled into a different form? If it’s being compiled (so that the code means something other than it seems to), then I see no particular advantage to using TypeScript syntax, given it’s more verbose than need be.

For reference, in Svelte that’d be something like this, which is shorter and more obvious:

  <div class="bold smart" id="abc" bla={true} on:click={() => { console.log("Clicked") }>
    hello, {store.user.name}
  </div>
Re:The Svelte Compiler Handbook by Trufa on Sunday April 05, 2020 @12:08PM (#22786377)
Yes, that's currently what I'm experimenting with.

This is very early stages and completely experimental.

The idea I'm experimenting is to compile typescript to another form, I completely see your point about too verbose though, but I'm also toying around with jsx.

Basically what I'm trying to do is a svelte where instead of this:

  {#each cats as { id, name }, i}
    <li>
       <a target="_blank" href="https://www.youtube.com/watch?v={id}">
 {i + 1}: {name}
       </a>
    </li>
  {/each}
You have have the native JavaScript map functions and so on.

Again, this is completely in the early stages and just playing around until something feels right.

Any recommendations appreciated.

Re:The Svelte Compiler Handbook by Casperin on Monday April 06, 2020 @03:35AM (#22791586)
Is there any framework that explicitly allows me to set properties instead of just attributes? It doesn't play nice with web components when the object you passed in comes out as a string "[object Object]".
Re:The Svelte Compiler Handbook by Trufa on Monday April 06, 2020 @01:54PM (#22796049)
What do you mean? how would it look?
Re:The Svelte Compiler Handbook by syspec on Sunday April 05, 2020 @12:00PM (#22786322)
Using 'evts' instead of events is a good way to get people to make mistakes
Re:The Svelte Compiler Handbook by Trufa on Sunday April 05, 2020 @12:08PM (#22786379)
Thanks for the feedback :)
Re:The Svelte Compiler Handbook by bufferoverflow on Sunday April 05, 2020 @10:41AM (#22785795)
That is awfully verbose.
Re:The Svelte Compiler Handbook by Trufa on Sunday April 05, 2020 @11:59AM (#22786315)
I'll hopefully add jsx eventually that will help with the visual aspect of the verbosity.
Re:The Svelte Compiler Handbook by wolfadex on Sunday April 05, 2020 @01:13PM (#22786844)
What's wrong with being verbose?
Re:The Svelte Compiler Handbook by bufferoverflow on Monday April 06, 2020 @07:48AM (#22792849)
You need to write more, you need to read more, and whoever maintains your code will need to read more. More chances for typos. That means more time wasted for everyone.

Why do you think we have async/await now instead of manually typing out all the promise syntaxic mess every time?

Re:The Svelte Compiler Handbook by tekknik on Monday April 06, 2020 @09:16AM (#22793428)
because handling a promise using .then/.catch creates a new block? verbosity isn’t an issue as much as being too terse, especially with macros
Re:The Svelte Compiler Handbook by spankalee on Sunday April 05, 2020 @04:11PM (#22788260)
lit-html is written in TypeScript, so has great typings.

There are TypeScript plugins to statically analyze the templates, like lit-analyzer and the lit-plugin VS Code extension.

LitElement provides TypeScript decorators for declaring reactive properties and more.

Re:The Svelte Compiler Handbook by xellisx on Sunday April 05, 2020 @07:24PM (#22789587)
While it is writen in typescript, it's still aimed towards JS first.
Re:The Svelte Compiler Handbook by spankalee on Sunday April 05, 2020 @09:13PM (#22790131)
I'm not exactly sure what you mean then.

TypeScript doesn't in general change its emit based on types, so its runtime feature set is exactly the same as JavaScript.

lit-html has a TypeScript compiler plug-in which provides template type=-checking, and LitElement provides decorators, like I said. How would something be more aimed at TypeScript, and not JavaScript?

Re:The Svelte Compiler Handbook by xellisx on Sunday April 05, 2020 @09:43PM (#22790246)
The project front page talks all about JavaScript, and no mention of TypeScript. So to me it's not aimed primarily toward developing against it in TS.
Re:The Svelte Compiler Handbook by Can_Not on Sunday April 05, 2020 @10:01PM (#22790304)
"Good Typescript Support" and "Technically Written in Typescript" are very different things.
Re:The Svelte Compiler Handbook by spankalee on Sunday April 05, 2020 @11:43PM (#22790744)
Do you have specifics?
Re:The Svelte Compiler Handbook by arkanciscan on Sunday April 05, 2020 @10:04AM (#22785582)
^ why you shouldn't use supersets