Skip to content

Commit

Permalink
feat: drop Diff in favor of Exclude
Browse files Browse the repository at this point in the history
We don't need `Diff` any longer since `Exclude` exists (and has for a
while). `Diff` is just a wrapper over `Exclude` now anyways.

BREAKING CHANGE: `Diff` is no longer exported from simplytyped. Can find
and replace `Diff` for `Exclude` to maintain same functionality.
  • Loading branch information
andnp committed Mar 11, 2019
1 parent a2c1162 commit 7b783bc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
3 changes: 1 addition & 2 deletions src/types/objects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Diff } from './strings';
import { False, True } from './conditionals';
import { AnyFunc } from './functions';

Expand Down Expand Up @@ -127,7 +126,7 @@ export type UnionizeProperties<T extends object> = T[Keys<T>];
* @param K the union of keys to remove from `T`
* @returns `T` with the keys `K` removed
*/
export type Omit<T extends object, K extends Keys<T>> = Pick<T, Diff<Keys<T>, K>>;
export type Omit<T extends object, K extends Keys<T>> = Pick<T, Exclude<Keys<T>, K>>;
/**
* Returns only the shared properties between two objects.
* All shared properties must be the same type.
Expand Down
9 changes: 3 additions & 6 deletions src/types/strings.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { True, False, And } from './conditionals';
import { IsNever } from './predicates';

// TODO: this is here only for backwards compatibility
export type Diff<T, U> = Exclude<T, U>;

export type DropString<T extends string, U extends T> = Diff<T, U>;
export type DropString<T extends string, U extends T> = Exclude<T, U>;

export type StringEqual<T extends string, U extends string> =
And<
IsNever<Diff<T, U>>,
IsNever<Diff<U, T>>
IsNever<Exclude<T, U>>,
IsNever<Exclude<U, T>>
>;

export type UnionContains<T, U> = U extends T ? True : False;
15 changes: 0 additions & 15 deletions test/strings/Diff.test.ts

This file was deleted.

0 comments on commit 7b783bc

Please sign in to comment.