mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-24 10:39:15 +01:00
* [Test] Improve error message on `toHaveUsedMove` * Fixed typing on test stuff + added caching on `toHaveArenaTagOptions` * Fixed matcher breaking with single move arguments * Fixed typing errors in `vitest.d.ts` * Fixed typing importing from the wrong file * Fixed wish test type errors * Reverted type changes to battler tag matchers by request
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import type { AtLeastOne, NonFunctionProperties } from "#types/type-helpers";
|
|
|
|
/**
|
|
* Helper type to admit an object containing the given properties
|
|
* _and_ at least 1 other non-function property.
|
|
* @example
|
|
* ```ts
|
|
* type foo = {
|
|
* qux: 1 | 2 | 3,
|
|
* bar: number,
|
|
* baz: string
|
|
* quux: () => void; // ignored!
|
|
* }
|
|
*
|
|
* type quxAndSomethingElse = OneOther<foo, "qux">
|
|
*
|
|
* const good1: quxAndSomethingElse = {qux: 1, bar: 3} // OK!
|
|
* const good2: quxAndSomethingElse = {qux: 2, baz: "4", bar: 12} // OK!
|
|
* const bad1: quxAndSomethingElse = {baz: "4", bar: 12} // Errors because `qux` is required
|
|
* const bad2: quxAndSomethingElse = {qux: 1} // Errors because at least 1 thing _other_ than `qux` is required
|
|
* ```
|
|
* @typeParam O - The object to source keys from
|
|
* @typeParam K - One or more of O's keys to render mandatory
|
|
*/
|
|
// NB: no need to recursively exclude non function properties
|
|
// TODO: Figure out how to force K to not be a method property
|
|
export type OneOther<O extends object, K extends keyof O> = Pick<O, K> & AtLeastOne<Omit<NonFunctionProperties<O>, K>>;
|