diff --git a/advent-of-typescript/2023/day_05.ts b/advent-of-typescript/2023/day_05.ts new file mode 100644 index 0000000..896addb --- /dev/null +++ b/advent-of-typescript/2023/day_05.ts @@ -0,0 +1,48 @@ +import { Equal, Expect } from "type-testing"; + +/* ----------------------------------------------------------------------------------------------- + * Code here + * -----------------------------------------------------------------------------------------------*/ + +type SantasList = [ + ...T, + ...U, +]; + +/* ----------------------------------------------------------------------------------------------- + * Do not edit below this line + * -----------------------------------------------------------------------------------------------*/ + +const bads = ["tommy", "trash"] as const; +const goods = ["bash", "tru"] as const; + +type test_0_actual = SantasList; +// ^? +type test_0_expected = ["tommy", "trash", "bash", "tru"]; +type test_0 = Expect>; + +type test_1_actual = SantasList<[], []>; +// ^? +type test_1_expected = []; +type test_1 = Expect>; + +type test_2_actual = SantasList<[], ["trash"]>; +// ^? +type test_2_expected = ["trash"]; +type test_2 = Expect>; + +type test_3_actual = SantasList<["john"], ["ashley", "elliot", "ziltoid"]>; +// ^? +type test_3_expected = ["john", "ashley", "elliot", "ziltoid"]; +type test_3 = Expect>; + +type test_4_actual = SantasList< + ["1", 2, "3"], + [false, boolean, "4", ["nested"]] +>; +// ^? +type test_4_expected = ["1", 2, "3", false, boolean, "4", ["nested"]]; +type test_4 = Expect>; + +// @ts-expect-error +type error_0 = SantasList; diff --git a/advent-of-typescript/2023/day_06.ts b/advent-of-typescript/2023/day_06.ts new file mode 100644 index 0000000..c24f0bd --- /dev/null +++ b/advent-of-typescript/2023/day_06.ts @@ -0,0 +1,35 @@ +import { Equal, Expect } from "type-testing"; + +/* ----------------------------------------------------------------------------------------------- + * Code here + * -----------------------------------------------------------------------------------------------*/ + +type FilterChildrenBy = Exclude; + +/* ----------------------------------------------------------------------------------------------- + * Do not edit below this line + * -----------------------------------------------------------------------------------------------*/ + +type test_0_actual = FilterChildrenBy< + // ^? + "nice" | "nice" | "nice", + "naughty" +>; +type test_0_expected = "nice"; +type test_0 = Expect>; + +type test_1_actual = FilterChildrenBy< + // ^? + "nice" | "naughty" | "naughty", + "naughty" +>; +type test_1_expected = "nice"; +type test_1 = Expect>; + +type test_2_actual = FilterChildrenBy< + // ^? + string | number | (() => void), + Function +>; +type test_2_expected = string | number; +type test_2 = Expect>; diff --git a/package.json b/package.json index c4d6f1c..732c469 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "lint-staged": { "*.ts": [ "oxlint --fix .", - "prettier . --cache" + "prettier ." ] }, "commitlint": {