4 ms·
Polymer is deprecated in favor of LitElement which comes with TypeScript decorators.
by staticvar 7y ago
Polymer is deprecated in favor of LitElement which comes with TypeScript decorators.
- chmln 7y agoWith LitElement you are still encoding markup in strings and only the interpolated expressions are typechecked [1]. Not to mention that LitElement is far more clunkier and tedious. [1] https://lit-element.polymer-project.org/guide/start#use-litelement-typescript-decorators https://lit-element.polymer-project.org/guide/start#use-lite...
- spankalee 7y agoThe lit-plugin VS Code extension provides type-checking and code-completion for lit-html temptlates. The approach can be adopted for a tsc plugin.
- chmln 7y agoLooks like there is a typescript plugin already [1], meaning this is not restricted to VS Code and should theoretically work in any editor with LSP support. That's better than I thought. [1] https://www.npmjs.com/package/ts-lit-plugin https://www.npmjs.com/package/ts-lit-plugin
- dmitriid 7y agoIt’s still opaque string blobs no matter how you try to dress them up. —- I should probably edit this: It’s still string blobs that are totally opaque to the browser, and that are parsed with regular expressions[1] at runtime[2] and dumped into DOM via innerHtml[3]. [1] https://github.com/Polymer/lit-html/blob/61c08a615abadbe58bc3cc06edaab1e8e4aa094d/src/lib/template.ts#L232 https://github.com/Polymer/lit-html/blob/61c08a615abadbe58bc... [2] http://exploringjs.com/es6/ch_template-literals.html http://exploringjs.com/es6/ch_template-literals.html [3] https://github.com/Polymer/lit-html/blob/61c08a615abadbe58bc3cc06edaab1e8e4aa094d/src/lib/template-result.ts#L101 https://github.com/Polymer/lit-html/blob/61c08a615abadbe58bc...
- cletusw 7y agoHonest question: How is React/vue/etc. different in this regard?
- dmitriid 7y agoReact is pure JS, no string parsing is involved at runtime (JSX is just function calls [1]). Vue has its own templating language that gets compiled to function calls that are very similar to React’s [2]. I have my fair share of criticisms against Vue (as any templating system, it’s quite inconsistent[3]). I don’t think any of them just dump string blobs via innerHtml. And I doubt any of them parse strings with regexps at runtime. [1] https://reactjs.org/docs/react-without-jsx.html https://reactjs.org/docs/react-without-jsx.html and https://overreacted.io/react-as-a-ui-runtime/ https://overreacted.io/react-as-a-ui-runtime/ (specifically section on React elements) [2] https://vuejs-tips.github.io/compiler/#v-else https://vuejs-tips.github.io/compiler/#v-else [3] https://news.ycombinator.com/item?id=19199423 https://news.ycombinator.com/item?id=19199423
- omegabravo 7y ago> React is pure JS, no string parsing is involved at runtime (JSX is just function calls [1]). Why does this matter? React still eventually compiles down to DOM operations whether that be innerHTML or XML modifications.
- dmitriid 7y agoTo quote stevebmark [1] --- quote --- …we’ve learned not to write code in strings. You’d think this would be a fundamental law of software engineering … Writing code, not strings, means you can do everything to it that you can do to code. You can type check code. You can lint it. You can optimize it, compile it, validate it, syntax highlight it, format it with tools like Prettier, tree shake it… --- end quote --- https://news.ycombinator.com/item?id=18511943 https://news.ycombinator.com/item?id=18511943
- Ruphin 7y ago