{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5207","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5207/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5207/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5207/events","html_url":"https://github.com/Microsoft/TypeScript/issues/5207","id":110840532,"number":5207,"title":"TS compiler leak a ReferenceError on Class Declaration","user":{"login":"falsandtru","id":3143368,"avatar_url":"https://avatars.githubusercontent.com/u/3143368?v=3","gravatar_id":"","url":"https://api.github.com/users/falsandtru","html_url":"https://github.com/falsandtru","followers_url":"https://api.github.com/users/falsandtru/followers","following_url":"https://api.github.com/users/falsandtru/following{/other_user}","gists_url":"https://api.github.com/users/falsandtru/gists{/gist_id}","starred_url":"https://api.github.com/users/falsandtru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/falsandtru/subscriptions","organizations_url":"https://api.github.com/users/falsandtru/orgs","repos_url":"https://api.github.com/users/falsandtru/repos","events_url":"https://api.github.com/users/falsandtru/events{/privacy}","received_events_url":"https://api.github.com/users/falsandtru/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-11T07:42:31Z","updated_at":"2015-10-12T06:29:00Z","closed_at":null,"body":"This compiled code will throw a ReferenceError exception by native javascript engine if Class syntax is implemented. It means that TS compiler generate the invalid code. Should be disallow the use of a class before definition like a Let and Const Declaration because Class Declaration does not specified as hoisting target by es6 spec.\r\n\r\n```ts\r\na; // ts: pass.\r\n   // js: pass.\r\nvar a;\r\nb; // ts: compile error\r\n   // js: runtime error(ReferenceError).\r\nlet b;\r\nc; // ts: compile error\r\n   // js: runtime error(ReferenceError).\r\nconst c = void 0;\r\nf(); // ts: pass.\r\n     // js: pass.\r\nfunction f(){}\r\nnew Foo(); // ts: pass.\r\n           // js: runtime error(ReferenceError)!\r\n           // Class Declaration is not hoistable.\r\n           // should be a compile error before throw a runtime error.\r\nclass Foo {}\r\n```\r\n\r\nhttp://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-statements-and-declarations\r\nhttp://www.ecma-international.org/ecma-262/6.0/#sec-variable-statement\r\nhttp://www.2ality.com/2015/02/es6-classes-final.html\r\n\r\nI think, this issue is different from #2854 because this issue is based on spec."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/147299947","html_url":"https://github.com/Microsoft/TypeScript/issues/5207#issuecomment-147299947","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5207","id":147299947,"user":{"login":"falsandtru","id":3143368,"avatar_url":"https://avatars.githubusercontent.com/u/3143368?v=3","gravatar_id":"","url":"https://api.github.com/users/falsandtru","html_url":"https://github.com/falsandtru","followers_url":"https://api.github.com/users/falsandtru/followers","following_url":"https://api.github.com/users/falsandtru/following{/other_user}","gists_url":"https://api.github.com/users/falsandtru/gists{/gist_id}","starred_url":"https://api.github.com/users/falsandtru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/falsandtru/subscriptions","organizations_url":"https://api.github.com/users/falsandtru/orgs","repos_url":"https://api.github.com/users/falsandtru/repos","events_url":"https://api.github.com/users/falsandtru/events{/privacy}","received_events_url":"https://api.github.com/users/falsandtru/received_events","type":"User","site_admin":false},"created_at":"2015-10-12T06:29:00Z","updated_at":"2015-10-12T06:29:00Z","body":"@basarat thanks! I tested on #4788 but could not detect for now. I think reach-ability check and declaration(and evaluation order) check are different."}}