diff --git a/client/src/templates/Challenges/utils/index.js b/client/src/templates/Challenges/utils/index.ts similarity index 71% rename from client/src/templates/Challenges/utils/index.js rename to client/src/templates/Challenges/utils/index.ts index ea3eb25c6b..5142978887 100644 --- a/client/src/templates/Challenges/utils/index.js +++ b/client/src/templates/Challenges/utils/index.ts @@ -2,19 +2,24 @@ import envData from '../../../../../config/env.json'; const { forumLocation } = envData; -export function getGuideUrl({ forumTopicId, title = '' }) { +interface GuideData { + forumTopicId: number; + title?: string; +} + +export function getGuideUrl({ forumTopicId, title = '' }: GuideData): string { title = encodeURIComponent(title); return forumTopicId ? `https://forum.freecodecamp.org/t/${forumTopicId}` : `${forumLocation}/search?q=${title}%20in%3Atitle%20order%3Aviews`; } -export function isGoodXHRStatus(status) { +export function isGoodXHRStatus(status: string): boolean { const statusInt = parseInt(status, 10); return (statusInt >= 200 && statusInt < 400) || statusInt === 402; } -export function transformEditorLink(url) { +export function transformEditorLink(url: string): string { return url .replace( /(\/\/)(?[^.]+)\.(?[^.]+)\.repl\.co\/?/,