1.0.3 • Published 6 months ago

@types/omit v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/omit

Summary

This package contains type definitions for omit (https://github.com/DamonOehlman/omit#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/omit.

index.d.ts

// Type definitions for omit 1.0
// Project: https://github.com/DamonOehlman/omit#readme
// Definitions by: Rajas Paranjpe <https://github.com/ChocolateLoverRaj>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

type Key = string | readonly string[];
type KeyAsStringType<K extends Key> = K extends readonly string[] ? K[number] : K;
type Rule<K extends Key, V> = Key | ((key: K, value: V, target: Record<KeyAsStringType<K>, V>) => boolean);

type OmitMultiple<T, K extends Key> = Pick<T, Exclude<keyof T, KeyAsStringType<K>>>;
type MaybeOmitMultiple<T, K extends Key> = OmitMultiple<T, K> & {
  [P in Extract<keyof T, KeyAsStringType<K>>]?:  T[P]
};

// Static key
declare function omit<K extends Key>(key: K): <T>(target: T) => T extends Array<infer T>
  ? Array<OmitMultiple<T, K>>
  : OmitMultiple<T, K>;
// Static key, with target
declare function omit<T, K extends Key>(key: K, target: T): T extends Array<infer T>
  ? Array<OmitMultiple<T, K>>
  : OmitMultiple<T, K>;
// Custom key
declare function omit<K extends Key>(rule: Rule<K, any>): <T>(target: T) => T extends Array<infer T>
  ? Array<MaybeOmitMultiple<T, K>>
  : MaybeOmitMultiple<T, K>;
// Custom key, with target
declare function omit<T, K extends Key>(key: Rule<K, any>, target: T): T extends Array<infer T>
  ? Array<MaybeOmitMultiple<T, K>>
  : MaybeOmitMultiple<T, K>;

export = omit;

Additional Details

  • Last updated: Wed, 15 Sep 2021 04:31:23 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by Rajas Paranjpe.

1.0.2

7 months ago

1.0.1

8 months ago

1.0.3

6 months ago

1.0.0

3 years ago