{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/31212391","id":31212391,"diff_hunk":"@@ -1001,10 +1008,12 @@ module ts {\n             switch (parsingContext) {\r\n                 case ParsingContext.SourceElements:\r\n                 case ParsingContext.ModuleElements:\r\n-                    return isSourceElement(inErrorRecovery);\r\n+                    // During error recovery we don't treat empty statements as statements\r","path":"src/compiler/parser.ts","position":64,"original_position":64,"commit_id":"b28f74ec20d129363f6e076a760cf504468fceb8","original_commit_id":"b28f74ec20d129363f6e076a760cf504468fceb8","user":{"login":"JsonFreeman","id":8052525,"avatar_url":"https://avatars.githubusercontent.com/u/8052525?v=3","gravatar_id":"","url":"https://api.github.com/users/JsonFreeman","html_url":"https://github.com/JsonFreeman","followers_url":"https://api.github.com/users/JsonFreeman/followers","following_url":"https://api.github.com/users/JsonFreeman/following{/other_user}","gists_url":"https://api.github.com/users/JsonFreeman/gists{/gist_id}","starred_url":"https://api.github.com/users/JsonFreeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JsonFreeman/subscriptions","organizations_url":"https://api.github.com/users/JsonFreeman/orgs","repos_url":"https://api.github.com/users/JsonFreeman/repos","events_url":"https://api.github.com/users/JsonFreeman/events{/privacy}","received_events_url":"https://api.github.com/users/JsonFreeman/received_events","type":"User","site_admin":false},"body":"\"as module elements\"","created_at":"2015-05-28T08:25:52Z","updated_at":"2015-05-28T08:25:52Z","html_url":"https://github.com/Microsoft/TypeScript/pull/3266#discussion_r31212391","pull_request_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3266","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/31212391"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/3266#discussion_r31212391"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3266"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3266","id":36236779,"html_url":"https://github.com/Microsoft/TypeScript/pull/3266","diff_url":"https://github.com/Microsoft/TypeScript/pull/3266.diff","patch_url":"https://github.com/Microsoft/TypeScript/pull/3266.patch","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3266","number":3266,"state":"open","locked":false,"title":"Local types","user":{"login":"ahejlsberg","id":4226954,"avatar_url":"https://avatars.githubusercontent.com/u/4226954?v=3","gravatar_id":"","url":"https://api.github.com/users/ahejlsberg","html_url":"https://github.com/ahejlsberg","followers_url":"https://api.github.com/users/ahejlsberg/followers","following_url":"https://api.github.com/users/ahejlsberg/following{/other_user}","gists_url":"https://api.github.com/users/ahejlsberg/gists{/gist_id}","starred_url":"https://api.github.com/users/ahejlsberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahejlsberg/subscriptions","organizations_url":"https://api.github.com/users/ahejlsberg/orgs","repos_url":"https://api.github.com/users/ahejlsberg/repos","events_url":"https://api.github.com/users/ahejlsberg/events{/privacy}","received_events_url":"https://api.github.com/users/ahejlsberg/received_events","type":"User","site_admin":false},"body":"This PR implements support for local class, interface, enum, and type alias declarations. For example:\r\n\r\n```typescript\r\nfunction f() {\r\n    enum E {\r\n        A, B, C\r\n    }\r\n    class C {\r\n        x: E;\r\n    }\r\n    interface I {\r\n        x: E;\r\n    }\r\n    type A = I[];\r\n    let a: A = [new C()];\r\n    a[0].x = E.B;\r\n}\r\n```\r\n\r\nLocal types are block scoped, similar to variables declared with `let` and `const`. For example:\r\n\r\n```typescript\r\nfunction f() {\r\n    if (true) {\r\n        interface T { x: number }\r\n        let v: T;\r\n        v.x = 5;\r\n    }\r\n    else {\r\n        interface T { x: string }\r\n        let v: T;\r\n        v.x = \"hello\";\r\n    }\r\n}\r\n```\r\n\r\nThe inferred return type of a function may be a type declared locally within the function. It is not possible for callers of the function to reference such a local type, but it can of course be matched structurally. For example:\r\n\r\n```typescript\r\ninterface Point {\r\n    x: number;\r\n    y: number;\r\n}\r\n\r\nfunction getPointFactory(x: number, y: number) {\r\n    class P {\r\n        x = x;\r\n        y = y;\r\n    }\r\n    return P;\r\n}\r\n\r\nvar PointZero = getPointFactory(0, 0);\r\nvar PointOne = getPointFactory(1, 1);\r\nvar p1 = new PointZero();\r\nvar p2 = new PointZero();\r\nvar p3 = new PointOne();\r\n```\r\n\r\nLocal types may reference enclosing type parameters and local class and interfaces may themselves be generic. For example:\r\n\r\n```typescript\r\nfunction f1() {\r\n    function f() {\r\n        class C<X, Y> {\r\n            constructor(public x: X, public y: Y) { }\r\n        }\r\n        return C;\r\n    }\r\n    let C = f();\r\n    let v = new C(10, \"hello\");\r\n    let x = v.x;  // number\r\n    let y = v.y;  // string\r\n}\r\n\r\nfunction f2() {\r\n    function f<X>(x: X) {\r\n        class C<Y> {\r\n            public x = x;\r\n            constructor(public y: Y) { }\r\n        }\r\n        return C;\r\n    }\r\n    let C = f(10);\r\n    let v = new C(\"hello\");\r\n    let x = v.x;  // number\r\n    let y = v.y;  // string\r\n}\r\n\r\nfunction f3() {\r\n    function f<X, Y>(x: X, y: Y) {\r\n        class C {\r\n            public x = x;\r\n            public y = y;\r\n        }\r\n        return C;\r\n    }\r\n    let C = f(10, \"hello\");\r\n    let v = new C();\r\n    let x = v.x;  // number\r\n    let y = v.y;  // string\r\n}\r\n```\r\n\r\nFixes #3217.\r\nFixes #2148.\r\n","created_at":"2015-05-26T19:29:08Z","updated_at":"2015-05-28T08:25:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cf2aa437501a87d148d1ad0410ea109eb4b31269","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3266/commits","review_comments_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3266/comments","review_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3266/comments","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/b28f74ec20d129363f6e076a760cf504468fceb8","head":{"label":"Microsoft:localTypes","ref":"localTypes","sha":"b28f74ec20d129363f6e076a760cf504468fceb8","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2015-05-28T07:23:55Z","pushed_at":"2015-05-28T04:36:35Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":828389,"stargazers_count":5331,"watchers_count":5331,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":566,"mirror_url":null,"open_issues_count":648,"forks":566,"open_issues":648,"watchers":5331,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"cc078653be56d38d84ffd4010e2d208eb3596ba0","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2015-05-28T07:23:55Z","pushed_at":"2015-05-28T04:36:35Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":828389,"stargazers_count":5331,"watchers_count":5331,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":566,"mirror_url":null,"open_issues_count":648,"forks":566,"open_issues":648,"watchers":5331,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3266"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/3266"},"issue":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/3266"},"comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/3266/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3266/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/3266/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/TypeScript/statuses/b28f74ec20d129363f6e076a760cf504468fceb8"}}}}