Title: Typescript incorrectly infer the types for Readonly optional properties. · Issue #18902 · microsoft/TypeScript · GitHub
Open Graph Title: Typescript incorrectly infer the types for Readonly optional properties. · Issue #18902 · microsoft/TypeScript
X Title: Typescript incorrectly infer the types for Readonly optional properties. · Issue #18902 · microsoft/TypeScript
Description: TypeScript Version: 2.5.3) / 2.6.0-dev.20170930 Code https://github.com/dryganets/typescript-bug/blob/master/index.ts I expect this code to compile. This example is Expected behavior: type guard if (this.props.a) { } reduces the type fro...
Open Graph Description: TypeScript Version: 2.5.3) / 2.6.0-dev.20170930 Code https://github.com/dryganets/typescript-bug/blob/master/index.ts I expect this code to compile. This example is Expected behavior: type guard if...
X Description: TypeScript Version: 2.5.3) / 2.6.0-dev.20170930 Code https://github.com/dryganets/typescript-bug/blob/master/index.ts I expect this code to compile. This example is Expected behavior: type guard if...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/18902
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Typescript incorrectly infer the types for Readonly optional properties.","articleBody":"\u003c!-- BUGS: Please use this template. -->\r\n\r\n\r\n**TypeScript Version:** 2.5.3) / 2.6.0-dev.20170930\r\n\r\n**Code**\r\n\r\nhttps://github.com/dryganets/typescript-bug/blob/master/index.ts\r\nI expect this code to compile.\r\nThis example is\r\n**Expected behavior:**\r\ntype guard\r\n```\r\nif (this.props.a) {\r\n}\r\n```\r\n\r\nreduces the type from string|undefined to string.\r\n\r\n**Actual behavior:**\r\ntype is still string|undefined after check.\r\n\r\nThe bug doesn't repro if I use the slightly different syntax:\r\n\r\n```\r\nexport class Test extends ComponentBase\u003cProps, {}> {\r\n\r\n```\r\n\r\nBut we have some places in the app where the former syntax is required.\r\n","author":{"url":"https://github.com/dryganets","@type":"Person","name":"dryganets"},"datePublished":"2017-10-03T00:38:05Z","url":"https://github.com/microsoft/TypeScript/issues/18902"}
| 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:d9615b2f-a5a2-3a2c-4ce0-12348dc1d90a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D670:3D97C8:1015142:1575585:6B011212 |
| html-safe-nonce | 7854454629e9c1d9736e12fb7142aad9659eb3b34f589c86f28a6e53c5a30d28 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjcwOjNEOTdDODoxMDE1MTQyOjE1NzU1ODU6NkIwMTEyMTIiLCJ2aXNpdG9yX2lkIjoiNzY4NTU1MjUyMTUwNjUyNTcxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 94f9731145132b8c2d5d17873ef205bc3fcf5a9b1c8808c665d0262d2b99efd9 |
| hovercard-subject-tag | issue:262270895 |
| 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/18902/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4e9c2ccca54e2c42aa0e9c7a2bb01ee4883a7788b3ab563b5c52d10a0e420da3/microsoft/TypeScript/issues/18902 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4e9c2ccca54e2c42aa0e9c7a2bb01ee4883a7788b3ab563b5c52d10a0e420da3/microsoft/TypeScript/issues/18902 |
| og:image:alt | TypeScript Version: 2.5.3) / 2.6.0-dev.20170930 Code https://github.com/dryganets/typescript-bug/blob/master/index.ts I expect this code to compile. This example is Expected behavior: type guard if... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dryganets |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width