Title: Incorrect type checking (maybe?) for recursive types · Issue #61520 · microsoft/TypeScript · GitHub
Open Graph Title: Incorrect type checking (maybe?) for recursive types · Issue #61520 · microsoft/TypeScript
X Title: Incorrect type checking (maybe?) for recursive types · Issue #61520 · microsoft/TypeScript
Description: 🔎 Search Terms "recursive" 🕗 Version & Regression Information Typescript 5.7.3, but on the current version in the sandbox (5.8.2) it reproduces too ⏯ Playground Link https://www.typescriptlang.org/play/?ts=5.8.2#code/C4TwDgpgBAShDGBXATgZ...
Open Graph Description: 🔎 Search Terms "recursive" 🕗 Version & Regression Information Typescript 5.7.3, but on the current version in the sandbox (5.8.2) it reproduces too ⏯ Playground Link https://www.typescriptlang.org/...
X Description: 🔎 Search Terms "recursive" 🕗 Version & Regression Information Typescript 5.7.3, but on the current version in the sandbox (5.8.2) it reproduces too ⏯ Playground Link https://www.types...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/61520
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect type checking (maybe?) for recursive types","articleBody":"### 🔎 Search Terms\n\n\"recursive\"\n\n### 🕗 Version & Regression Information\n\nTypescript 5.7.3, but on the current version in the sandbox (5.8.2) it reproduces too\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?ts=5.8.2#code/C4TwDgpgBAShDGBXATgZwJYDcIBVzQF4oBvAKCigDN0IAbAEwH4AuKAO0QFsAjCZAbnJQA8jBawEKDNjyQA2gF1BAX0Gl4AezapgVdGmCsAFAEooBAHwSkaLLnzmop81aNkKFAPSeoqABYaiAxQvFB8yBrIVJFQwH7QqAha9AA0IYi6cXzQ6KjsGmHIEchCFKKscsR6dPSsAIxQymlVAIbc8KwATI0KKaUeA4OD3lAAemMT41OkyiZqmtq61AYAwpHICIZOZpbWUnayhNuscDbS9pAuTu4eI9wZUADu6HFhAB5gtOjwL1AbwCg2LEHPQELQWsgWsB0FooL94PF4ABrPKaIqbWggfrlKCVaoMeqNZpQNodKDdZS9fpDGm3HxTSaTGZzIA\n\n### 💻 Code\n\n```ts\ntype RecursiveType = {\n field?: number;\n OR?: RecursiveType[];\n};\n\nconst first: () => RecursiveType = () => ({\n // should be error for the second, but there is no error\n OR: [{ field: 1 }, { abc: 2 }],\n // ^ ^ ^ ^ ^ ^\n});\n\nconst firstCorrect: () => RecursiveType = (): RecursiveType => ({\n // but with explicit return type declaration it checks correctly\n OR: [{ field: 1 }, { abc: 2 }],\n // ^ ^ ^ ^ ^ ^\n});\n```\n\n\n### 🙁 Actual behavior\n\nOnly the second example throws an error\n\n### 🙂 Expected behavior\n\nBoth examples should throw an error\n\n### Additional information about the issue\n\nThis is probably ACTUALLY correct behavior, but I still decided to create a bug report just in case","author":{"url":"https://github.com/e965","@type":"Person","name":"e965"},"datePublished":"2025-04-01T22:27:20Z","url":"https://github.com/microsoft/TypeScript/issues/61520"}
| 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:1543c68d-2c67-ddcf-7fe7-fa8b27d6965f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C904:2F9718:3AA0E2:50463E:6B00C9E8 |
| html-safe-nonce | 1245adb17a3a62481abd08fa01e49da51845ff64e2ea25da8eaf222140fc3206 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTA0OjJGOTcxODozQUEwRTI6NTA0NjNFOjZCMDBDOUU4IiwidmlzaXRvcl9pZCI6IjI4Njc5NTAyNzAzNzE5MDgwNzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 882875c2d4c32cefd855dc72a8a31f49eb6e029eafb2cc40dc56597ed0991198 |
| hovercard-subject-tag | issue:2964699902 |
| 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/61520/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3e57758b052dde5cdf60522863a97c9f7249156b60ff377e32ca0e828e048887/microsoft/TypeScript/issues/61520 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3e57758b052dde5cdf60522863a97c9f7249156b60ff377e32ca0e828e048887/microsoft/TypeScript/issues/61520 |
| og:image:alt | 🔎 Search Terms "recursive" 🕗 Version & Regression Information Typescript 5.7.3, but on the current version in the sandbox (5.8.2) it reproduces too ⏯ Playground Link https://www.typescriptlang.org/... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | e965 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 98dc00e171c204462a6f367482a0f8c3c6b5dbca99cd7390e82d2df49ce096e4 |
| 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 | ef013399cf0a3c324bea644a685d7c1e0f06b5b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width