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

Support for JSX? #18

Closed
myitcv opened this issue Aug 3, 2015 · 9 comments
Closed

Support for JSX? #18

myitcv opened this issue Aug 3, 2015 · 9 comments
Assignees

Comments

@myitcv
Copy link
Contributor

myitcv commented Aug 3, 2015

JSX support has landed:

microsoft/TypeScript#3564

Any plans to support that here?

Thanks

@vvakame vvakame self-assigned this Aug 3, 2015
@vvakame
Copy link
Owner

vvakame commented Aug 3, 2015

@myitcv tsfmt use typescript that are installed at the same time.
please check this sample https://gist.github.com/vvakame/9a6459464258c7de63f9

@myitcv
Copy link
Contributor Author

myitcv commented Aug 3, 2015

Thanks, I think I've tracked down the problem. Confirmed that JSX formatting is working, except (for some reason) for the following:

/// <reference path="typings/tsd.d.ts" />

import React = require("react");

function test(): any {
    return <span>This is a test</span>;
}

produces:

/// <reference path="typings/tsd.d.ts" />

import React = require("react");

function test(): any {
    return <span>This is a test< /span>;
}

Notice the problematic < /span>.

The former compiles, the latter does not:

$ ./node_modules/.bin/tsc --jsx react --module system test.tsx
test.tsx(6,34): error TS1003: Identifier expected.
test.tsx(6,35): error TS1005: '>' expected.
test.tsx(9,1): error TS17002: Expected corresponding JSX closing tag for 'span'.

So this is probably a TypeScript core thing?

@vvakame
Copy link
Owner

vvakame commented Aug 3, 2015

yes. typescript-formatter depends to TypeScript core.
typescript-formatter can consume code same as tsc command.
I'm not JSX user. but I think < /span> is broken syntax.

@myitcv
Copy link
Contributor Author

myitcv commented Aug 3, 2015

Thanks. I'll raise this as an issue over there and cc you

@myitcv
Copy link
Contributor Author

myitcv commented Aug 3, 2015

Reference microsoft/TypeScript#4127

@myitcv
Copy link
Contributor Author

myitcv commented Aug 3, 2015

@vvakame - please see microsoft/TypeScript#4127 (comment)

@myitcv
Copy link
Contributor Author

myitcv commented Aug 3, 2015

I've just raised #19 to flesh out a fix for this

@vvakame
Copy link
Owner

vvakame commented Sep 22, 2015

typescript-formatter 1.0.0 support jsx maybe i think so...

@myitcv
Copy link
Contributor Author

myitcv commented Sep 22, 2015

It does, thanks

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

2 participants