Title: Proposal: Mapped Types syntax to remove modifiers · Issue #13723 · microsoft/TypeScript · GitHub
Open Graph Title: Proposal: Mapped Types syntax to remove modifiers · Issue #13723 · microsoft/TypeScript
X Title: Proposal: Mapped Types syntax to remove modifiers · Issue #13723 · microsoft/TypeScript
Description: Current TypeScript Version: 2.1.1 We have a syntax to add "readonly" to every property of a type. Unfortunately, it seems there is no way to have the reverse operation: removing it. This is useful for creating Mocked version of types for...
Open Graph Description: Current TypeScript Version: 2.1.1 We have a syntax to add "readonly" to every property of a type. Unfortunately, it seems there is no way to have the reverse operation: removing it. This is useful ...
X Description: Current TypeScript Version: 2.1.1 We have a syntax to add "readonly" to every property of a type. Unfortunately, it seems there is no way to have the reverse operation: removing it. This ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/13723
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: Mapped Types syntax to remove modifiers","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\nCurrent **TypeScript Version:** 2.1.1\r\n\r\nWe have a syntax to add \"readonly\" to every property of a type. Unfortunately, it seems there is no way to have the reverse operation: removing it.\r\nThis is useful for creating Mocked version of types for UTs, which have readonly fields in production.\r\n\r\nThis should work recursively.\r\n\r\n**Code**\r\n```ts\r\ninterface MyType2 {\r\n readonly z1: number;\r\n z2: string;\r\n}\r\n\r\ninterface MyType {\r\n readonly a: number;\r\n readonly b: MyType2;\r\n c: string;\r\n d: MyType2;\r\n}\r\n\r\ntype Mock\u003cT> {\r\n [P in keyofwithoutmodifiers T]: Mock\u003cT[P]>;\r\n}\r\n\r\ntype MyMockedType = Mock\u003cMyType>;\r\n```\r\n\r\n**Expected behavior:**\r\ntype MyMockedType to be\r\n```ts\r\n{\r\n a: number;\r\n b: { z1: number; z2: string };\r\n c: string;\r\n d: { z1: number; z2: string };\r\n}\r\n```\r\n\r\n**Actual behavior:**\r\nnot possible right now","author":{"url":"https://github.com/marcomura","@type":"Person","name":"marcomura"},"datePublished":"2017-01-27T14:51:05Z","url":"https://github.com/microsoft/TypeScript/issues/13723"}
| 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:43136b8c-a427-20fc-d182-30d275d6f1bb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9370:7C906:9D700C:D4ACCA:6B053B77 |
| html-safe-nonce | 9da267fc8a5c657f54e4c3a6389fa02d3193f0d5f20b8ccb49c0ee91ce6637e6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzcwOjdDOTA2OjlENzAwQzpENEFDQ0E6NkIwNTNCNzciLCJ2aXNpdG9yX2lkIjoiMjU1MDM3NTA5MjgxMTI4MzMxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 146d9ecb20ffe9d2f03520089c02dc0161858bea8212d159724c9f4a3986dda1 |
| hovercard-subject-tag | issue:203653895 |
| 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/13723/issue_layout |
| twitter:image | https://opengraph.githubassets.com/74173980fcd46cafe99d4c2699f1ac11ba0c09dab4b67851d75ce551445aa731/microsoft/TypeScript/issues/13723 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/74173980fcd46cafe99d4c2699f1ac11ba0c09dab4b67851d75ce551445aa731/microsoft/TypeScript/issues/13723 |
| og:image:alt | Current TypeScript Version: 2.1.1 We have a syntax to add "readonly" to every property of a type. Unfortunately, it seems there is no way to have the reverse operation: removing it. This is useful ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | marcomura |
| hostname | github.com |
| expected-hostname | github.com |
| None | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| 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 | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width