From bce557cc2dc767628bed6aac87301a1be7c5431b Mon Sep 17 00:00:00 2001 From: rxliuli Date: Tue, 4 Nov 2025 05:03:50 +0800 Subject: init commit --- src/utils/types.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/utils/types.ts (limited to 'src/utils/types.ts') diff --git a/src/utils/types.ts b/src/utils/types.ts new file mode 100644 index 0000000..4cb85aa --- /dev/null +++ b/src/utils/types.ts @@ -0,0 +1,17 @@ +/** + * Determine if {@linkcode input} matches the `"object"` type + */ +export function isObject(input: unknown): input is object { + return typeof input === 'object' && !!input; +} + +type Without = { [P in Exclude]?: never }; + +/** + * Helper type for creating an exclusive union between two types + * + * @see {@link https://stackoverflow.com/a/53229567/2250435 | StackOverflow Post} + */ +export type XOR = T | U extends object + ? (Without & U) | (Without & T) + : T | U; -- cgit v1.2.3