From 98183e720235338887a9ef0fb887735a7faafab9 Mon Sep 17 00:00:00 2001 From: jpuri Date: Thu, 19 Dec 2024 15:35:36 +0530 Subject: [PATCH 1/5] Fix primary type regex match condition for types signatures --- src/utils/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/common.ts b/src/utils/common.ts index ae1b297..ce441fd 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -5,7 +5,7 @@ * @returns Parameter string with array brackets [] removed. */ export const stripArrayTypeIfPresent = (typeString: string) => { - if (typeString?.match(/\S\[\d*\]$/u) !== null) { + if (typeString?.match(/\S\[\d*\]$/u)) { return typeString.replace(/\[\d*\]$/gu, '').trim(); } return typeString; From 5fdeecdd9fa78df8baaacec66f925f9ba3f59caa Mon Sep 17 00:00:00 2001 From: jpuri Date: Thu, 19 Dec 2024 20:34:05 +0530 Subject: [PATCH 2/5] update --- src/utils/common.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/common.test.ts b/src/utils/common.test.ts index ba58322..2cf5183 100644 --- a/src/utils/common.test.ts +++ b/src/utils/common.test.ts @@ -10,6 +10,7 @@ describe('CommonUtils', () => { it('return types which are not array without any change', () => { expect(stripArrayTypeIfPresent('string')).toBe('string'); expect(stripArrayTypeIfPresent('string []')).toBe('string []'); + expect(stripArrayTypeIfPresent(undefined as unknown as string)).toBe(undefined); }); }); }); From 6e7f9576711f9f94a01db130861459641a60138e Mon Sep 17 00:00:00 2001 From: jpuri Date: Thu, 19 Dec 2024 20:38:02 +0530 Subject: [PATCH 3/5] update --- src/utils/common.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/common.test.ts b/src/utils/common.test.ts index 2cf5183..acfbeb8 100644 --- a/src/utils/common.test.ts +++ b/src/utils/common.test.ts @@ -10,7 +10,7 @@ describe('CommonUtils', () => { it('return types which are not array without any change', () => { expect(stripArrayTypeIfPresent('string')).toBe('string'); expect(stripArrayTypeIfPresent('string []')).toBe('string []'); - expect(stripArrayTypeIfPresent(undefined as unknown as string)).toBe(undefined); + expect(stripArrayTypeIfPresent(undefined as unknown as string)).toBeUndefined(); }); }); }); From e67fa814a94ba42138985bafc2d953602e5b53e6 Mon Sep 17 00:00:00 2001 From: jpuri Date: Thu, 19 Dec 2024 20:39:47 +0530 Subject: [PATCH 4/5] update --- src/utils/common.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/common.test.ts b/src/utils/common.test.ts index acfbeb8..8cbfe3e 100644 --- a/src/utils/common.test.ts +++ b/src/utils/common.test.ts @@ -10,7 +10,9 @@ describe('CommonUtils', () => { it('return types which are not array without any change', () => { expect(stripArrayTypeIfPresent('string')).toBe('string'); expect(stripArrayTypeIfPresent('string []')).toBe('string []'); - expect(stripArrayTypeIfPresent(undefined as unknown as string)).toBeUndefined(); + expect( + stripArrayTypeIfPresent(undefined as unknown as string), + ).toBeUndefined(); }); }); }); From 8e04103341522b02866f045f6d4ae4321436d07e Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 19 Dec 2024 21:26:49 +0530 Subject: [PATCH 5/5] Update src/utils/common.test.ts Co-authored-by: Mark Stacey --- src/utils/common.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/common.test.ts b/src/utils/common.test.ts index 8cbfe3e..304e663 100644 --- a/src/utils/common.test.ts +++ b/src/utils/common.test.ts @@ -11,7 +11,8 @@ describe('CommonUtils', () => { expect(stripArrayTypeIfPresent('string')).toBe('string'); expect(stripArrayTypeIfPresent('string []')).toBe('string []'); expect( - stripArrayTypeIfPresent(undefined as unknown as string), + // @ts-expect-error Intentionally testing invalid input + stripArrayTypeIfPresent(undefined), ).toBeUndefined(); }); });