mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-17 16:00:50 -04:00
feat: require JSDoc in new api (#50429)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@@ -9,6 +9,12 @@ type NoNullProperties<T> = {
|
||||
[P in keyof T]: NullToUndefined<T[P]>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Twitter handle or URL to a URL.
|
||||
*
|
||||
* @param handleOrUrl Twitter handle or URL.
|
||||
* @returns Twitter URL.
|
||||
*/
|
||||
export const normalizeTwitter = (
|
||||
handleOrUrl: string | null
|
||||
): string | undefined => {
|
||||
@@ -23,6 +29,12 @@ export const normalizeTwitter = (
|
||||
return url ?? handleOrUrl;
|
||||
};
|
||||
|
||||
/**
|
||||
* Ensure that the user's profile UI settings are valid.
|
||||
*
|
||||
* @param maybeProfileUI A null or the user's profile UI settings.
|
||||
* @returns The input with nulls removed or a default value if there is no input.
|
||||
*/
|
||||
export const normalizeProfileUI = (
|
||||
maybeProfileUI: ProfileUI | null
|
||||
): NoNullProperties<ProfileUI> => {
|
||||
@@ -42,6 +54,12 @@ export const normalizeProfileUI = (
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove all the null properties from an object.
|
||||
*
|
||||
* @param obj Any object.
|
||||
* @returns The input with nulls removed.
|
||||
*/
|
||||
export const removeNulls = <T extends Record<string, unknown>>(
|
||||
obj: T
|
||||
): NoNullProperties<T> =>
|
||||
@@ -65,6 +83,12 @@ type NormalizedChallenge = {
|
||||
solution?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove all the null properties from a CompletedChallenge array.
|
||||
*
|
||||
* @param completedChallenges The CompletedChallenge array.
|
||||
* @returns The input with nulls removed.
|
||||
*/
|
||||
export const normalizeChallenges = (
|
||||
completedChallenges: CompletedChallenge[]
|
||||
): NormalizedChallenge[] => {
|
||||
|
||||
Reference in New Issue
Block a user