diff --git a/src/utils/common.test.ts b/src/utils/common.test.ts index ba58322..304e663 100644 --- a/src/utils/common.test.ts +++ b/src/utils/common.test.ts @@ -10,6 +10,10 @@ describe('CommonUtils', () => { it('return types which are not array without any change', () => { expect(stripArrayTypeIfPresent('string')).toBe('string'); expect(stripArrayTypeIfPresent('string []')).toBe('string []'); + expect( + // @ts-expect-error Intentionally testing invalid input + stripArrayTypeIfPresent(undefined), + ).toBeUndefined(); }); }); }); 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;