mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
refactor: replace ts-ignore with ts-expect-error (#681)
* refactor: replace ts-ignore with ts-expect-error * refactor: remove unused ts-expect-errors
This commit is contained in:
parent
8deb2753e0
commit
010f766de9
@ -12,7 +12,6 @@ import { useState } from 'react';
|
|||||||
import { scrollToTop } from '../../../common/util';
|
import { scrollToTop } from '../../../common/util';
|
||||||
|
|
||||||
const CreateApiToken = () => {
|
const CreateApiToken = () => {
|
||||||
/* @ts-ignore */
|
|
||||||
const { setToastApiError } = useToast();
|
const { setToastApiError } = useToast();
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
@ -9,7 +9,6 @@ import PermissionButton from '../../../common/PermissionButton/PermissionButton'
|
|||||||
import { ADMIN } from '../../../providers/AccessProvider/permissions';
|
import { ADMIN } from '../../../providers/AccessProvider/permissions';
|
||||||
|
|
||||||
const CreateProjectRole = () => {
|
const CreateProjectRole = () => {
|
||||||
/* @ts-ignore */
|
|
||||||
const { setToastData, setToastApiError } = useToast();
|
const { setToastData, setToastApiError } = useToast();
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
@ -12,7 +12,6 @@ import PermissionButton from '../../../common/PermissionButton/PermissionButton'
|
|||||||
import { ADMIN } from '../../../providers/AccessProvider/permissions';
|
import { ADMIN } from '../../../providers/AccessProvider/permissions';
|
||||||
|
|
||||||
const CreateUser = () => {
|
const CreateUser = () => {
|
||||||
/* @ts-ignore */
|
|
||||||
const { setToastApiError } = useToast();
|
const { setToastApiError } = useToast();
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
@ -38,7 +38,7 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
position: 'relative',
|
position: 'relative',
|
||||||
},
|
},
|
||||||
errorMessage: {
|
errorMessage: {
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
fontSize: theme.fontSizes.smallBody,
|
fontSize: theme.fontSizes.smallBody,
|
||||||
color: theme.palette.error.main,
|
color: theme.palette.error.main,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
@ -24,7 +24,6 @@ const FormTemplate: React.FC<ICreateProps> = ({
|
|||||||
loading,
|
loading,
|
||||||
formatApiCode,
|
formatApiCode,
|
||||||
}) => {
|
}) => {
|
||||||
// @ts-ignore-next-line
|
|
||||||
const { setToastData } = useToast();
|
const { setToastData } = useToast();
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
const smallScreen = useMediaQuery(`(max-width:${900}px)`);
|
const smallScreen = useMediaQuery(`(max-width:${900}px)`);
|
||||||
|
@ -8,7 +8,7 @@ import ConditionallyRender from '../../ConditionallyRender';
|
|||||||
import Close from '@material-ui/icons/Close';
|
import Close from '@material-ui/icons/Close';
|
||||||
|
|
||||||
const Toast = ({ title, text, type, confetti }: IToastData) => {
|
const Toast = ({ title, text, type, confetti }: IToastData) => {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
const { setToast } = useContext(UIContext);
|
const { setToast } = useContext(UIContext);
|
||||||
|
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
|
@ -7,7 +7,7 @@ import AnimateOnMount from '../AnimateOnMount/AnimateOnMount';
|
|||||||
import Toast from './Toast/Toast';
|
import Toast from './Toast/Toast';
|
||||||
|
|
||||||
const ToastRenderer = () => {
|
const ToastRenderer = () => {
|
||||||
// @ts-ignore-next-line
|
// @ts-expect-error
|
||||||
const { toastData, setToast } = useContext(UIContext);
|
const { toastData, setToast } = useContext(UIContext);
|
||||||
const commonStyles = useCommonStyles();
|
const commonStyles = useCommonStyles();
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
|
@ -54,7 +54,7 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
position: 'relative',
|
position: 'relative',
|
||||||
},
|
},
|
||||||
errorMessage: {
|
errorMessage: {
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
fontSize: theme.fontSizes.smallBody,
|
fontSize: theme.fontSizes.smallBody,
|
||||||
color: theme.palette.error.main,
|
color: theme.palette.error.main,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
@ -16,7 +16,6 @@ import { ADMIN } from '../../providers/AccessProvider/permissions';
|
|||||||
import useProjectRolePermissions from '../../../hooks/api/getters/useProjectRolePermissions/useProjectRolePermissions';
|
import useProjectRolePermissions from '../../../hooks/api/getters/useProjectRolePermissions/useProjectRolePermissions';
|
||||||
|
|
||||||
const CreateEnvironment = () => {
|
const CreateEnvironment = () => {
|
||||||
/* @ts-ignore */
|
|
||||||
const { setToastApiError, setToastData } = useToast();
|
const { setToastApiError, setToastData } = useToast();
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
@ -38,7 +38,7 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
position: 'relative',
|
position: 'relative',
|
||||||
},
|
},
|
||||||
errorMessage: {
|
errorMessage: {
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
fontSize: theme.fontSizes.smallBody,
|
fontSize: theme.fontSizes.smallBody,
|
||||||
color: theme.palette.error.main,
|
color: theme.palette.error.main,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
@ -6,7 +6,7 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
},
|
},
|
||||||
formHeader: {
|
formHeader: {
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
fontSize: theme.fontSizes.bodySize,
|
fontSize: theme.fontSizes.bodySize,
|
||||||
marginTop: '1.5rem',
|
marginTop: '1.5rem',
|
||||||
marginBottom: '0.5rem',
|
marginBottom: '0.5rem',
|
||||||
|
@ -12,7 +12,6 @@ import { useContext } from 'react';
|
|||||||
import UIContext from '../../../contexts/UIContext';
|
import UIContext from '../../../contexts/UIContext';
|
||||||
|
|
||||||
const CreateFeature = () => {
|
const CreateFeature = () => {
|
||||||
/* @ts-ignore */
|
|
||||||
const { setToastData, setToastApiError } = useToast();
|
const { setToastData, setToastApiError } = useToast();
|
||||||
const { setShowFeedback } = useContext(UIContext);
|
const { setShowFeedback } = useContext(UIContext);
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
|
@ -12,7 +12,6 @@ import PermissionButton from '../../common/PermissionButton/PermissionButton';
|
|||||||
import { UPDATE_FEATURE } from '../../providers/AccessProvider/permissions';
|
import { UPDATE_FEATURE } from '../../providers/AccessProvider/permissions';
|
||||||
|
|
||||||
const EditFeature = () => {
|
const EditFeature = () => {
|
||||||
/* @ts-ignore */
|
|
||||||
const { setToastData, setToastApiError } = useToast();
|
const { setToastData, setToastApiError } = useToast();
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
@ -38,7 +38,7 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
marginBottom: '0.5rem',
|
marginBottom: '0.5rem',
|
||||||
},
|
},
|
||||||
typeDescription: {
|
typeDescription: {
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
fontSize: theme.fontSizes.smallBody,
|
fontSize: theme.fontSizes.smallBody,
|
||||||
color: theme.palette.grey[600],
|
color: theme.palette.grey[600],
|
||||||
top: '-13px',
|
top: '-13px',
|
||||||
@ -55,7 +55,7 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
position: 'relative',
|
position: 'relative',
|
||||||
},
|
},
|
||||||
errorMessage: {
|
errorMessage: {
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
fontSize: theme.fontSizes.smallBody,
|
fontSize: theme.fontSizes.smallBody,
|
||||||
color: theme.palette.error.main,
|
color: theme.palette.error.main,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
@ -24,7 +24,7 @@ interface IFeatureToggleListNewProps {
|
|||||||
projectId: string;
|
projectId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
const sortList = (list, sortOpt) => {
|
const sortList = (list, sortOpt) => {
|
||||||
if (!list) {
|
if (!list) {
|
||||||
return list;
|
return list;
|
||||||
@ -33,7 +33,7 @@ const sortList = (list, sortOpt) => {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
if (sortOpt.type === 'string') {
|
if (sortOpt.type === 'string') {
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
return list.sort((a, b) => {
|
return list.sort((a, b) => {
|
||||||
const fieldA = a[sortOpt.field]?.toUpperCase();
|
const fieldA = a[sortOpt.field]?.toUpperCase();
|
||||||
const fieldB = b[sortOpt.field]?.toUpperCase();
|
const fieldB = b[sortOpt.field]?.toUpperCase();
|
||||||
@ -49,7 +49,7 @@ const sortList = (list, sortOpt) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (sortOpt.type === 'date') {
|
if (sortOpt.type === 'date') {
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
return list.sort((a, b) => {
|
return list.sort((a, b) => {
|
||||||
const fieldA = new Date(a[sortOpt.field]);
|
const fieldA = new Date(a[sortOpt.field]);
|
||||||
const fieldB = new Date(b[sortOpt.field]);
|
const fieldB = new Date(b[sortOpt.field]);
|
||||||
|
@ -75,7 +75,6 @@ const FeatureStatus = ({
|
|||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={!!lastSeenAt}
|
condition={!!lastSeenAt}
|
||||||
show={
|
show={
|
||||||
//@ts-ignore
|
|
||||||
<TimeAgo
|
<TimeAgo
|
||||||
date={lastSeenAt}
|
date={lastSeenAt}
|
||||||
title=""
|
title=""
|
||||||
|
@ -147,7 +147,6 @@ const FeatureOverviewVariants = () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await patchFeatureVariants(projectId, featureId, patch);
|
const res = await patchFeatureVariants(projectId, featureId, patch);
|
||||||
// @ts-ignore
|
|
||||||
const { variants } = await res.json();
|
const { variants } = await res.json();
|
||||||
mutate(FEATURE_CACHE_KEY, { ...feature, variants }, false);
|
mutate(FEATURE_CACHE_KEY, { ...feature, variants }, false);
|
||||||
setToastData({
|
setToastData({
|
||||||
@ -204,7 +203,6 @@ const FeatureOverviewVariants = () => {
|
|||||||
if (patch.length === 0) return;
|
if (patch.length === 0) return;
|
||||||
try {
|
try {
|
||||||
const res = await patchFeatureVariants(projectId, featureId, patch);
|
const res = await patchFeatureVariants(projectId, featureId, patch);
|
||||||
// @ts-ignore
|
|
||||||
const { variants } = await res.json();
|
const { variants } = await res.json();
|
||||||
mutate(FEATURE_CACHE_KEY, { ...feature, variants }, false);
|
mutate(FEATURE_CACHE_KEY, { ...feature, variants }, false);
|
||||||
setToastData({
|
setToastData({
|
||||||
|
@ -10,7 +10,6 @@ import PermissionButton from '../../../common/PermissionButton/PermissionButton'
|
|||||||
import { CREATE_PROJECT } from '../../../providers/AccessProvider/permissions';
|
import { CREATE_PROJECT } from '../../../providers/AccessProvider/permissions';
|
||||||
|
|
||||||
const CreateProject = () => {
|
const CreateProject = () => {
|
||||||
/* @ts-ignore */
|
|
||||||
const { setToastData, setToastApiError } = useToast();
|
const { setToastData, setToastApiError } = useToast();
|
||||||
const { refetch } = useUser();
|
const { refetch } = useUser();
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
|
@ -38,7 +38,7 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
position: 'relative',
|
position: 'relative',
|
||||||
},
|
},
|
||||||
errorMessage: {
|
errorMessage: {
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
fontSize: theme.fontSizes.smallBody,
|
fontSize: theme.fontSizes.smallBody,
|
||||||
color: theme.palette.error.main,
|
color: theme.palette.error.main,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
@ -38,7 +38,7 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
position: 'relative',
|
position: 'relative',
|
||||||
},
|
},
|
||||||
errorMessage: {
|
errorMessage: {
|
||||||
//@ts-ignore
|
// @ts-expect-error
|
||||||
fontSize: theme.fontSizes.smallBody,
|
fontSize: theme.fontSizes.smallBody,
|
||||||
color: theme.palette.error.main,
|
color: theme.palette.error.main,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
@ -5,15 +5,15 @@ const handleErrorResponses = (target: string) => async (res: Response) => {
|
|||||||
);
|
);
|
||||||
// Try to resolve body, but don't rethrow res.json is not a function
|
// Try to resolve body, but don't rethrow res.json is not a function
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
error.info = await res.json();
|
error.info = await res.json();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
error.info = {};
|
error.info = {};
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
error.status = res.status;
|
error.status = res.status;
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
error.statusText = res.statusText;
|
error.statusText = res.statusText;
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ interface IToastOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const useToast = () => {
|
const useToast = () => {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
const { setToast } = useContext(UIContext);
|
const { setToast } = useContext(UIContext);
|
||||||
|
|
||||||
const hideToast = () =>
|
const hideToast = () =>
|
||||||
|
Loading…
Reference in New Issue
Block a user