Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSX + ko components ? #1663

Closed
aminroosta opened this issue Dec 27, 2014 · 5 comments
Closed

JSX + ko components ? #1663

aminroosta opened this issue Dec 27, 2014 · 5 comments

Comments

@aminroosta
Copy link

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 ?

@rniemeyer
Copy link
Member

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!

@NoelAbrahams
Copy link

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.

@ivaluev
Copy link

ivaluev commented Mar 14, 2016

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

  • I also want an internal ko parser as environments vary and having external compiler for jsx may not be always an option
  • not sure how opening bracket can be legal in js(x) file - so something along these lines also seems good enough as well binding proposal and jsx key being the key identifying the view type (string literal or jsx)

@Elephant-Vessel
Copy link

+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.

@jtheisen
Copy link

jtheisen commented Nov 7, 2016

Great idea, and with tsx this would be truly type-safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants