Title: Type narrowing not work with inferred function arguments · Issue #45671 · microsoft/TypeScript · GitHub
Open Graph Title: Type narrowing not work with inferred function arguments · Issue #45671 · microsoft/TypeScript
X Title: Type narrowing not work with inferred function arguments · Issue #45671 · microsoft/TypeScript
Description: Bug Report 🔎 Search Terms type narrow argument 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/play?ts=4.4.2#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXwHcYoAHAMTTA...
Open Graph Description: Bug Report 🔎 Search Terms type narrow argument 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/play?ts=4.4.2#code/C...
X Description: Bug Report 🔎 Search Terms type narrow argument 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/play?ts=4.4.2#co...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/45671
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type narrowing not work with inferred function arguments","articleBody":"# Bug Report\r\n\r\n### 🔎 Search Terms\r\n\r\ntype narrow argument\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\n\u003chttps://www.typescriptlang.org/play?ts=4.4.2#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXwHcYoAHAMTTAApEAueKzAD3oGEMmBKeAXgD54ANxxZgnesNEAoUJFgIU6bHnhwAjsixwAyhhhUAzvQN6sqAObihI4FKlmMIGIihgE7JvADeU+PAwAFjA4BIYYUBjIRvCoyAC2AEZOVqgggk4A3FIAvnZQBgCe6EiUyviIAEyMHGwc3D5+ECAY8NEmMGbm8AA+SFAQBgg88GigiGYgwPD506gFvvBYiAwAhAbczAB0gcGhAIwADAecC+qaOnqGJ7lSRKQU6FT5RWAlSrj41SzwHvULTS02qYLD0+gMhiNUGMJlMZlA5gslqt1vAtjsQlRDsdTiANFoQLp9OscidbsRyJQnoViopMB8GMw-o1mq1jMCur0XODeJDoalYQZZvM-EiqGsNhxtkEMViTn4zvjCVd4AB6FXwAA8AFotfAAAYGPWLQXtTqgrmDElSIA>\r\n\r\n### 💻 Code\r\n\r\n```ts\r\ndeclare function wrapFunc(f: (ctx: Ctx) => void): void\r\ndeclare function requireStr(s: string): void\r\n\r\ninterface Ctx {\r\n throw(status: number): never;\r\n}\r\n\r\nasync function f2(ctx: Ctx) {\r\n let s: string | false = undefined as any\r\n if (!s) ctx.throw(100)\r\n requireStr(s)\r\n}\r\n\r\nwrapFunc(async function (ctx: Ctx) {\r\n let s: string | false = undefined as any\r\n if (!s) ctx.throw(100)\r\n requireStr(s)\r\n})\r\n\r\nwrapFunc(async function (ctx) {\r\n let s: string | false = undefined as any\r\n if (!s) ctx.throw(100)\r\n requireStr(s) // \u003c-- Compile Error! here `s` is string | false\r\n})\r\n```\r\n","author":{"url":"https://github.com/weijarz","@type":"Person","name":"weijarz"},"datePublished":"2021-09-01T01:28:25Z","url":"https://github.com/microsoft/TypeScript/issues/45671"}
| 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:706a12bb-7eb3-d972-ee7c-cfd3b723b9f2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C430:3D97C8:C3A0A8:1060874:6B00F978 |
| html-safe-nonce | a3bff7a0b2a427314a4a57e284780f6b342ebc291152dad6a765367ce9c21509 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDMwOjNEOTdDODpDM0EwQTg6MTA2MDg3NDo2QjAwRjk3OCIsInZpc2l0b3JfaWQiOiI3MzA1MzAzNjgyMjE4Nzg1MTQ0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7d900b674eefe955ba8eeb8ef4ca576b0e62063df32352b40b9a8175efdacf18 |
| hovercard-subject-tag | issue:984499266 |
| 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/45671/issue_layout |
| twitter:image | https://opengraph.githubassets.com/441a84ba7c5150d3ae2af0523335028f6b27b2493da7f185e148c930bec3b7ef/microsoft/TypeScript/issues/45671 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/441a84ba7c5150d3ae2af0523335028f6b27b2493da7f185e148c930bec3b7ef/microsoft/TypeScript/issues/45671 |
| og:image:alt | Bug Report 🔎 Search Terms type narrow argument 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/play?ts=4.4.2#code/C... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | weijarz |
| 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