Rocky_Mountain_Vending/.pnpm-store/v10/files/42/a19fca6c4816f801c5d74685a7dfa351b82ad7ecf43751772954f1091779c6ef4435ebceceffd52a5afb17b8576952fa56156b96c981719bb41a1ea972bd89
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

39 lines
1.1 KiB
Text

/**
Extract all optional keys from the given type.
This is useful when you want to create a new type that contains different type values for the optional keys only.
@example
```
import type {OptionalKeysOf, Except} from 'type-fest';
interface User {
name: string;
surname: string;
luckyNumber?: number;
}
const REMOVE_FIELD = Symbol('remove field symbol');
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
};
const update1: UpdateOperation<User> = {
name: 'Alice'
};
const update2: UpdateOperation<User> = {
name: 'Bob',
luckyNumber: REMOVE_FIELD
};
```
@category Utilities
*/
export type OptionalKeysOf<BaseType extends object> =
BaseType extends unknown // For distributing `BaseType`
? (keyof {
[Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never
}) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
: never; // Should never happen