UNPKG

@metamask/keyring-utils

Version:
1 lines 1.45 kB
{"version":3,"file":"typing.cjs","sourceRoot":"","sources":["../src/typing.ts"],"names":[],"mappings":";;AAoCA,gCAEC;AAfD;;;;;;;;;;;GAWG;AACH,6DAA6D;AAC7D,SAAgB,UAAU;IACxB,sBAAsB;AACxB,CAAC","sourcesContent":["/**\n * Omit keys from a union type.\n *\n * The normal `Omit` type does not distribute over unions. So we use this\n * workaround that applies `Omit` to each member of the union.\n *\n * See: <https://github.com/microsoft/TypeScript/issues/31501#issuecomment-1280579305>\n */\nexport type OmitUnion<Type, Key extends keyof any> = Type extends any\n ? Omit<Type, Key>\n : never;\n\n/**\n * Type that resolves to `true` if `Child` extends `Base`, otherwise `false`.\n *\n * @example\n * ```ts\n * type A = Extends<{a: string, b: string}, {a: string}>; // true\n * type B = Extends<{a: string}, {a: string, b: string}>; // false\n * ```\n */\nexport type Extends<Child, Base> = Child extends Base ? true : false;\n\n/**\n * Assert that a type extends `true`. It can be used, for example, to assert\n * that a given type extends another type.\n *\n * @example\n * ```ts\n * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok\n * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error\n * ```\n *\n * This function follows the naming pattern used on `tsd`.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function expectTrue<Type extends true>(): void {\n // Intentionally empty\n}\n"]}