From dd0493d3a05b826467da7ec436d9f8c1eb08eb03 Mon Sep 17 00:00:00 2001 From: rajput-hemant Date: Sat, 16 Dec 2023 17:14:12 +0530 Subject: [PATCH] feat: solved day 15 type challenge Signed-off-by: rajput-hemant --- advent-of-typescript/2023/day_15.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 advent-of-typescript/2023/day_15.ts diff --git a/advent-of-typescript/2023/day_15.ts b/advent-of-typescript/2023/day_15.ts new file mode 100644 index 0000000..81a165f --- /dev/null +++ b/advent-of-typescript/2023/day_15.ts @@ -0,0 +1,29 @@ +import { Equal, Expect } from "type-testing"; + +/* ----------------------------------------------------------------------------------------------- + * Code Here + * -----------------------------------------------------------------------------------------------*/ + +type BoxToys = + // Arr["length"] extends N // this doesn't work w/ union types + N extends Arr["length"] // works + ? Arr + : BoxToys; + +/* ----------------------------------------------------------------------------------------------- + * Do Not Edit Below This Line + * -----------------------------------------------------------------------------------------------*/ + +type test_doll_actual = BoxToys<"doll", 1>; +// ^? +type test_doll_expected = ["doll"]; +type test_doll = Expect>; + +type test_nutcracker_actual = BoxToys<"nutcracker", 3 | 4>; +// ^? +type test_nutcracker_expected = + | ["nutcracker", "nutcracker", "nutcracker"] + | ["nutcracker", "nutcracker", "nutcracker", "nutcracker"]; +type test_nutcracker = Expect< + Equal +>;