{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/642","labels_url":"https://api.github.com/repos/facebook/immutable-js/issues/642/labels{/name}","comments_url":"https://api.github.com/repos/facebook/immutable-js/issues/642/comments","events_url":"https://api.github.com/repos/facebook/immutable-js/issues/642/events","html_url":"https://github.com/facebook/immutable-js/pull/642","id":109283343,"number":642,"title":"Global type definition fixes","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},"labels":[{"url":"https://api.github.com/repos/facebook/immutable-js/labels/CLA%20Signed","name":"CLA Signed","color":"009900"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-10-01T11:44:44Z","updated_at":"2015-11-30T11:49:20Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/immutable-js/pulls/642","html_url":"https://github.com/facebook/immutable-js/pull/642","diff_url":"https://github.com/facebook/immutable-js/pull/642.diff","patch_url":"https://github.com/facebook/immutable-js/pull/642.patch"},"body":"With reference to the [current TypeScript type definition](https://github.com/facebook/immutable-js/blob/59028b5e8552339acbdaab0c3f6547bd131f8f54/type-definitions/Immutable.d.ts). \r\n\r\nThe following code compiles:\r\n\r\n```typescript\r\n/// <reference path=\"../jspm_packages/npm/immutable@3.7.5/dist/immutable.d.ts\" />\r\n\r\nlet x = Immutable.Seq([1,2,3]);\r\nconsole.log(x);\r\n``` \r\n\r\nbut fails at runtime unless you have loaded ImmutableJS elsewhere. For those, like me, who use [SystemJS](https://github.com/systemjs/systemjs) (or other modules loaders) to load modules, we need to declare dependencies via imports, and generally rely on the compiler to tell us when we have missed one (as is the case here).\r\n\r\nThis PR creates two (linked) versions of the type definition:\r\n\r\n* For those people who are going to loaded ImmutableJS elsewhere and want to therefore take advantage of the global definitions, they should reference `Immutable-global.d.ts`\r\n* For those people who use module loaders and want the above code to be a compile error because they haven't imported ImmutableJS, they should use `Immutable.d.ts`\r\n\r\nA similar approach is [taken by React](https://github.com/borisyankov/DefinitelyTyped/tree/master/react).\r\n\r\nSo if instead I reference the `Immutable.d.ts` in this PR, the above code would give a compile error:\r\n\r\n```\r\napp/app.ts(3,9): error TS2304: Cannot find name 'Immutable'.\r\n```\r\n\r\nThis forces me to import:\r\n\r\n```typescript\r\n/// <reference path=\"../typings/immutable/Immutable.d.ts\" />\r\n\r\nimport * as Immutable from \"immutable\";\r\n\r\nlet x = Immutable.Seq([1,2,3]);\r\nconsole.log(x);\r\n```\r\n\r\nThe transpiled output then includes the relevant module loading code to ensure ImmutableJS has been loaded before use (in my case I'm using [SystemJS](https://github.com/systemjs/systemjs)):\r\n\r\n```javascript\r\nSystem.register([\"immutable\"], function(exports_1) {\r\n    var Immutable;\r\n    var x;\r\n    return {\r\n        setters:[\r\n            function (Immutable_1) {\r\n                Immutable = Immutable_1;\r\n            }],\r\n        execute: function() {\r\n            x = Immutable.Seq([1, 2, 3]);\r\n            console.log(x);\r\n        }\r\n    }\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/comments/160608485","html_url":"https://github.com/facebook/immutable-js/pull/642#issuecomment-160608485","issue_url":"https://api.github.com/repos/facebook/immutable-js/issues/642","id":160608485,"user":{"login":"javacer","id":6864490,"avatar_url":"https://avatars.githubusercontent.com/u/6864490?v=3","gravatar_id":"","url":"https://api.github.com/users/javacer","html_url":"https://github.com/javacer","followers_url":"https://api.github.com/users/javacer/followers","following_url":"https://api.github.com/users/javacer/following{/other_user}","gists_url":"https://api.github.com/users/javacer/gists{/gist_id}","starred_url":"https://api.github.com/users/javacer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javacer/subscriptions","organizations_url":"https://api.github.com/users/javacer/orgs","repos_url":"https://api.github.com/users/javacer/repos","events_url":"https://api.github.com/users/javacer/events{/privacy}","received_events_url":"https://api.github.com/users/javacer/received_events","type":"User","site_admin":false},"created_at":"2015-11-30T11:49:20Z","updated_at":"2015-11-30T11:49:20Z","body":"+1"}}