Skip to content

Conversation

@Anton-CSS
Copy link

No description provided.

export const removeFirstZeros = (value: string) => value.replace(/^(-)?[0]+(-?\d+.*)$/, '$1$2');

export const getBeautifulNumber = (value, separator = ' ') =>
export const getBeautifulNumber = (value: string, separator = ' ') =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Стоит указать что ф-ия возвращает тут и ниже

export const getNumberedArray = (arr) => arr.map((value, number) => ({ value, number }));
export const toStringArray = (arr) => arr.map(({ value, number }) => `${value}_${number}`);
export const getNumberedArray = (arr: Array<number>) => arr.map((value, number) => ({ value, number }));
export const toStringArray = (arr: { value: string; number: string }[]) =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Там могут быть что-то помимо строки?например number

* Нужно превратить файл в ts и указать типы аргументов и типы возвращаемого значения
* */
export const removePlus = (string) => string.replace(/^\+/, '');
export const removePlus = (string: string) => string.replace(/^\+/, '');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Предлагаю у каждой функции типизировать ответ

export const longColorRegExp = /^#[0-9a-f]{6}$/i;

export const checkColor = (color) => {
export const checkColor = (color: string) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут интересный ответ получается например

return [red, green, blue];
};

export const getNumberedArray = <T>(arr: Array<T>): { value: T; number: number }[] =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В отдельный тип { value: T; number: number }[]

export const getNumberedArray = <T>(arr: Array<T>): { value: T; number: number }[] =>
arr.map((value, number) => ({ value, number }));

export const toStringArray = (arr: { value: string | number; number: string | number }[]): string[] =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в отдельный тип{ value: string | number; number: string | number }[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants