feat: require JSDoc in new api (#50429)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Naomi Carrigan
2023-08-03 09:20:54 -07:00
committed by GitHub
parent 2a13fefdf0
commit 0aa1ad0d09
23 changed files with 275 additions and 3 deletions

View File

@@ -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[] => {