5 ms·
> typesafety was the main benefit of JSX Do you have a source for that?
by ricardobeat 8y ago
> typesafety was the main benefit of JSX
Do you have a source for that?
- pspeter3 8y agoI don't know if there is a primary source but it is one of the main benefits for me.
- bcherny 8y agoMy opinion, not a fact. Before JSX came out, there were tons of templating systems that let you embed HTMLish things in JS: Handlebars, Mustache, EJS, Pug, Angular templates. JSX’s big innovation was taking the way XHP promoted HTML to first class syntax and applying it to JS. The big difference between that and the template systems that came before it is JSX is statically analyzable (by your type checker, or by other tools), which means you can scale it to FB scale.
- ricardobeat 8y agoWhat I was thinking is that you're backdating your impressions. JSX came out in 2013, when TypeScript was at it's infancy, and also predates flow; support for JSX in the TS compiler was only added in late 2015. You're right that when it came out it's main innovation was separation of concerns and composability, but types or static analysis were not part of the value proposition at the time.
- bcherny 8y agoYou know, I think that’s a really fair way to look at it. I would be surprised, though, if down the line type safety wasn’t a design goal. It did come from the same company that built XHP around 2010, and the same dude that built the first React prototypes in OCaml. I can ask around after the holidays and see if anyone remembers :)
- spion 8y agoWhat kind of source do you have in mind? The arguments types that are valid will vary based on the content of the template string, and no type system (well a dependently typed language such as Idris could do it) for JS (flow, typescript) supports that. On the other hand, both TypeScript and Flow support type checking for JSX attributes (and child elements to some extent)
- wild_preference 8y agoWhy would you need an external source for a personal opinion?