Title: Regression in type inference for Promise.all() · Issue #28792 · microsoft/TypeScript · GitHub
Open Graph Title: Regression in type inference for Promise.all() · Issue #28792 · microsoft/TypeScript
X Title: Regression in type inference for Promise.all() · Issue #28792 · microsoft/TypeScript
Description: TypeScript Version: 3.2.1 & 3.3.0-dev.20181201 Search Terms: type inference, promise, tuple Code async function f(x: number): Promise
Open Graph Description: TypeScript Version: 3.2.1 & 3.3.0-dev.20181201 Search Terms: type inference, promise, tuple Code async function f(x: number): Promise X Description: TypeScript Version: 3.2.1 & 3.3.0-dev.20181201 Search Terms: type inference, promise, tuple Code async function f(x: number): Promise<number>{ return x + 1; } async function g(s: string):...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/28792
X: @github
Domain: github.com
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression in type inference for Promise.all()","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:** 3.2.1 & 3.3.0-dev.20181201\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\ntype inference, promise, tuple\r\n\r\n**Code**\r\n\r\n```ts\r\nasync function f(x: number): Promise\u003cnumber>{\r\n return x + 1;\r\n}\r\n\r\nasync function g(s: string): Promise\u003cstring>{\r\n return s + \"\\n\";\r\n}\r\n\r\nasync function h(): Promise\u003cstring> {\r\n const [a, b] = await Promise.all([f(1), g(\"x\")]).catch(() => [null, null]);\r\n if (a === null || b === null) throw new Error();\r\n return b.trim();\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nno compile error, as in TS3.1\r\n\r\n**Actual behavior:**\r\n```\r\ntest.ts:12:12 - error TS2339: Property 'trim' does not exist on type 'string | number'.\r\n Property 'trim' does not exist on type 'number'.\r\n\r\n12 return b.trim();\r\n ~~~~\r\n\r\n```\r\n\r\nIn TS3.1:\r\n```\r\na: number | null\r\nb: string | null\r\n```\r\n\r\nIn TS3.2:\r\n```\r\na: string | number | null\r\nb: string | number | null\r\n```\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior -->\r\n[here](http://www.typescriptlang.org/play/#src=async%20function%20f(x%3A%20number)%3A%20Promise%3Cnumber%3E%7B%0D%0A%20%20%20%20return%20x%20%2B%201%3B%0D%0A%7D%0D%0A%0D%0Aasync%20function%20g(s%3A%20string)%3A%20Promise%3Cstring%3E%7B%0D%0A%20%20%20%20return%20s%20%2B%20%22%5Cn%22%3B%0D%0A%7D%0D%0A%0D%0Aasync%20function%20h()%3A%20Promise%3Cstring%3E%20%7B%0D%0A%20%20%20%20const%20%5Ba%2C%20b%5D%20%3D%20await%20Promise.all(%5Bf(1)%2C%20g(%22x%22)%5D).catch(()%20%3D%3E%20%5Bnull%2C%20null%5D)%3B%0D%0A%20%20%20%20if%20(a%20%3D%3D%3D%20null%20%7C%7C%20b%20%3D%3D%3D%20null)%20throw%20new%20Error()%3B%0D%0A%20%20%20%20return%20b.trim()%3B%0D%0A%7D%0D%0A)\r\n(Enable strictNullChecks to reproduce it)\r\n\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n","author":{"url":"https://github.com/Tatamo","@type":"Person","name":"Tatamo"},"datePublished":"2018-12-01T15:49:02Z","url":"https://github.com/microsoft/TypeScript/issues/28792"}
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:963523f4-f102-8f4a-d389-86046a5e4a75 current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id DD48:3C21B:9F06E9:CF04AA:6B00E2A3 html-safe-nonce a74ab031b538aa121c15f1d4e5f683dab40dca139cf59d835fcf476235a49b64 visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDQ4OjNDMjFCOjlGMDZFOTpDRjA0QUE6NkIwMEUyQTMiLCJ2aXNpdG9yX2lkIjoiMzg4OTE4MjExMTk3MzgyNzIzNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 visitor-hmac eb2cf841d1211932c279a28289ffb97c98a22c5b5e0cd5c4cfcb963e667a1f4b hovercard-subject-tag issue:386469734 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/28792/issue_layout twitter:image https://opengraph.githubassets.com/7fbabb8f0cc4baa71086014c8b29402b8c813ca27b33d4d0ce5ff87931391d74/microsoft/TypeScript/issues/28792 twitter:card summary_large_image og:image https://opengraph.githubassets.com/7fbabb8f0cc4baa71086014c8b29402b8c813ca27b33d4d0ce5ff87931391d74/microsoft/TypeScript/issues/28792 og:image:alt TypeScript Version: 3.2.1 & 3.3.0-dev.20181201 Search Terms: type inference, promise, tuple Code async function f(x: number): Promise og:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username Tatamo hostname github.com expected-hostname github.com None 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 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 624179fb8b88d26ba5bba08894eb60a1c5a1d93d ui-target full theme-color #1e2327 color-scheme light dark react-app-name issues
URLs of crawlers that visited me.