Title: Assertion function & Type guards for Record types broken on 5.0 · Issue #53379 · microsoft/TypeScript · GitHub
Open Graph Title: Assertion function & Type guards for Record types broken on 5.0 · Issue #53379 · microsoft/TypeScript
X Title: Assertion function & Type guards for Record types broken on 5.0 · Issue #53379 · microsoft/TypeScript
Description: 🔎 Search Terms asserts assertion function type guard record 🕗 Version & Regression Information Worked on 4.9, broken since 5.0 Probably introduced by #52984 ⏯ Playground Link Playground link with relevant code 💻 Code declare function isO...
Open Graph Description: 🔎 Search Terms asserts assertion function type guard record 🕗 Version & Regression Information Worked on 4.9, broken since 5.0 Probably introduced by #52984 ⏯ Playground Link Playground link with r...
X Description: 🔎 Search Terms asserts assertion function type guard record 🕗 Version & Regression Information Worked on 4.9, broken since 5.0 Probably introduced by #52984 ⏯ Playground Link Playground link wi...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/53379
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Assertion function & Type guards for Record types broken on 5.0 ","articleBody":"### 🔎 Search Terms\r\n* asserts\r\n* assertion function\r\n* type guard\r\n* record\r\n\r\n### 🕗 Version & Regression Information\r\n\r\nWorked on 4.9, broken since 5.0 \r\n\r\nProbably introduced by #52984\r\n\r\n### ⏯ Playground Link\r\n\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?ts=5.0.2#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXywGcB5AIwCtwMAKHALnjQGtUcB3VASgZwMPgBK4HDGAAeQhhhZUAcwA08KKgCeAPgBQG0JFgIU6bHiWFCIGBjKVMtBs1YduJsxf68ig4aIlSZCpapq8PBaECAY8ABuUBDIIAwA3gC+8AC88KjIEBAAhADcGliI1ERWVNTRsSCcnPAJGsHBlXEAdMoqGAAWfvAA9L3w5jAi8IQyYAgArC0ADC0ATBpJWlCm5pYU5c3VWtttql09-YMwwzCj41OzC0A)\r\n\r\n### 💻 Code\r\n\r\n\u003c!-- Please post the relevant code sample here as well-->\r\n```ts\r\ndeclare function isObject(o: unknown): o is Record\u003cstring, any>\r\n\r\ndeclare function assertObject(o: unknown): asserts o is Record\u003cstring, any> \r\n\r\nlet value: {} = null!;\r\nif(isObject(value)) {\r\n value.anything // error since 5.0.2\r\n}\r\n\r\nassertObject(value)\r\n\r\nvalue.anything // error since 5.0.2\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\n`Property 'anything' does not exist on type '{}'.(2339)`\r\n\r\n### 🙂 Expected behavior\r\n\r\nNo error, narrowing / assertion should work fine. \r\n\r\n\u003c!-- \r\nSO issue : https://stackoverflow.com/questions/75790945/typescript-weird-type-inference-when-checking-null-or-undefined\r\n-->","author":{"url":"https://github.com/JeanMeche","@type":"Person","name":"JeanMeche"},"datePublished":"2023-03-20T14:33:10Z","url":"https://github.com/microsoft/TypeScript/issues/53379"}
| 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:2c258c7c-8f96-2c62-2b99-2b93d1f27602 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B726:AC6A2:15B257:1C8690:6B0162E5 |
| html-safe-nonce | 0f9705f53e76a808f5974c72f08c00c01bcb085e3c38c5bbda0b7620b15f3037 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzI2OkFDNkEyOjE1QjI1NzoxQzg2OTA6NkIwMTYyRTUiLCJ2aXNpdG9yX2lkIjoiNDYxNzc0ODUzNDA2NDY2OTQxMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 99296bc08f78443862b30c6c60b7699bbf3654e6db5cc8e2add533683c56d31b |
| hovercard-subject-tag | issue:1632239951 |
| 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/53379/issue_layout |
| twitter:image | https://opengraph.githubassets.com/46b3501bfd7e803b9eea35ad42e8ca68d3d18cc2876f23af45c7ffc9a8ca2ddd/microsoft/TypeScript/issues/53379 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/46b3501bfd7e803b9eea35ad42e8ca68d3d18cc2876f23af45c7ffc9a8ca2ddd/microsoft/TypeScript/issues/53379 |
| og:image:alt | 🔎 Search Terms asserts assertion function type guard record 🕗 Version & Regression Information Worked on 4.9, broken since 5.0 Probably introduced by #52984 ⏯ Playground Link Playground link with r... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JeanMeche |
| 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