Skip to content

Commit

Permalink
# is now //
Browse files Browse the repository at this point in the history
  • Loading branch information
px-d committed Jan 2, 2025
1 parent c5848bf commit 7eaa39f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion public/consolidated/typescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"typedefinition"
],
"contributors": [],
"code": "type Exclusive<T, U = T> = T | U extends Record<string, unknown>\n ?\n | ({ [P in Exclude<keyof T, keyof U>]?: never } & U)\n | ({ [P in Exclude<keyof U, keyof T>]?: never } & T)\n : T | U;\n\n\n# Usage:\ntype A = { name: string; email?: string; provider?: string };\ntype B = { name: string; phone?: string; country?: string };\n\ntype EitherOr = Exclusive<A, B>;\n\nconst w: EitherOr = { name: \"John\", email: \"[email protected]\" }; // ✅\nconst x: EitherOr = { name: \"John\", phone: \"+123 456\" }; // ✅\nconst y: EitherOr = { name: \"John\", email: \"\", phone: \"\" }; // ⛔️\nconst z: EitherOr = { name: \"John\", phne: \"\", provider: \"\" }; // ⛔️\n"
"code": "type Exclusive<T, U = T> = T | U extends Record<string, unknown>\n ?\n | ({ [P in Exclude<keyof T, keyof U>]?: never } & U)\n | ({ [P in Exclude<keyof U, keyof T>]?: never } & T)\n : T | U;\n\n\n// Usage:\ntype A = { name: string; email?: string; provider?: string };\ntype B = { name: string; phone?: string; country?: string };\n\ntype EitherOr = Exclusive<A, B>;\n\nconst w: EitherOr = { name: \"John\", email: \"[email protected]\" }; // ✅\nconst x: EitherOr = { name: \"John\", phone: \"+123 456\" }; // ✅\nconst y: EitherOr = { name: \"John\", email: \"\", phone: \"\" }; // ⛔️\nconst z: EitherOr = { name: \"John\", phne: \"\", provider: \"\" }; // ⛔️\n"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion snippets/typescript/helper-types/exclusive-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Exclusive<T, U = T> = T | U extends Record<string, unknown>
: T | U;


# Usage:
// Usage:
type A = { name: string; email?: string; provider?: string };
type B = { name: string; phone?: string; country?: string };

Expand Down

0 comments on commit 7eaa39f

Please sign in to comment.