Title: tsc and tsserver have different ideas of excessively deep types · Issue #32573 · microsoft/TypeScript · GitHub
Open Graph Title: tsc and tsserver have different ideas of excessively deep types · Issue #32573 · microsoft/TypeScript
X Title: tsc and tsserver have different ideas of excessively deep types · Issue #32573 · microsoft/TypeScript
Description: TypeScript Version: typescript-3.6.0-insiders.20190725 https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/37759/artifacts?artifactName=tgz&fileId=2A7E3F3E93DD6F833D63A63F3A7A21707B3F57B08FCA5C93A8...
Open Graph Description: TypeScript Version: typescript-3.6.0-insiders.20190725 https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/37759/artifacts?artifactName=tgz&fileId=2A7E3F3E93...
X Description: TypeScript Version: typescript-3.6.0-insiders.20190725 https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/37759/artifacts?artifactName=tgz&fileId=2A7E3F...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/32573
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"tsc and tsserver have different ideas of excessively deep types","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** \r\n\r\n`typescript-3.6.0-insiders.20190725`\r\n\r\nhttps://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/37759/artifacts?artifactName=tgz&fileId=2A7E3F3E93DD6F833D63A63F3A7A21707B3F57B08FCA5C93A8F1848556D8141F02&fileName=/typescript-3.6.0-insiders.20190725.tgz\r\n\r\nTaken from,\r\nhttps://github.com/microsoft/TypeScript/pull/32028#issuecomment-515234327\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:**\r\n\r\nmax instantiation count, max instantiation depth, tsc, tsserver\r\n\r\n**Code**\r\n\r\nI've reduced the 40-subproject monorepo to just small parts of 2 subprojects.\r\n\r\nHere is a snippet of the problem,\r\n\r\n```ts\r\n\r\n/**\r\n *\r\n * ```json\r\n * //tsconfig-base.json\r\n * \"disableSourceOfProjectReferenceRedirect\": true,\r\n * ```\r\n *\r\n * ```json\r\n * //package.json\r\n * \"typescript\": \"https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/37759/artifacts?artifactName=tgz&fileId=2A7E3F3E93DD6F833D63A63F3A7A21707B3F57B08FCA5C93A8F1848556D8141F02&fileName=/typescript-3.6.0-insiders.20190725.tgz\"\r\n * ```\r\n *\r\n * -----\r\n *\r\n * VS Code: OK!\r\n * Type inference OK!\r\n *\r\n * -----\r\n *\r\n * `tsc` gives me,\r\n *\r\n * ```js\r\n * src/blah.ts:11:21 - error TS2589: Type instantiation is excessively deep and possibly infinite.\r\n *\r\n * 11 export const json = tm.deepMerge(\r\n * ~~~~~~~~~~~~~\r\n * 12 base.json,\r\n * ~~~~~~~~~~~~~~\r\n * ...\r\n * 31 s.convertBlahType.toStr.BLAH\r\n * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n * 32 );\r\n * ~\r\n * ```\r\n */\r\nexport const json = tm.deepMerge(\r\n /*snip*/\r\n);\r\n\r\nconst x = json(\"\", \"\");\r\nif (x.foo != undefined) {\r\n if (x.foo.bar != undefined) {\r\n //Correctly infers `string`\r\n //So, 14M type instantiations is okay with VS code\r\n x.foo.bar.baz\r\n }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nIf `tsc` gets the error,\r\n```\r\nTS2589: Type instantiation is excessively deep and possibly infinite.\r\n```\r\n\r\nThen `tsserver` should also get the error\r\n\r\n**Actual behavior:**\r\n\r\n`tsc` gets the error, but `tsserver` does not (or at least VS code infers the type correctly without errors)\r\n\r\n**Playground Link:** \r\n\r\n-None-\r\n\r\n@sheetalkamat \r\n\r\nThe project involved contains code related to a company project.\r\nSo, I really do not want to upload it publicly, if possible.\r\n\r\nI could mangle the variable names so that they're meaningless but if I can just email the parts of the project that are involved, that would be nice.\r\n\r\nRepro steps:\r\n\r\n1. `npm install`\r\n1. `npm run build`\r\n1. See `TS2589: Type instantiation is excessively deep and possibly infinite.`\r\n1. Open VS code\r\n1. Navigate to file `tsc` says contains errors\r\n1. Notice no errors\r\n1. Play with return type of function\r\n1. Notice inference works correctly\r\n\r\n**Related Issues:** \r\n\r\nThe merged PR that introduced the error,\r\nhttps://github.com/microsoft/TypeScript/pull/32079#issuecomment-515334873\r\n\r\nThe build I am testing,\r\nhttps://github.com/microsoft/TypeScript/pull/32028\r\n\r\nAlso relevant, https://github.com/microsoft/TypeScript/issues/29511\r\nIt seems like every few versions, there ends up being a difference between `tsc` and `tsserver`, regarding the max instantiation depth\r\n","author":{"url":"https://github.com/AnyhowStep","@type":"Person","name":"AnyhowStep"},"datePublished":"2019-07-26T07:48:46Z","url":"https://github.com/microsoft/TypeScript/issues/32573"}
| 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:775dc8fd-8d73-3be7-64af-8d75be263583 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B18C:3F4253:259EB66:321E7D4:6B01A420 |
| html-safe-nonce | 7e6b1ca4ceb7a8f7023077c22c43de2c0542ba0fbad5e0852fadcb83dbce6ed0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMThDOjNGNDI1MzoyNTlFQjY2OjMyMUU3RDQ6NkIwMUE0MjAiLCJ2aXNpdG9yX2lkIjoiMTUzMDYwNjExNzA3MDE1MjczNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fa0e408ac69a582009fe42e95fa15de724bc7ca90f181fb1bf50cbd23d65b5b2 |
| hovercard-subject-tag | issue:473225055 |
| 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/32573/issue_layout |
| twitter:image | https://opengraph.githubassets.com/aba6d80b7f9c7fe343005f09fb3c2d15ed576e95111c64ac1541509ea5fa1c56/microsoft/TypeScript/issues/32573 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/aba6d80b7f9c7fe343005f09fb3c2d15ed576e95111c64ac1541509ea5fa1c56/microsoft/TypeScript/issues/32573 |
| og:image:alt | TypeScript Version: typescript-3.6.0-insiders.20190725 https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/37759/artifacts?artifactName=tgz&fileId=2A7E3F3E93... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AnyhowStep |
| 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