Skip to content

fix: simpler solution + alternative to 02ex07 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions 02-assignability-and-conditional-types/solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ namespace bonus {
type test4 = Get<{ name: string }, "age">;
}

namespace seven {
type XOR<bool1, bool2> = [bool1, bool2] extends [true, true]
? false
: [bool1, bool2] extends [false, false]
? false
: true;
namespace seven {
type XOR<bool1, bool2> = bool1 extends bool2 ? false : true;
// alternative
// type XOR2<bool1, bool2> = [bool1, bool2] extends
// | [true, true]
// | [false, false]
// ? false
// : true;

type res1 = XOR<true, true>;
type t1 = Expect<Equal<res1, false>>;
Expand Down