{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11316","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11316/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11316/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11316/events","html_url":"https://github.com/Microsoft/TypeScript/issues/11316","id":180607220,"number":11316,"title":"Issue when using export as namespace in type definitions","user":{"login":"subash-a","id":2296251,"avatar_url":"https://avatars.githubusercontent.com/u/2296251?v=3","gravatar_id":"","url":"https://api.github.com/users/subash-a","html_url":"https://github.com/subash-a","followers_url":"https://api.github.com/users/subash-a/followers","following_url":"https://api.github.com/users/subash-a/following{/other_user}","gists_url":"https://api.github.com/users/subash-a/gists{/gist_id}","starred_url":"https://api.github.com/users/subash-a/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/subash-a/subscriptions","organizations_url":"https://api.github.com/users/subash-a/orgs","repos_url":"https://api.github.com/users/subash-a/repos","events_url":"https://api.github.com/users/subash-a/events{/privacy}","received_events_url":"https://api.github.com/users/subash-a/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-10-03T10:24:44Z","updated_at":"2016-10-03T16:13:29Z","closed_at":null,"body":"TS Version 2.1.0-dev.20160915\r\nWe use `JSPM` as our module loader and using npm-based installation of type defintions (i.e. @types)\r\n\r\nAn issue when referring to React namespace when it is not imported.\r\n\r\n**Actual Behaviour**\r\nWe get the error message:\r\n`Identifier 'React' must be imported from a module`\r\n\r\n**Expected Behaviour** \r\nget the error message\r\n`Cannot find namespace 'React'`\r\n\r\nSeems like this is related to:\r\n`export as namespace React;` statement in the [React type definitions](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/04b427297486d599eca173d464bed41c10b5440d/react/index.d.ts#L7)\r\n\r\nThe `export as namespace..` appears to make the React namespace available globally, i.e. it pollutes the global namespace, and also gives rise to the message `Identifier 'React' must be imported from a module`, when we comment out the `export as namespace...` everything works as expected, but suspect this was included for some reason by @RyanCavanaugh ?"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/251150462","html_url":"https://github.com/Microsoft/TypeScript/issues/11316#issuecomment-251150462","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11316","id":251150462,"user":{"login":"myitcv","id":3374574,"avatar_url":"https://avatars.githubusercontent.com/u/3374574?v=3","gravatar_id":"","url":"https://api.github.com/users/myitcv","html_url":"https://github.com/myitcv","followers_url":"https://api.github.com/users/myitcv/followers","following_url":"https://api.github.com/users/myitcv/following{/other_user}","gists_url":"https://api.github.com/users/myitcv/gists{/gist_id}","starred_url":"https://api.github.com/users/myitcv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myitcv/subscriptions","organizations_url":"https://api.github.com/users/myitcv/orgs","repos_url":"https://api.github.com/users/myitcv/repos","events_url":"https://api.github.com/users/myitcv/events{/privacy}","received_events_url":"https://api.github.com/users/myitcv/received_events","type":"User","site_admin":false},"created_at":"2016-10-03T16:13:29Z","updated_at":"2016-10-03T16:13:29Z","body":"> If there are no imports or exports as in the last example, you are writing a global script. \r\nA file is only a module if it has at least one top level import or export.\r\n\r\nSorry, but I'm missing something. We're talking about a TypeScript project here that declares a `tsconfig.json` similar to what follows (which is ours):\r\n\r\n```json\r\n{\r\n  \"compilerOptions\": {\r\n    \"declaration\": false,\r\n    \"jsx\": \"react\",\r\n    \"module\": \"system\",\r\n    \"moduleResolution\": \"node\",\r\n    \"newLine\": \"LF\",\r\n    \"noEmitOnError\": true,\r\n    \"noImplicitAny\": true,\r\n    \"noImplicitReturns\": true,\r\n    \"noLib\": true,\r\n    \"removeComments\": false,\r\n    \"rootDir\": \".\",\r\n    \"sourceMap\": true,\r\n    \"target\": \"es5\",\r\n    \"typeRoots\": [\r\n      \"../node_modules/@types/\",\r\n      \"../src/typings/\"\r\n    ]\r\n  }\r\n}\r\n```\r\n\r\nAre you saying that global scripts can be written in this context? Assuming there is just one `.ts` file in this project and it doesn't declare any dependencies via imports, it is effectively a global script? \r\n\r\nThen doesn't this fail the test that I described above? Namely that it's possible to write code (as you did, your global script) that uses `React`, compiles, but then fails at runtime?"}}
{"actor":{"display_login":"myitcv"}}