Title: TS2367 must accout for await inside of an async function. · Issue #48148 · microsoft/TypeScript · GitHub
Open Graph Title: TS2367 must accout for await inside of an async function. · Issue #48148 · microsoft/TypeScript
X Title: TS2367 must accout for await inside of an async function. · Issue #48148 · microsoft/TypeScript
Description: Bug Report 🔎 Search Terms TS2367 await async this condition will always return since the types have no overlap 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://stackoverflow.com/q...
Open Graph Description: Bug Report 🔎 Search Terms TS2367 await async this condition will always return since the types have no overlap 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Pla...
X Description: Bug Report 🔎 Search Terms TS2367 await async this condition will always return since the types have no overlap 🕗 Version & Regression Information This is the behavior in every version I tried ⏯...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/48148
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TS2367 must accout for await inside of an async function.","articleBody":"# Bug Report\r\n\r\n\u003c!--\r\n Please fill in each section completely. Thank you!\r\n-->\r\n\r\n### 🔎 Search Terms\r\n\r\nTS2367 await async this condition will always return since the types have no overlap\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This is the behavior in every version I tried\r\n\r\n### ⏯ Playground Link\r\n\r\nhttps://stackoverflow.com/questions/54019195/incorrect-conclusion-that-this-condition-will-always-return-false\r\n\r\n### 💻 Code\r\n\r\n```\r\npublic async transitionA() {\r\n this.state = State.TWO\r\n await sleep(1000)\r\n if (this.state === State.ONE) { // \u003c-- TS2367 error\r\n this.state = State.TWO\r\n }\r\n}\r\n```\r\n\r\nTypescript thinks that this.state could not possibly be equal to State.ONE inside of the if statement. In reality, anything could happen during the await inside of other methods.\r\n\r\n### 🙁 Actual behavior\r\n\r\nStatic analysis complains that an instance variable could not possibly have been reassigned inside of an asynchronous function, where it has **no guarantee** that other methods that happen during the **await** could end up reassigning the variable or not.\r\n\r\n### 🙂 Expected behavior\r\n\r\nInside of async functions where there is an await between the initial assignment and the variable check, TS2367 **should not apply**.\r\n","author":{"url":"https://github.com/Giwayume","@type":"Person","name":"Giwayume"},"datePublished":"2022-03-07T05:40:16Z","url":"https://github.com/microsoft/TypeScript/issues/48148"}
| 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:52e31246-75d9-50f7-153c-e9d42627caa5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED2A:27B4C6:8F6332:C18E20:6B04D948 |
| html-safe-nonce | 6244cb9fdb6024cf963fc1ebb3c9f941f01a24ed03fab99b193c35ca2650b55f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDJBOjI3QjRDNjo4RjYzMzI6QzE4RTIwOjZCMDREOTQ4IiwidmlzaXRvcl9pZCI6Ijg5MjQyOTcyNTY2MjMyMDA1ODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 30f30f76062fd3b87fa5efc604989dd7109830d680f13354b01bbd272a3f00f5 |
| hovercard-subject-tag | issue:1160934381 |
| 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/48148/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4f466e2efbaad58275b47ee0ff24bacd29767e18a88497231464e9348f604e74/microsoft/TypeScript/issues/48148 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4f466e2efbaad58275b47ee0ff24bacd29767e18a88497231464e9348f604e74/microsoft/TypeScript/issues/48148 |
| og:image:alt | Bug Report 🔎 Search Terms TS2367 await async this condition will always return since the types have no overlap 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Pla... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Giwayume |
| hostname | github.com |
| expected-hostname | github.com |
| None | 194dacb8acfd3e4d3ffb2704e0b1f10327f0dad690a7142acc7b0e0a2d073965 |
| 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 | 6c35540a0a2991ee20bd053ba2601cce33f72cb1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width