feat(typescript-types): Add Get<O, P>

This commit is contained in:
T. R. Bernstein
2025-07-18 13:29:54 +02:00
parent 5461fc52b4
commit ac53d1e584
3 changed files with 46 additions and 0 deletions

View File

@@ -46,12 +46,14 @@ The types included in this library are categorized by their purpose.
| Type | Description |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`Get<O, P>`][] | Extract the type of the item at keypath `P` in object `O`. |
| [`KeyPaths<T, O, F>`][] | A union of all keypaths of `T` where the value does not extend `F`. Separator can be set via `O['separator']`. |
| [`OptionalKeysOf<T>`][] | A union of all keys of `T` that are marked as optional. If `T` is a union, a union of the optional keys of all union members of `T` is returned[^optional-keys-of_remark]. |
| [`PickAssignable<T, K>`][] | Return a mapped type with all keys of `T` that extend `K`. If no key does extend `K` an empty type is returned. |
[^optional-keys-of_remark]: If `T` is `any`, it returns a union of string and number 'string | number'.
[`Get<O, P>`]: src/get.ts
[`KeyPaths<T, O, F>`]: src/key-paths.ts
[`OptionalKeysOf<T>`]: src/optional-keys-of.ts
[`PickAssignable<T, K>`]: src/pick-assignable.ts