From 410e058d5cce1a7cb795d3e6a6073b2337403de0 Mon Sep 17 00:00:00 2001 From: aadito123 Date: Tue, 17 Dec 2024 16:54:36 +0800 Subject: [PATCH 1/3] fix startsWith output type to include requirement --- library/src/actions/startsWith/startsWith.test-d.ts | 2 +- library/src/actions/startsWith/startsWith.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/src/actions/startsWith/startsWith.test-d.ts b/library/src/actions/startsWith/startsWith.test-d.ts index b6f87e443..f312d2bb5 100644 --- a/library/src/actions/startsWith/startsWith.test-d.ts +++ b/library/src/actions/startsWith/startsWith.test-d.ts @@ -37,7 +37,7 @@ describe('startsWith', () => { }); test('of output', () => { - expectTypeOf>().toEqualTypeOf(); + expectTypeOf>().toEqualTypeOf<`foo${string}`>(); }); test('of issue', () => { diff --git a/library/src/actions/startsWith/startsWith.ts b/library/src/actions/startsWith/startsWith.ts index c16990394..cef5db7d9 100644 --- a/library/src/actions/startsWith/startsWith.ts +++ b/library/src/actions/startsWith/startsWith.ts @@ -45,7 +45,7 @@ export interface StartsWithAction< | undefined, > extends BaseValidation< TInput, - TInput, + `${TRequirement}${TInput}`, StartsWithIssue > { /** From b251507fc57031358fc63c8c1097931d810276df Mon Sep 17 00:00:00 2001 From: aadito123 Date: Tue, 17 Dec 2024 16:56:04 +0800 Subject: [PATCH 2/3] same but for endsWith --- library/src/actions/endsWith/endsWith.test-d.ts | 2 +- library/src/actions/endsWith/endsWith.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/src/actions/endsWith/endsWith.test-d.ts b/library/src/actions/endsWith/endsWith.test-d.ts index 927c162d4..bc0ee95c4 100644 --- a/library/src/actions/endsWith/endsWith.test-d.ts +++ b/library/src/actions/endsWith/endsWith.test-d.ts @@ -37,7 +37,7 @@ describe('endsWith', () => { }); test('of output', () => { - expectTypeOf>().toEqualTypeOf(); + expectTypeOf>().toEqualTypeOf<`${string}foo`>(); }); test('of issue', () => { diff --git a/library/src/actions/endsWith/endsWith.ts b/library/src/actions/endsWith/endsWith.ts index 1a0dd7ed1..18b574245 100644 --- a/library/src/actions/endsWith/endsWith.ts +++ b/library/src/actions/endsWith/endsWith.ts @@ -43,7 +43,7 @@ export interface EndsWithAction< TMessage extends | ErrorMessage> | undefined, -> extends BaseValidation> { +> extends BaseValidation> { /** * The action type. */ From a798433b64e0998db08aa0c32073c21316c4b125 Mon Sep 17 00:00:00 2001 From: aadito123 Date: Thu, 19 Dec 2024 11:22:09 +0800 Subject: [PATCH 3/3] remove piping of TInput --- library/src/actions/endsWith/endsWith.test-d.ts | 6 ++++++ library/src/actions/endsWith/endsWith.ts | 2 +- library/src/actions/startsWith/startsWith.test-d.ts | 8 +++++++- library/src/actions/startsWith/startsWith.ts | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/library/src/actions/endsWith/endsWith.test-d.ts b/library/src/actions/endsWith/endsWith.test-d.ts index bc0ee95c4..40abe96bd 100644 --- a/library/src/actions/endsWith/endsWith.test-d.ts +++ b/library/src/actions/endsWith/endsWith.test-d.ts @@ -31,6 +31,8 @@ describe('endsWith', () => { describe('should infer correct types', () => { type Action = EndsWithAction; + type Action2 = EndsWithAction, 'bar', undefined>; + test('of input', () => { expectTypeOf>().toEqualTypeOf(); @@ -40,6 +42,10 @@ describe('endsWith', () => { expectTypeOf>().toEqualTypeOf<`${string}foo`>(); }); + test('of output after pipe', () => { + expectTypeOf>().toEqualTypeOf<`${string}bar`>(); + }); + test('of issue', () => { expectTypeOf>().toEqualTypeOf< EndsWithIssue diff --git a/library/src/actions/endsWith/endsWith.ts b/library/src/actions/endsWith/endsWith.ts index 18b574245..f26b64be4 100644 --- a/library/src/actions/endsWith/endsWith.ts +++ b/library/src/actions/endsWith/endsWith.ts @@ -43,7 +43,7 @@ export interface EndsWithAction< TMessage extends | ErrorMessage> | undefined, -> extends BaseValidation> { +> extends BaseValidation> { /** * The action type. */ diff --git a/library/src/actions/startsWith/startsWith.test-d.ts b/library/src/actions/startsWith/startsWith.test-d.ts index f312d2bb5..b2fc2ffe4 100644 --- a/library/src/actions/startsWith/startsWith.test-d.ts +++ b/library/src/actions/startsWith/startsWith.test-d.ts @@ -4,7 +4,7 @@ import { startsWith, type StartsWithAction, type StartsWithIssue, -} from './startsWith.ts'; +} from './startsWith.ts'; describe('startsWith', () => { describe('should return action object', () => { @@ -31,6 +31,7 @@ describe('startsWith', () => { describe('should infer correct types', () => { type Action = StartsWithAction; + type Action2 = StartsWithAction, 'bar', undefined>; test('of input', () => { expectTypeOf>().toEqualTypeOf(); @@ -40,6 +41,10 @@ describe('startsWith', () => { expectTypeOf>().toEqualTypeOf<`foo${string}`>(); }); + test('of output after pipe', () => { + expectTypeOf>().toEqualTypeOf<`bar${string}`>(); + }); + test('of issue', () => { expectTypeOf>().toEqualTypeOf< StartsWithIssue @@ -47,3 +52,4 @@ describe('startsWith', () => { }); }); }); + \ No newline at end of file diff --git a/library/src/actions/startsWith/startsWith.ts b/library/src/actions/startsWith/startsWith.ts index cef5db7d9..c224c99bf 100644 --- a/library/src/actions/startsWith/startsWith.ts +++ b/library/src/actions/startsWith/startsWith.ts @@ -45,7 +45,7 @@ export interface StartsWithAction< | undefined, > extends BaseValidation< TInput, - `${TRequirement}${TInput}`, + `${TRequirement}${string}`, StartsWithIssue > { /**