Skip to content

Commit 973b68b

Browse files
author
Limon Monte
authored
fix(typescript): replace Diff type with new built-in Exclude type (#43)
1 parent b270d6b commit 973b68b

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/sweetalert2-react-content.d.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,8 @@ interface ReactOptions {
4141
footer?: ReactElementOr<'footer'>;
4242
}
4343

44-
// Diff<> and Owerwrite<> types below are inspired from this GitHub comment:
45-
// https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-307871458
46-
47-
// Diff<T, U> is a subtraction operator for string literal types.
48-
// It returns the string types of T that are not in U.
49-
// ex: Diff<('a' | 'b' | 'c'), ('c' | 'd')>; // 'a' | 'b'
50-
type Diff<T extends string, U extends string> =
51-
({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];
52-
5344
// Overwrite<T, U> will take the properties of U and add to it the properties of T that are not in U.
5445
// This emulates an overwrite (override) of chosen properties of T with properties of U.
5546
// It works like { ...T, ...U } in JS.
56-
type Overwrite<T, U> = Pick<T, Diff<keyof T, keyof U>> & U;
47+
// https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-393936055
48+
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;

0 commit comments

Comments
 (0)