{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2673","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2673/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2673/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2673/events","html_url":"https://github.com/Microsoft/TypeScript/pull/2673","id":67231210,"number":2673,"title":"JSX Support","user":{"login":"fdecampredon","id":864201,"avatar_url":"https://avatars.githubusercontent.com/u/864201?v=3","gravatar_id":"","url":"https://api.github.com/users/fdecampredon","html_url":"https://github.com/fdecampredon","followers_url":"https://api.github.com/users/fdecampredon/followers","following_url":"https://api.github.com/users/fdecampredon/following{/other_user}","gists_url":"https://api.github.com/users/fdecampredon/gists{/gist_id}","starred_url":"https://api.github.com/users/fdecampredon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fdecampredon/subscriptions","organizations_url":"https://api.github.com/users/fdecampredon/orgs","repos_url":"https://api.github.com/users/fdecampredon/repos","events_url":"https://api.github.com/users/fdecampredon/events{/privacy}","received_events_url":"https://api.github.com/users/fdecampredon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/cla-signed","name":"cla-signed","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-04-08T22:11:28Z","updated_at":"2015-04-18T08:45:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/2673","html_url":"https://github.com/Microsoft/TypeScript/pull/2673","diff_url":"https://github.com/Microsoft/TypeScript/pull/2673.diff","patch_url":"https://github.com/Microsoft/TypeScript/pull/2673.patch"},"body":"Following the discussion in #296, here is a PR that adds support for JSX constructs.\r\n\r\nAnd some details about the implementation/spec :\r\n\r\n* JSX elements are only parsed if a triple slash directive is present : \r\n```typescript\r\n///<jsx factory=\"myFactory\" />\r\n```\r\n* JSX elements are type checked as a call of the factory function : \r\n```typescript\r\n///<jsx factory=\"myFactory\" />\r\n<MyComp attr={something}> Something </MyComp>;\r\n// typechecked as : \r\nmyFactory(MyComp, { attr: something}, \" Something \");\r\n```\r\n* JSX elements are emitted unchanged (only formatted).\r\n\r\n* To reproduce React's behavior, depending of the case of the tag, the first argument of the function call might be treated as a string:\r\n```typescript\r\n///<jsx factory=\"myFactory\" />\r\n<div />\r\n// typechecked as : \r\nmyFactory(\"div\", {});\r\n\r\n<MyComp />\r\n// typechecked as : \r\nmyFactory(MyComp, {});\r\n```\r\n* JSX directive factory attribute value might contain any property access level: \r\n```typescript\r\n///<jsx factory=\"myNameSpace.myNameSpace1.myFunc\" />\r\n///<jsx factory=\"React.createElement\" />\r\n```\r\n* In General JSX elements describe how a component should be instantiated (at least in React). In this context the way of how attributes should be checked is generally dictated by the *tag*.  \r\nFor this purpose, types for *JSXElement call* are only inferred from the first argument (the *tag*).\r\n```typescript\r\n///<jsx factory=\"test\" />\r\n\r\ndeclare function test<P>(p1: P, p2: P): void;\r\n\r\nvar Comp = { items: \"foo\" };\r\ntest(Comp, {}); // no error P is inferred as `{}` \r\n<Comp />; // error Argument of type '{}' is not assignable to parameter of type '{ items: string; }'.\r\n```\r\nThe service integration is minimal and ported from my old version of jsx-typescript, so not well tested. \r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/94144992","html_url":"https://github.com/Microsoft/TypeScript/pull/2673#issuecomment-94144992","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/2673","id":94144992,"user":{"login":"basarat","id":874898,"avatar_url":"https://avatars.githubusercontent.com/u/874898?v=3","gravatar_id":"","url":"https://api.github.com/users/basarat","html_url":"https://github.com/basarat","followers_url":"https://api.github.com/users/basarat/followers","following_url":"https://api.github.com/users/basarat/following{/other_user}","gists_url":"https://api.github.com/users/basarat/gists{/gist_id}","starred_url":"https://api.github.com/users/basarat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basarat/subscriptions","organizations_url":"https://api.github.com/users/basarat/orgs","repos_url":"https://api.github.com/users/basarat/repos","events_url":"https://api.github.com/users/basarat/events{/privacy}","received_events_url":"https://api.github.com/users/basarat/received_events","type":"User","site_admin":false},"created_at":"2015-04-18T08:45:05Z","updated_at":"2015-04-18T08:45:05Z","body":"> Probably every level, because TS codes may be mixed inside XML elements.\r\n\r\nWould make designers *very* unhappy with their jobs"}}