Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export {};

declare global {
/**
* Allows extracting all possible values of another type.
*/
type ValueOf<T> = T[keyof T];

/**
* Like Partial utility type, only this allows specifying select keys
* to be made optional instead of all keys.
*/
type Optional<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>

/**
* A slightly nicer way of defining nullable types.
*/
type Nullable<T> = T | null;

/**
* Replace the type for specified keys of a type.
*/
type Replace<T, K extends keyof T, R> = Omit<T, K> & { [key in K]: R };
}