{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5849","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5849/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5849/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5849/events","html_url":"https://github.com/Microsoft/TypeScript/issues/5849","id":119646107,"number":5849,"title":"Massive slowdown in compiling complicated union types","user":{"login":"Arnavion","id":1096010,"avatar_url":"https://avatars.githubusercontent.com/u/1096010?v=3","gravatar_id":"","url":"https://api.github.com/users/Arnavion","html_url":"https://github.com/Arnavion","followers_url":"https://api.github.com/users/Arnavion/followers","following_url":"https://api.github.com/users/Arnavion/following{/other_user}","gists_url":"https://api.github.com/users/Arnavion/gists{/gist_id}","starred_url":"https://api.github.com/users/Arnavion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Arnavion/subscriptions","organizations_url":"https://api.github.com/users/Arnavion/orgs","repos_url":"https://api.github.com/users/Arnavion/repos","events_url":"https://api.github.com/users/Arnavion/events{/privacy}","received_events_url":"https://api.github.com/users/Arnavion/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Bug","name":"Bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/15","html_url":"https://github.com/Microsoft/TypeScript/milestones/TypeScript%201.8","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/15/labels","id":1347987,"number":15,"title":"TypeScript 1.8","description":"","creator":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.githubusercontent.com/u/8000722?v=3","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"open_issues":132,"closed_issues":121,"state":"open","created_at":"2015-10-09T22:07:47Z","updated_at":"2015-12-02T00:54:33Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2015-12-01T05:39:29Z","updated_at":"2015-12-02T01:11:31Z","closed_at":null,"body":"This is the same code as what originally prompted #2997\r\n\r\nWhile it isn't crashing because of infinite loops any more, it *has* become very slow with 1.7. If I pause it in the debugger I see the following stack repeating many times.\r\n\r\n```\r\ninferFromTypes [tsc.js] Line 15334\tJavaScript\r\ninferFromTypes [tsc.js] Line 15314\tJavaScript\r\ninferFromTypes [tsc.js] Line 15301\tJavaScript\r\ninferFromProperties [tsc.js] Line 15350\tJavaScript\r\ninferFromTypes [tsc.js] Line 15334\tJavaScript\r\ninferFromTypes [tsc.js] Line 15314\tJavaScript\r\ninferFromTypes [tsc.js] Line 15301\tJavaScript\r\ninferFromIndexTypes [tsc.js] Line 15380\tJavaScript\r\ninferFromTypes [tsc.js] Line 15337\tJavaScript\r\ninferFromProperties [tsc.js] Line 15350\tJavaScript\r\n```\r\n\r\nReduced test case:\r\n\r\n```typescript\r\nclass Module {\r\n\tpublic members: { [name: string]: FFunction | Property };\r\n}\r\n\r\nclass Namespace {\r\n\tpublic members: { [name: string]: Class | Enum };\r\n}\r\n\r\nclass Class {\r\n\tpublic parent: Module | Namespace;\r\n\r\n\tpublic members: { [name: string]: Property | FFunction };\r\n}\r\n\r\nclass Interface {\r\n\tpublic members: { [name: string]: Property | FFunction };\r\n}\r\n\r\nclass FFunction {\r\n\tpublic parent: Module | Namespace | Class | Interface; // (1)\r\n}\r\n\r\nclass Property {\r\n\tpublic parent: Module | Namespace | Class | Interface; // (2)\r\n}\r\n\r\nclass Enum {\r\n\tpublic parent: Module | Namespace;\r\n\r\n\tpublic members: EnumMember[];\r\n}\r\n\r\nclass EnumMember {\r\n\tpublic parent: Enum;\r\n}\r\n\r\nvar members: (Property | FFunction)[];\r\nmembers.map(member => \"\");\r\n```\r\n\r\nCompile with `tsc foo.ts` on node 4.2.2 x64 on Windows 7.\r\n\r\nThis takes ~18s on my machine. If I remove `Module` from the union type at (1), it drops to ~12s. Removing `Module` at (2) drops it to ~6s. And so on.\r\n\r\nThe original code is at https://github.com/Arnavion/libjass/blob/82f3706/build/typescript/ast.ts which has a much more complicated forest of types. It's been compiling for 5 minutes now, whereas it took ~2s with 1.6"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/161147424","html_url":"https://github.com/Microsoft/TypeScript/issues/5849#issuecomment-161147424","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/5849","id":161147424,"user":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.githubusercontent.com/u/8000722?v=3","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"created_at":"2015-12-02T01:11:30Z","updated_at":"2015-12-02T01:11:30Z","body":"@Arnavion is there a chance you can move to `typescript@next` directly? "}}