Title: Typing for object deep paths · Issue #12290 · microsoft/TypeScript · GitHub
Open Graph Title: Typing for object deep paths · Issue #12290 · microsoft/TypeScript
X Title: Typing for object deep paths · Issue #12290 · microsoft/TypeScript
Description: Recently introduces keyof operator will work well for typing functions that accept properties directly on target type. interface Some { a: number, b: string } type oneOfTheSomeKeys = keyof Some // restricts value to "a", "b" What do you ...
Open Graph Description: Recently introduces keyof operator will work well for typing functions that accept properties directly on target type. interface Some { a: number, b: string } type oneOfTheSomeKeys = keyof Some // ...
X Description: Recently introduces keyof operator will work well for typing functions that accept properties directly on target type. interface Some { a: number, b: string } type oneOfTheSomeKeys = keyof Some // ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/12290
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Typing for object deep paths","articleBody":"Recently introduces [`keyof`](https://github.com/Microsoft/TypeScript/pull/11929#issuecomment-260856694) operator will work well for typing functions that accept properties directly on target type.\r\n\r\n```ts\r\ninterface Some {\r\n a: number,\r\n b: string\r\n}\r\n\r\ntype oneOfTheSomeKeys = keyof Some // restricts value to \"a\", \"b\"\r\n```\r\n What do you think, is it possible in theory to type deeply nested paths, so that for type:\r\n```ts\r\ninterface Some {\r\n a: number,\r\n b: {\r\n c: number\r\n d: {\r\n e: number\r\n }\r\n }\r\n}\r\n```\r\nso that it would be possible to restrict possible path values to:\r\n\r\n```\r\n[\"a\"]\r\n[\"b\"]\r\n[\"b\", \"c\"]\r\n[\"b\", \"d\"]\r\n[\"b\", \"d, \"e\"]\r\n```\r\nThis actual for such methods like [ramda's `path`](http://ramdajs.com/docs/#path):\r\n```js\r\nR.path(['a', 'b'], {a: {b: 2}}); //=> 2\r\nR.path(['a', 'b'], {c: {b: 2}}); //=> undefined\r\n```\r\n?","author":{"url":"https://github.com/wclr","@type":"Person","name":"wclr"},"datePublished":"2016-11-16T05:32:21Z","url":"https://github.com/microsoft/TypeScript/issues/12290"}
| 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:695e3d84-1251-b90d-6882-518947b23c08 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E888:C2718:AD8FCB:E1CF6F:6B00EA1A |
| html-safe-nonce | 9b2b83688c5d0c58ac1c2af452d6a429fa7f81de71e13389429332e5a19888f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODg4OkMyNzE4OkFEOEZDQjpFMUNGNkY6NkIwMEVBMUEiLCJ2aXNpdG9yX2lkIjoiMzQzNzk0MzY0Mzc0MTE1MzgxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7289bd9e28b2be1b58ef51ddb67236caee92f6168b7cb62c00f936aaefa0b89f |
| hovercard-subject-tag | issue:189595168 |
| 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/12290/issue_layout |
| twitter:image | https://opengraph.githubassets.com/912a6074d2d3bda674bf9664f5e618ab448ecfcaaa035a8c31be2f499363a02f/microsoft/TypeScript/issues/12290 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/912a6074d2d3bda674bf9664f5e618ab448ecfcaaa035a8c31be2f499363a02f/microsoft/TypeScript/issues/12290 |
| og:image:alt | Recently introduces keyof operator will work well for typing functions that accept properties directly on target type. interface Some { a: number, b: string } type oneOfTheSomeKeys = keyof Some // ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wclr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width