Chore(front): Add more typeguards (#2136)

* Chore(front): Add more typeguards

Co-authored-by: Benjamin Mayanja V <vibenjamin6@gmail.com>
Co-authored-by: KlingerMatheus <klinger.matheus@gitstart.dev>

* Remove source map generation to avoid warnings

---------

Co-authored-by: Benjamin Mayanja V <vibenjamin6@gmail.com>
Co-authored-by: KlingerMatheus <klinger.matheus@gitstart.dev>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
gitstart-twenty
2023-10-24 10:26:47 +03:00
committed by GitHub
parent 80d558559f
commit 5acafe2fc6
29 changed files with 82 additions and 87 deletions

View File

@ -1,3 +1,4 @@
import { isObject, isString } from '@sniptt/guards';
import { GraphQLVariables } from 'msw';
import {
@ -27,7 +28,7 @@ const filterData = <DataT>(
const nestedKey = Object.keys(filterElement.is)[0] as string;
if (
item[key as keyof typeof item] &&
typeof item[key as keyof typeof item] === 'object'
isObject(item[key as keyof typeof item])
) {
const nestedItem = item[key as keyof typeof item];
return (
@ -116,7 +117,7 @@ export const filterAndSortData = <DataT>(
const sortDirection =
firstOrderBy[key as unknown as keyof typeof firstOrderBy];
if (typeof itemAValue === 'string' && typeof itemBValue === 'string') {
if (isString(itemAValue) && isString(itemBValue)) {
return sortDirection === 'desc'
? itemBValue.localeCompare(itemAValue)
: -itemBValue.localeCompare(itemAValue);