Title: ts.TypeChecker.typeToTypeNode goes in infinite loop eating up CPU and Memory. · Issue #29564 · microsoft/TypeScript · GitHub
Open Graph Title: ts.TypeChecker.typeToTypeNode goes in infinite loop eating up CPU and Memory. · Issue #29564 · microsoft/TypeScript
X Title: ts.TypeChecker.typeToTypeNode goes in infinite loop eating up CPU and Memory. · Issue #29564 · microsoft/TypeScript
Description: TypeScript Version: 3.2.2 Search Terms: ts.TypeChecker.typeToTypeNode, ts.TypeLiteralNode, ts.NodeBuilderFlags.NoTruncation Description: We are trying to use typescript compiler for getting the type of ObjectLiteralExpression and for the...
Open Graph Description: TypeScript Version: 3.2.2 Search Terms: ts.TypeChecker.typeToTypeNode, ts.TypeLiteralNode, ts.NodeBuilderFlags.NoTruncation Description: We are trying to use typescript compiler for getting the typ...
X Description: TypeScript Version: 3.2.2 Search Terms: ts.TypeChecker.typeToTypeNode, ts.TypeLiteralNode, ts.NodeBuilderFlags.NoTruncation Description: We are trying to use typescript compiler for getting the typ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/29564
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ts.TypeChecker.typeToTypeNode goes in infinite loop eating up CPU and Memory.","articleBody":"TypeScript Version: 3.2.2\r\n\r\nSearch Terms:\r\nts.TypeChecker.typeToTypeNode, \r\nts.TypeLiteralNode,\r\nts.NodeBuilderFlags.NoTruncation\r\n\r\nDescription:\r\n\r\nWe are trying to use typescript compiler for getting the type of ObjectLiteralExpression and for the purpose we utilize following code:\r\n\r\n```\r\ngetApparentTypeForObjectLiteralExpression(node : ts.Node) : {type : ts.Type, typeNode : ts.TypeNode} {\r\n let type : ts.Type = this.checker.getTypeAtLocation(node);\r\n let typeNode = this.checker.typeToTypeNode(type, undefined, ts.NodeBuilderFlags.NoTruncation);\r\n\r\n if(ts.isTypeLiteralNode(typeNode))\r\n {\r\n var memberCount = typeNode.members.length;\r\n var name : string;\r\n typeNode.members.forEach(member => {\r\n name += member.name;\r\n name += \" , \";\r\n });\r\n }\r\n return {type, typeNode}\r\n }\r\n```\r\nWhen we run the above code over the attached file SEA3DAmmo.txt (rename file to SEA3DAmmo.js), the line this.checker.typeToTypeNode goes into infinite loop and the application consumes high CPU and Memory and the call does not return back atall.\r\n\r\nThis is an absolute blocker, may be i am doing some mistake. \r\nI also tried running with following options:\r\nthis.checker.typeToTypeNode(type, node, ts.NodeBuilderFlags.NoTruncation);\r\nor\r\nthis.checker.typeToTypeNode(type, node.parent, ts.NodeBuilderFlags.NoTruncation);\r\n\r\n**Expected behavior:**\r\nIt should return value and should not go in infinite loop.\r\n\r\n[SEA3DAmmo.txt](https://github.com/Microsoft/TypeScript/files/2793068/SEA3DAmmo.txt)\r\n","author":{"url":"https://github.com/abhijitparkhi1983","@type":"Person","name":"abhijitparkhi1983"},"datePublished":"2019-01-24T18:51:09Z","url":"https://github.com/microsoft/TypeScript/issues/29564"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3af4788a-6d41-ea38-5419-fd628b83e7af |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BFE6:1148D3:26B0761:31595C5:6B0199F7 |
| html-safe-nonce | 9a3022af633db597b6905245ad8b8aafc99defd2908835e3237e830a24e46e7f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkU2OjExNDhEMzoyNkIwNzYxOjMxNTk1QzU6NkIwMTk5RjciLCJ2aXNpdG9yX2lkIjoiNzk4ODI3NTMxOTkwNTgxOTEyNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0e3f9533b485b7f004d86f4a10aca0545802534dd22df8ec0971ac7a5a2fb187 |
| hovercard-subject-tag | issue:402847034 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/29564/issue_layout |
| twitter:image | https://opengraph.githubassets.com/af1f78deecc4efe909522720139d22f49521cb31966ccb5b5c079573f853446c/microsoft/TypeScript/issues/29564 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/af1f78deecc4efe909522720139d22f49521cb31966ccb5b5c079573f853446c/microsoft/TypeScript/issues/29564 |
| og:image:alt | TypeScript Version: 3.2.2 Search Terms: ts.TypeChecker.typeToTypeNode, ts.TypeLiteralNode, ts.NodeBuilderFlags.NoTruncation Description: We are trying to use typescript compiler for getting the typ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abhijitparkhi1983 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width