{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6208","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6208/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6208/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6208/events","html_url":"https://github.com/Microsoft/TypeScript/issues/6208","id":123538601,"number":6208,"title":"JSX expression type inferencing.","user":{"login":"jameskeane","id":186679,"avatar_url":"https://avatars.githubusercontent.com/u/186679?v=3","gravatar_id":"","url":"https://api.github.com/users/jameskeane","html_url":"https://github.com/jameskeane","followers_url":"https://api.github.com/users/jameskeane/followers","following_url":"https://api.github.com/users/jameskeane/following{/other_user}","gists_url":"https://api.github.com/users/jameskeane/gists{/gist_id}","starred_url":"https://api.github.com/users/jameskeane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jameskeane/subscriptions","organizations_url":"https://api.github.com/users/jameskeane/orgs","repos_url":"https://api.github.com/users/jameskeane/repos","events_url":"https://api.github.com/users/jameskeane/events{/privacy}","received_events_url":"https://api.github.com/users/jameskeane/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-22T19:06:09Z","updated_at":"2015-12-22T20:28:09Z","closed_at":null,"body":"I am working on a jsx library for using CustomElements, and I would like to be able to use the element instance type directly from a JSX expression. Reading through #3203 it seems that `JSX.Element` is the final return type of all JSX expressions.\r\n\r\nCould the JSX expression type not be inferred by evaluating the return type of `React.createElement`? i.e. run the type-inferencing as if the code has been de-sugared.\r\n\r\nConsider:\r\n```Typescript\r\nnamespace React {\r\n  interface ElementConstructor<T> {\r\n      new(): T\r\n  }\r\n  \r\n  // i.e. the element instance type created is of the passed in constructor.\r\n  function createElement<T>(cls: ElementConstructor<T>, props: any, ...children: any[]): T {\r\n  }\r\n}\r\n\r\nclass ExampleTag {\r\n  exampleFunction() { }\r\n}\r\n\r\n// The next line fails type checking\r\n(<ExampleTag />).exampleFunction(); // The type of the JSX expression is specific.\r\n```\r\n\r\nNotice the inconsistency of the type inferencing between JSX and it's de-sugared equivalent.\r\n```Typescript\r\n(<ExampleTag />).exampleFunction();  // Fails type check\r\n(React.createElement(ExampleTag)).exampleFunction();  // Passes\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/166722365","html_url":"https://github.com/Microsoft/TypeScript/issues/6208#issuecomment-166722365","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6208","id":166722365,"user":{"login":"ivogabe","id":4706418,"avatar_url":"https://avatars.githubusercontent.com/u/4706418?v=3","gravatar_id":"","url":"https://api.github.com/users/ivogabe","html_url":"https://github.com/ivogabe","followers_url":"https://api.github.com/users/ivogabe/followers","following_url":"https://api.github.com/users/ivogabe/following{/other_user}","gists_url":"https://api.github.com/users/ivogabe/gists{/gist_id}","starred_url":"https://api.github.com/users/ivogabe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivogabe/subscriptions","organizations_url":"https://api.github.com/users/ivogabe/orgs","repos_url":"https://api.github.com/users/ivogabe/repos","events_url":"https://api.github.com/users/ivogabe/events{/privacy}","received_events_url":"https://api.github.com/users/ivogabe/received_events","type":"User","site_admin":false},"created_at":"2015-12-22T20:28:09Z","updated_at":"2015-12-22T20:28:09Z","body":"+1, would also be very useful for usage without React."}}