-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: solved day 7 & 8 type challenges
Signed-off-by: rajput-hemant <rajput.hemant2001@gmail.com>
- Loading branch information
1 parent
c3ac00e
commit 3b964a9
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Equal, Expect } from "type-testing"; | ||
|
||
type AppendGood<T> = { [K in keyof T as `good_${string & K}`]: T[K] }; | ||
|
||
/* ----------------------------------------------------------------------------------------------- | ||
* Code Here | ||
* -----------------------------------------------------------------------------------------------*/ | ||
|
||
/* ----------------------------------------------------------------------------------------------- | ||
* Do not edit below this line | ||
* -----------------------------------------------------------------------------------------------*/ | ||
|
||
type WellBehavedList = { | ||
tom: { address: "1 candy cane lane" }; | ||
timmy: { address: "43 chocolate dr" }; | ||
trash: { address: "637 starlight way" }; | ||
candace: { address: "12 aurora" }; | ||
}; | ||
type test_wellBehaved_actual = AppendGood<WellBehavedList>; | ||
// ^? | ||
type test_wellBehaved_expected = { | ||
good_tom: { address: "1 candy cane lane" }; | ||
good_timmy: { address: "43 chocolate dr" }; | ||
good_trash: { address: "637 starlight way" }; | ||
good_candace: { address: "12 aurora" }; | ||
}; | ||
type test_wellBehaved = Expect< | ||
Equal<test_wellBehaved_expected, test_wellBehaved_actual> | ||
>; | ||
|
||
type Unrelated = { | ||
dont: "cheat"; | ||
play: "fair"; | ||
}; | ||
type test_Unrelated_actual = AppendGood<Unrelated>; | ||
// ^? | ||
type test_Unrelated_expected = { | ||
good_dont: "cheat"; | ||
good_play: "fair"; | ||
}; | ||
type test_Unrelated = Expect< | ||
Equal<test_Unrelated_expected, test_Unrelated_actual> | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Equal, Expect } from "type-testing"; | ||
|
||
/* ----------------------------------------------------------------------------------------------- | ||
* Code here | ||
* -----------------------------------------------------------------------------------------------*/ | ||
|
||
type RemoveNaughtyChildren<T> = { | ||
[K in keyof T as K extends `naughty_${string}` ? never : K]: T[K]; | ||
}; | ||
|
||
/* ----------------------------------------------------------------------------------------------- | ||
* Do not edit below this line | ||
* -----------------------------------------------------------------------------------------------*/ | ||
|
||
type SantasList = { | ||
naughty_tom: { address: "1 candy cane lane" }; | ||
good_timmy: { address: "43 chocolate dr" }; | ||
naughty_trash: { address: "637 starlight way" }; | ||
naughty_candace: { address: "12 aurora" }; | ||
}; | ||
type test_wellBehaved_actual = RemoveNaughtyChildren<SantasList>; | ||
// ^? | ||
type test_wellBehaved_expected = { | ||
good_timmy: { address: "43 chocolate dr" }; | ||
}; | ||
type test_wellBehaved = Expect< | ||
Equal<test_wellBehaved_expected, test_wellBehaved_actual> | ||
>; | ||
|
||
type Unrelated = { | ||
dont: "cheat"; | ||
naughty_play: "fair"; | ||
}; | ||
type test_Unrelated_actual = RemoveNaughtyChildren<Unrelated>; | ||
// ^? | ||
type test_Unrelated_expected = { | ||
dont: "cheat"; | ||
}; | ||
type test_Unrelated = Expect< | ||
Equal<test_Unrelated_expected, test_Unrelated_actual> | ||
>; |