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:
@ -1,9 +1,8 @@
|
||||
import { isBoolean } from '@sniptt/guards';
|
||||
|
||||
import { FieldBooleanValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldBooleanValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldBooleanValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'boolean';
|
||||
): fieldValue is FieldBooleanValue => isBoolean(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldChipValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldChipValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldChipValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'string';
|
||||
): fieldValue is FieldChipValue => isString(fieldValue);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { isNull, isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldDateValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldDateValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldDateValue =>
|
||||
fieldValue === null ||
|
||||
(fieldValue !== undefined && typeof fieldValue === 'string');
|
||||
): fieldValue is FieldDateValue => isNull(fieldValue) || isString(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldEmailValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldEmailValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldEmailValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'string';
|
||||
): fieldValue is FieldEmailValue => isString(fieldValue);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { isNull, isNumber } from '@sniptt/guards';
|
||||
|
||||
import { FieldMoneyValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldMoneyValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldMoneyValue =>
|
||||
fieldValue === null ||
|
||||
(fieldValue !== undefined && typeof fieldValue === 'number');
|
||||
): fieldValue is FieldMoneyValue => isNull(fieldValue) || isNumber(fieldValue);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { isNull, isNumber } from '@sniptt/guards';
|
||||
|
||||
import { FieldNumberValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldNumberValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldNumberValue =>
|
||||
fieldValue === null ||
|
||||
(fieldValue !== undefined && typeof fieldValue === 'number');
|
||||
): fieldValue is FieldNumberValue => isNull(fieldValue) || isNumber(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldPhoneValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldPhoneValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldPhoneValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'string';
|
||||
): fieldValue is FieldPhoneValue => isString(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isNumber } from '@sniptt/guards';
|
||||
|
||||
import { FieldProbabilityValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldProbabilityValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldProbabilityValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'number';
|
||||
): fieldValue is FieldProbabilityValue => isNumber(fieldValue);
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { isObject, isUndefined } from '@sniptt/guards';
|
||||
|
||||
import { FieldRelationValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldRelationValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldRelationValue =>
|
||||
fieldValue !== undefined && typeof fieldValue === 'object';
|
||||
!isUndefined(fieldValue) && isObject(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldTextValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldTextValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldTextValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'string';
|
||||
): fieldValue is FieldTextValue => isString(fieldValue);
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { isString } from '@sniptt/guards';
|
||||
|
||||
import { FieldURLValue } from '../FieldMetadata';
|
||||
|
||||
// TODO: add yup
|
||||
export const isFieldURLValue = (
|
||||
fieldValue: unknown,
|
||||
): fieldValue is FieldURLValue =>
|
||||
fieldValue !== null &&
|
||||
fieldValue !== undefined &&
|
||||
typeof fieldValue === 'string';
|
||||
): fieldValue is FieldURLValue => isString(fieldValue);
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import * as React from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
import { IconComponent } from '@/ui/display/icon/types/IconComponent';
|
||||
import { Avatar, AvatarType } from '@/users/components/Avatar';
|
||||
import { isNonEmptyString } from '~/utils/isNonEmptyString';
|
||||
|
||||
import { Chip, ChipVariant } from './Chip';
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { useRef } from 'react';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import debounce from 'lodash.debounce';
|
||||
|
||||
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
||||
@ -9,7 +10,6 @@ import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
|
||||
import { MenuItemMultiSelectAvatar } from '@/ui/navigation/menu-item/components/MenuItemMultiSelectAvatar';
|
||||
import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
|
||||
import { Avatar } from '@/users/components/Avatar';
|
||||
import { isNonEmptyString } from '~/utils/isNonEmptyString';
|
||||
|
||||
import { EntityForSelect } from '../types/EntityForSelect';
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { useRef } from 'react';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { Key } from 'ts-key-enum';
|
||||
|
||||
import { IconPlus } from '@/ui/display/icon';
|
||||
@ -11,7 +12,6 @@ import { MenuItemSelectAvatar } from '@/ui/navigation/menu-item/components/MenuI
|
||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||
import { Avatar } from '@/users/components/Avatar';
|
||||
import { assertNotNull } from '~/utils/assert';
|
||||
import { isNonEmptyString } from '~/utils/isNonEmptyString';
|
||||
|
||||
import { CreateButtonId, EmptyButtonId } from '../constants';
|
||||
import { useEntitySelectScroll } from '../hooks/useEntitySelectScroll';
|
||||
|
||||
Reference in New Issue
Block a user