Title: Cannot infer type in generic Readonly · Issue #14360 · microsoft/TypeScript · GitHub
Open Graph Title: Cannot infer type in generic Readonly · Issue #14360 · microsoft/TypeScript
X Title: Cannot infer type in generic Readonly · Issue #14360 · microsoft/TypeScript
Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Cannot infer type in generic Readonly · Issue #14360 · microsoft/TypeScript
Open Graph Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Cannot infer type in generic Readonly · Issue #14360 · microsoft/TypeScript
X Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Cannot infer type in generic Readonly · Issue #14360 · microsoft/TypeScript
Opengraph URL: https://github.com/microsoft/TypeScript
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot infer type in generic Readonly","articleBody":"\u003c!-- BUGS: Please use this template. -->\r\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\r\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\r\n\r\n**TypeScript Version:** 2.2.1\r\n\r\n**Code**\r\n\r\n```ts\r\ninterface A {\r\n b?(): void\r\n}\r\n\r\nfunction works\u003cT extends A>(a: T) {\r\n if (a.b) a.b()\r\n}\r\n\r\nfunction worksToo(a: Readonly\u003cA>) {\r\n if (a.b) a.b()\r\n}\r\n\r\nfunction doesntWork\u003cT extends A>(a: Readonly\u003cT>) {\r\n if (a.b) a.b()\r\n // Cannot invoke an expression whose type lacks a call signature.\r\n // Type '(() => void) | undefined' has no compatible call signatures.\r\n}\r\n```\r\n\r\nNote that there is no `Object is possibly 'undefined'` message here.\r\n\r\n**Expected behavior:**\r\nAfter `if` check method should be considered defined.\r\n**Actual behavior:**\r\nMember type is not inferred correctly.","author":{"url":"https://github.com/anvish","@type":"Person","name":"anvish"},"datePublished":"2017-02-28T11:50:20Z","url":"https://github.com/microsoft/TypeScript/issues/14360"}
| 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 | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:70ba3dc5-dabc-ef54-92fd-120161094b6e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC3C:34DB8F:B61BE5:F44A64:6B00F8BC |
| html-safe-nonce | 49702087eb38fd769dd5120a8e2f0ffda06f2c551fdaa38518f1ec8efba149c2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzNDOjM0REI4RjpCNjFCRTU6RjQ0QTY0OjZCMDBGOEJDIiwidmlzaXRvcl9pZCI6Ijc2MDkxOTc1MDM0NTEyOTc5ODAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ac23fb472b124fa4b23a6a8a820b4882fda7934176c15f4100dcd257b4ea35d1 |
| hovercard-subject-tag | repository:20929025 |
| 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/microsoft/TypeScript/issues/14360 |
| twitter:image | https://opengraph.githubassets.com/7f74c95cbe889dbb3d9b1bf9b33e028a73710cb2fdd6519734f41a069c8c2bfa/microsoft/TypeScript |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7f74c95cbe889dbb3d9b1bf9b33e028a73710cb2fdd6519734f41a069c8c2bfa/microsoft/TypeScript |
| og:image:alt | TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Cannot infer type in generic Readonly · Issue #14360 · microsoft/TypeScript |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| turbo-cache-control | no-cache |
| 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