Title: Recursive async function return type not inferred when await on the self call · Issue #55973 · microsoft/TypeScript · GitHub
Open Graph Title: Recursive async function return type not inferred when await on the self call · Issue #55973 · microsoft/TypeScript
X Title: Recursive async function return type not inferred when await on the self call · Issue #55973 · microsoft/TypeScript
Description: 🔎 Search Terms async recursive await 🕗 Version & Regression Information Latest version ⏯ Playground Link https://www.typescriptlang.org/play?#code/PTAEEsDsDMFMCcDOoAuBPADrUB3cKALAewFcVQBDHC-AKAsTUgGNRoSWVwjJR5ZmARgAUASlABvWqBkRooYQFkKhAH...
Open Graph Description: 🔎 Search Terms async recursive await 🕗 Version & Regression Information Latest version ⏯ Playground Link https://www.typescriptlang.org/play?#code/PTAEEsDsDMFMCcDOoAuBPADrUB3cKALAewFcVQBDHC-AKAsTUg...
X Description: 🔎 Search Terms async recursive await 🕗 Version & Regression Information Latest version ⏯ Playground Link https://www.typescriptlang.org/play?#code/PTAEEsDsDMFMCcDOoAuBPADrUB3cKALAewFcVQBDHC-AKA...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/55973
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Recursive async function return type not inferred when await on the self call","articleBody":"### 🔎 Search Terms\n\nasync recursive await\n\n### 🕗 Version & Regression Information\n\nLatest version\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play?#code/PTAEEsDsDMFMCcDOoAuBPADrUB3cKALAewFcVQBDHC-AKAsTUgGNRoSWVwjJR5ZmARgAUASlABvWqBkRooYQFkKhAHTwKkACZEAtmNAAeUAAZVAVnFTZNvrBQl4vfkLEBuabIC+oWABtEbGtbGX4HJ1AAcgJ-PyJIjxsvWmTaEAgYBGRNNFx8AkpqOgYmVnZObmcBACYDYJlweSUVAnVNHX1xYzNLSU8QsMdeKhpyF1rRRO9fAKD+20GI6Nj4qZlk5KA\n\n### 💻 Code\n\n```ts\r\n// infers type without await\r\nasync function rec1() {\r\n if (Math.random() \u003c 0.5) {\r\n return rec1();\r\n } else {\r\n return 'hello';\r\n }\r\n}\r\n\r\n// infers any with await\r\nasync function rec2() {\r\n if (Math.random() \u003c 0.5) {\r\n return await rec2();\r\n } else {\r\n return 'hello';\r\n }\r\n}\r\n\r\n```\r\n\n\n### 🙁 Actual behavior\n\ninfers `any` with `await` on self call\n\n### 🙂 Expected behavior\n\nshould infer the return type as it does without `await`\n\n### Additional information about the issue\n\nTo my understanding, the code has the exact same runtime behavior, so one would expect the same at compilation.\r\n\r\nIf working as intended? why?\r\n\r\nThanks.","author":{"url":"https://github.com/miguel-leon","@type":"Person","name":"miguel-leon"},"datePublished":"2023-10-04T06:13:30Z","url":"https://github.com/microsoft/TypeScript/issues/55973"}
| 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:f23326db-5287-15ad-0272-868410ebad7b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8552:2FEA0C:D809C:1205D0:6B015F73 |
| html-safe-nonce | c366814ec863446ea02367639d6707fdf3ca9482cc9b1ab1da334d2bd5b2aca9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTUyOjJGRUEwQzpEODA5QzoxMjA1RDA6NkIwMTVGNzMiLCJ2aXNpdG9yX2lkIjoiMjE1MDExMDUxMTkyMzAyNzgyNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 881f573c5cde516c7d0ac419201a4ce2f8b3f1a9d27ea305b0a267b9687923ab |
| hovercard-subject-tag | issue:1925476356 |
| 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/55973/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d1790d0b582a62a5107be5b424e2e3d8ba23abdce8c6108771e83c0afbd1b321/microsoft/TypeScript/issues/55973 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d1790d0b582a62a5107be5b424e2e3d8ba23abdce8c6108771e83c0afbd1b321/microsoft/TypeScript/issues/55973 |
| og:image:alt | 🔎 Search Terms async recursive await 🕗 Version & Regression Information Latest version ⏯ Playground Link https://www.typescriptlang.org/play?#code/PTAEEsDsDMFMCcDOoAuBPADrUB3cKALAewFcVQBDHC-AKAsTUg... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | miguel-leon |
| 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