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 +>;