type-fest
type-fest copied to clipboard
A collection of essential TypeScript types
Hello, For use, the `ArrayElement` type is super convenient, yet we can only import it from the `type-fest/source/internal` path. In Deno this causes some import issues so I was wondering...
typescript: 5.1.6 type `JsonObject` not limit Object key type like symbol ```typescript const a = {[Symbol(1)]: 1} function test(v: JsonObject) {} // issue test(a) // no ts error, should throw...
Example: ``` type O = { record: { nestedrecord: { nestedProp?: string } } } ``` `SetRequired` would have type ``` { record: { nestedrecord: { nestedProp: string } }...
```ts type KeysOfType = { [K in keyof T]: T[K] extends U ? K : never; }[keyof T]; ``` ## Upvote & Fund - We're using [Polar.sh](https://polar.sh/sindresorhus) so you can...
```ts export type NonEmpty = [T, ...T[]]; ``` Context: https://github.com/sindresorhus/type-fest/pull/287 Why add such a simple type? Mostly for readability and discoverability. Most people don't know about this trick and we...
See [this issue](https://github.com/microsoft/TypeScript/issues/55535), specifically [this comment](https://github.com/microsoft/TypeScript/issues/55535#issuecomment-1703854817). Using a recursively mapped type like `RequiredDeep` comes with a side effect: even though VS Code seems to resolve the type, the type-checker ignores...
I am working on a TypeScript project where I need to transform a type with optional properties into a type where the `optional` properties are replaced with union types that...
Fairly straightforward type but quite useful. It's often that APIs will have a function that accepts `string | string[]` or similarly `string | FooType | string[] | FooType[]`. It would...
## Short summary Given: * `TupleType`: a tuple of similar objects * `KeyProperty`: a key that is... * Present on every object in the tuple * Used to hold `string`...
I would like to know if it is possible to have a scenario like this one: ``` type A = { a: string; b: number; c: boolean; d: boolean; e:...