refactor: mollify TypeScript
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
7d0760c98f
commit
01b354f0d1
@ -116,14 +116,10 @@ const ShowProjectLinks = (props: ShowProjectLinksProps): JSX.Element => {
|
||||
{ title: 'Data Visualization' },
|
||||
{ title: 'Back End Development and APIs' },
|
||||
{ title: 'Legacy Information Security and Quality Assurance' }
|
||||
];
|
||||
] as const;
|
||||
return legacyCerts.map((cert, ind) => {
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
// @ts-expect-error Error expected until projectMap is typed
|
||||
const mapToUse = projectMap[cert.title] || legacyProjectMap[cert.title];
|
||||
const mapToUse = (projectMap[cert.title] ||
|
||||
legacyProjectMap[cert.title]) as { certSlug: string }[];
|
||||
const { certSlug } = first(mapToUse) as { certSlug: string };
|
||||
const certLocation = `/certification/${username}/${certSlug}`;
|
||||
return (
|
||||
@ -141,17 +137,19 @@ const ShowProjectLinks = (props: ShowProjectLinksProps): JSX.Element => {
|
||||
});
|
||||
}
|
||||
// @ts-expect-error Error expected until projectMap is typed
|
||||
return (projectMap[certName] || legacyProjectMap[certName]).map(
|
||||
// @ts-expect-error Error expected until projectMap is typed
|
||||
({ link, title, id }) => (
|
||||
const project = (projectMap[certName] || legacyProjectMap[certName]) as {
|
||||
link: string;
|
||||
title: string;
|
||||
id: string;
|
||||
}[];
|
||||
return project.map(({ link, title, id }) => (
|
||||
<li key={id}>
|
||||
<Link className='project-link' to={link}>
|
||||
{t(`certification.project.title.${title as string}`, title)}
|
||||
{t(`certification.project.title.${title}`, title)}
|
||||
</Link>
|
||||
: {getProjectSolution(id, title)}
|
||||
</li>
|
||||
)
|
||||
);
|
||||
));
|
||||
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-enable @typescript-eslint/no-unsafe-call */
|
||||
/* eslint-enable @typescript-eslint/no-unsafe-return */
|
||||
|
@ -101,7 +101,12 @@ function FormFields(props: FormFieldsProps): JSX.Element {
|
||||
type={type}
|
||||
value={value as string}
|
||||
/>
|
||||
{nullOrWarning(value, !pristine && error, isURL, name)}
|
||||
{nullOrWarning(
|
||||
value as string,
|
||||
!pristine && error,
|
||||
isURL,
|
||||
name
|
||||
)}
|
||||
</FormGroup>
|
||||
</Col>
|
||||
);
|
||||
|
@ -17,6 +17,7 @@ import './heatmap.css';
|
||||
// @ts-ignore
|
||||
import envData from '../../../../../config/env.json';
|
||||
import { langCodes } from '../../../../../config/i18n/all-langs';
|
||||
import { User } from '../../../redux/prop-types';
|
||||
import FullWidthRow from '../../helpers/full-width-row';
|
||||
import Spacer from '../../helpers/spacer';
|
||||
|
||||
@ -29,8 +30,7 @@ const { clientLocale } = envData;
|
||||
const localeCode = langCodes[clientLocale];
|
||||
|
||||
interface HeatMapProps {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
calendar: any;
|
||||
calendar: User['calendar'];
|
||||
}
|
||||
|
||||
interface PageData {
|
||||
@ -186,7 +186,6 @@ class HeatMapInner extends Component<HeatMapInnerProps, HeatMapInnerState> {
|
||||
|
||||
const HeatMap = (props: HeatMapProps): JSX.Element => {
|
||||
const { t } = useTranslation();
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const { calendar } = props;
|
||||
|
||||
/**
|
||||
@ -195,8 +194,9 @@ const HeatMap = (props: HeatMapProps): JSX.Element => {
|
||||
*/
|
||||
|
||||
// create array of timestamps and turn into milliseconds
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const timestamps = Object.keys(calendar).map((stamp: any) => stamp * 1000);
|
||||
const timestamps = Object.keys(calendar).map(
|
||||
stamp => Number.parseInt(stamp, 10) * 1000
|
||||
);
|
||||
const startOfTimestamps = startOfDay(new Date(timestamps[0]));
|
||||
let endOfCalendar = startOfDay(Date.now());
|
||||
let startOfCalendar;
|
||||
|
@ -57,6 +57,7 @@ const CustomHits = connectHits(
|
||||
];
|
||||
const allHits = hits.slice(0, 8).concat(footer);
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
handleHits(allHits);
|
||||
});
|
||||
|
||||
|
@ -220,7 +220,7 @@ export type CertTest = {
|
||||
};
|
||||
|
||||
export type User = {
|
||||
calendar: unknown;
|
||||
calendar: Record<string, number>;
|
||||
about: string;
|
||||
acceptedPrivacyTerms: boolean;
|
||||
completedChallenges: CompletedChallenge[];
|
||||
|
@ -64,7 +64,7 @@ const DesktopLayout = (props: DesktopLayoutProps): JSX.Element => {
|
||||
|
||||
const getChallengeFile = () => {
|
||||
const { challengeFiles } = props;
|
||||
return first(sortChallengeFiles(challengeFiles)) as ChallengeFile | null;
|
||||
return first(sortChallengeFiles(challengeFiles) as ChallengeFile[]);
|
||||
};
|
||||
|
||||
const {
|
||||
|
@ -13,7 +13,7 @@ interface CompletionModalBodyProps {
|
||||
interface CompletionModalBodyState {
|
||||
// This type was driving me nuts - seems like `NodeJS.Timeout | null;` should work
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
progressInterval: any;
|
||||
progressInterval: number | null;
|
||||
shownPercent: number;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ export class CompletionModalBody extends PureComponent<
|
||||
const amountPerInterval = completedPercent / intervalsToFinish;
|
||||
let percent = 0;
|
||||
|
||||
const myInterval = setInterval(() => {
|
||||
const myInterval = window.setInterval(() => {
|
||||
percent += amountPerInterval;
|
||||
|
||||
if (percent > completedPercent) percent = completedPercent;
|
||||
@ -65,6 +65,7 @@ export class CompletionModalBody extends PureComponent<
|
||||
}
|
||||
|
||||
componentWillUnmount(): void {
|
||||
if (this.state.progressInterval !== null)
|
||||
clearInterval(this.state.progressInterval);
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,14 @@ type Meta = {
|
||||
challengeOrder: string[][];
|
||||
};
|
||||
|
||||
interface CreateProjectArgs {
|
||||
superBlock: SuperBlocks;
|
||||
block: string;
|
||||
helpCategory: string;
|
||||
order: number;
|
||||
title?: string;
|
||||
}
|
||||
|
||||
async function createProject(
|
||||
superBlock: SuperBlocks,
|
||||
block: string,
|
||||
@ -264,7 +272,8 @@ prompt([
|
||||
}
|
||||
}
|
||||
])
|
||||
.then(({ superBlock, block, title, helpCategory, order }) =>
|
||||
.then(
|
||||
({ superBlock, block, title, helpCategory, order }: CreateProjectArgs) =>
|
||||
createProject(superBlock, block, helpCategory, order, title)
|
||||
)
|
||||
.then(() =>
|
||||
|
@ -59,7 +59,7 @@ if (FREECODECAMP_NODE_ENV !== 'development') {
|
||||
searchKeys,
|
||||
donationKeys
|
||||
);
|
||||
const receivedvariables = Object.keys(env);
|
||||
const receivedvariables = Object.keys(env as Record<string, unknown>);
|
||||
expectedVariables.sort();
|
||||
receivedvariables.sort();
|
||||
if (expectedVariables.length !== receivedvariables.length) {
|
||||
|
Reference in New Issue
Block a user