2 ms·
> JSX is 1,000% magic syntax, and anyone telling you otherwise is trying to sell you something. > It looks, feels, and acts wrong in ways that Svelte or Vue te
by civilitty 4y ago
> JSX is 1,000% magic syntax, and anyone telling you otherwise is trying to sell you something.
> It looks, feels, and acts wrong in ways that Svelte or Vue templates (and most other templating systems) don’t, to me.
My biggest example of this (and it drives me crazy) is when mixing Typescript generics in TSX files: you often have to do ridiculous boilerplate like `<T extends any>` because otherwise `<T>` would be recognized as JSX and blow up the syntax tree. Hoorah for the context-sensitive grammar.
Typescript is what "No magic syntax" looks like: all it takes to get usable javascript is to parse the TS AST, remove the TS specific nodes, and serialize the tree back to text. There are a few exceptions like enums but they're not core features and you can go your entire career without needing them. Meanwhile the JSX ecosystem is full of crap like emotion and styled-components that need babel plugins to support features like component selectors. SMH
- selfmodruntime 4y agoYou are mistaken. This is a fault on TypeScript. Using angle brackets for generics has been a mistake in an environment where XML is used.