Title: In finally block, local variable is incorrectly typed as never with return in try block. · Issue #28153 · microsoft/TypeScript · GitHub
Open Graph Title: In finally block, local variable is incorrectly typed as never with return in try block. · Issue #28153 · microsoft/TypeScript
X Title: In finally block, local variable is incorrectly typed as never with return in try block. · Issue #28153 · microsoft/TypeScript
Description: TypeScript Version: 3.1.3 Search Terms: try finally block Code async function test(): Promise
Open Graph Description: TypeScript Version: 3.1.3 Search Terms: try finally block Code async function test(): Promise
X Description: TypeScript Version: 3.1.3 Search Terms: try finally block Code async function test(): Promise<string> { let browser: puppeteer.Browser | undefined = undefined; let page: puppeteer.Page | unde...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/28153
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"In finally block, local variable is incorrectly typed as never with return in try block.","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.1.3\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** try finally block \r\n\r\n**Code**\r\n\r\n```ts\r\nasync function test(): Promise\u003cstring> {\r\n let browser: puppeteer.Browser | undefined = undefined;\r\n let page: puppeteer.Page | undefined = undefined;\r\n try {\r\n browser = await test1();\r\n page = await test2(browser);\r\n return await page.content();;\r\n } finally {\r\n if (page) {\r\n await page.close();\r\n }\r\n\r\n if (browser) {\r\n await browser.close();\r\n }\r\n }\r\n}\r\n\r\nasync function test1(): Promise\u003cpuppeteer.Browser> {\r\n return await puppeteer.launch();\r\n}\r\n\r\nasync function test2(browser: puppeteer.Browser): Promise\u003cpuppeteer.Page> {\r\n return await browser.newPage();\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\npage and browser can be of type puppeteer.Page and puppeteer.Browser\r\n\r\n**Actual behavior:**\r\ncompile error message:\r\nerror TS2339: Property 'close' does not exist on type 'never'.\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n#11665(The different is current issue's code contains a return in try block)","author":{"url":"https://github.com/OpenSourceAries","@type":"Person","name":"OpenSourceAries"},"datePublished":"2018-10-26T10:25:23Z","url":"https://github.com/microsoft/TypeScript/issues/28153"}
| 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:46721c4c-d3ea-9a74-5597-45b63123957b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C506:10531B:EB997:12D7F9:6B00F7EC |
| html-safe-nonce | 2a908d181bd012bd7242fb3356acbb8188634e10f6c89a3531df5220383bf5b1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTA2OjEwNTMxQjpFQjk5NzoxMkQ3Rjk6NkIwMEY3RUMiLCJ2aXNpdG9yX2lkIjoiMTM4OTIzNDg5NzcwMDMyMTI2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 77b82b589ad3b379feebb5200953f834b12f90e67179b10b547fab631d923b22 |
| hovercard-subject-tag | issue:374321735 |
| 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/28153/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0c3a0b4eb31243bd14bb59ddca1eb2ff92acc8f350b44f45baaa4fab17105664/microsoft/TypeScript/issues/28153 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0c3a0b4eb31243bd14bb59ddca1eb2ff92acc8f350b44f45baaa4fab17105664/microsoft/TypeScript/issues/28153 |
| og:image:alt | TypeScript Version: 3.1.3 Search Terms: try finally block Code async function test(): Promise |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | OpenSourceAries |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| 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 | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width