From 91ecf2655ba4d53fbefdf86bfe08a64b4198ce3c Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 8 May 2025 21:43:55 -0400 Subject: [PATCH 1/2] fix: correct reversed types in 03-split-on --- .../03-split-on/solution.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/projects/type-operations/template-literal-type-shenanigans/03-split-on/solution.ts b/projects/type-operations/template-literal-type-shenanigans/03-split-on/solution.ts index 1cd5d76..ef75ebf 100644 --- a/projects/type-operations/template-literal-type-shenanigans/03-split-on/solution.ts +++ b/projects/type-operations/template-literal-type-shenanigans/03-split-on/solution.ts @@ -3,5 +3,11 @@ export type SplitOn< On extends string, Results extends string[] = [], > = Text extends `${infer Prefix}${On}${infer Suffix}` - ? SplitOn - : [Text, ...Results]; + ? SplitOn + : [...Results, Text]; + +type Wat1 = SplitOn<"baby", "a">; +// ^? + +type Wat2 = SplitOn<"hello my baby", " ">; +// ^? From 367dce12ddf560bd08454ae7d9ab1e5167cee775 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 8 May 2025 21:44:45 -0400 Subject: [PATCH 2/2] fix: correct reversed types in 03-split-on --- .../03-split-on/solution.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/projects/type-operations/template-literal-type-shenanigans/03-split-on/solution.ts b/projects/type-operations/template-literal-type-shenanigans/03-split-on/solution.ts index ef75ebf..564a238 100644 --- a/projects/type-operations/template-literal-type-shenanigans/03-split-on/solution.ts +++ b/projects/type-operations/template-literal-type-shenanigans/03-split-on/solution.ts @@ -5,9 +5,3 @@ export type SplitOn< > = Text extends `${infer Prefix}${On}${infer Suffix}` ? SplitOn : [...Results, Text]; - -type Wat1 = SplitOn<"baby", "a">; -// ^? - -type Wat2 = SplitOn<"hello my baby", " ">; -// ^?