diff --git a/.changeset/violet-cherries-clean.md b/.changeset/violet-cherries-clean.md new file mode 100644 index 00000000..6bd63844 --- /dev/null +++ b/.changeset/violet-cherries-clean.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/wonder-stuff-core": minor +--- + +Add Without, Nullable, and TSFixMe helper types diff --git a/packages/wonder-stuff-core/src/types.ts b/packages/wonder-stuff-core/src/types.ts index 02a715de..60e0caed 100644 --- a/packages/wonder-stuff-core/src/types.ts +++ b/packages/wonder-stuff-core/src/types.ts @@ -37,3 +37,28 @@ export type Secrets = {readonly [key: string]: SecretString}; * Make a read-only type mutable. */ export type Mutable = {-readonly [P in keyof T]: T[P]}; + +/** + * Remove the keys in `R` from `C`. + */ +export type Without = Omit; + +/** + * Opposite of `NonNullable`. + * + * This type is most useful in making code that's been converted from Flow + * to TypeScript more readable. + */ +export type Nullable = T | null | undefined; + +/** + * This type can be used in place of `any` to indicate that we don't know + * what the type is, but we know that it is wrong and needs to be fixed. + * + * It's similar to $FlowFixMe in Flow. + * + * This should be used in situations where `@ts-expect-error` cannot be used + * or should not be used (as is the case with type errors on props in JSX + * elements). + */ +export type TSFixMe = Message & any;