Title: add stricter Omit helper type · Issue #30825 · microsoft/TypeScript · GitHub
Open Graph Title: add stricter Omit helper type · Issue #30825 · microsoft/TypeScript
X Title: add stricter Omit helper type · Issue #30825 · microsoft/TypeScript
Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - add stricter Omit helper type · Issue #30825 · microsoft/TypeScript
Open Graph Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - add stricter Omit helper type · Issue #30825 · microsoft/TypeScript
X Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - add stricter Omit helper type · Issue #30825 · microsoft/TypeScript
Opengraph URL: https://github.com/microsoft/TypeScript
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"add stricter Omit helper type","articleBody":"## Search Terms\r\n\r\nomit strict\r\n\r\n## Suggestion\r\n\r\nThe [new `Omit` type](https://github.com/Microsoft/TypeScript/pull/30552) does not restrict the omitted keys to be keys actually present on the given type. There should be some avenue to express \"omit, but only with keys that are present\", likely either a change to `Omit` or some other `Omit`-like type.\r\n\r\n## Use Cases\r\n\r\nCopied from https://github.com/pelotom/type-zoo/pull/31.\r\n\r\nThe benefit that a stricter type has is primarily:\r\n\r\n- Preventing typos.\r\n- Allowing the compiler to pick up on rename refactors automatically.\r\n\r\nCurrently, permissive Omit acts as a \"barrier\" that prevents rename refactors from passing through, which means that any such refactor generates whole bunches of errors that have to be manually fixed. If the field in question is optional, this can actually introduce bugs.\r\n\r\nAnd some further color:\r\n\r\nI generally use `Omit` with string literal unions (as opposed to, say, generic types that `extends string`), because I often use them for defining higher-order React components that wrap another component _except_ for this one prop. As such, in my use case, I never want a permissive `Omit`.\r\n\r\n## Examples\r\n\r\n```tsx\r\ninterface ImplementationDetailProps {\r\n publiclyVisibleFoo: Foo;\r\n filePrivateBar: Bar;\r\n}\r\n\r\nclass ImplementationDetail extends React.Component\u003cImplementationDetailProps> { ... }\r\n\r\nexport type PublicProps = Omit\u003cImplementationDetailProps, \"filePrivateBar\">;\r\n\r\nexport class Public extends React.Component\u003cPublicProps> { ... }\r\n```\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n\r\n* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)\r\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n\r\n","author":{"url":"https://github.com/seansfkelley","@type":"Person","name":"seansfkelley"},"datePublished":"2019-04-09T06:19:33Z","url":"https://github.com/microsoft/TypeScript/issues/30825"}
| 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:79348956-ffbe-8843-7f32-63300129cde1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E014:1DCB8C:24B75C:320058:6B00C0E2 |
| html-safe-nonce | ccc74d7ef8169f5f1710877ab5e726bcea993129136c97b5da552ca5db55e9ba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDE0OjFEQ0I4QzoyNEI3NUM6MzIwMDU4OjZCMDBDMEUyIiwidmlzaXRvcl9pZCI6IjQ3ODA4MjkwMDQ5MzQ0NjM3MTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8faba6de4c025c78744c1b1ab2ba20ef8ef412b958f89882e81a949f6c45591b |
| 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/30825 |
| twitter:image | https://opengraph.githubassets.com/3e9d5e188ae5a0307b24d28eeda8bbd7a786bc386dbbc704481e07491eb63f96/microsoft/TypeScript |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3e9d5e188ae5a0307b24d28eeda8bbd7a786bc386dbbc704481e07491eb63f96/microsoft/TypeScript |
| og:image:alt | TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - add stricter Omit helper type · Issue #30825 · 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 | 93edd3bebc4afb7ce711ee74cb5d2a95927850b082a4d43e212222389cb1c415 |
| 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 | 1fee81a280ea86312b69448e261b418189bfd5b5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width