i'm an amateur js developer and i absolutely love knockoutjs !
i have an idea and i what to share it with you.
here it is :
(i): knockout components are great but the html part is a string literal
(ii): being able to see both html (template) and js (view model) code in one place is great
(iii) : we have already an answer for (ii) => JSX
(iv): code editors already support JSX syntax | at least are going to support it
(i),(ii),(iii),(iv) => we should write a JSX compiler for knockout components . (right?)
here is a simple example :
https://github.com/aminroosta/konckout-sample-jsx-compiler/blob/master/index.html
i want to know your opinion , do you think that it does worth the effort ?
Sounds kind of interesting. I generally have put markup in separate files and use a module system (like text plugin for require.js) to pull them in. However, when doing work with React recently, I found JSX to be pleasant to work in. I'll close this, as this would be a good candidate for a plugin vs. something to pursue for KO code. If you ever do develop such a plugin, feel free to link to it here. Thanks for posting!
TypeScript is proposing to extend their compiler to permit compilation of files containing JSX.
See Microsoft/TypeScript#3203.
If this goes ahead then ReactJS will have a competitive advantage over KnockoutJS.
That is because syntax and semantic errors in JSX will be checked at compile time for ReactJS, while for Knockout these errors will only become apparent at runtime (if at all).
I propose this issue be re-opened and Knockout consider providing native support for JSX.
I support aminroosta and his very clear points, moreover I believe that jsx support is the next logical step for knockout components and knockout overall.
however I'd like to make a few other points
+1 For the implications of the design-time syntax checking that JSX with TypeScript enables. I like knockout but hate working with strings like we have to.
Great idea, and with tsx this would be truly type-safe.
Most helpful comment
+1 For the implications of the design-time syntax checking that JSX with TypeScript enables. I like knockout but hate working with strings like we have to.