Skip to content

ref: complete ts migration#4

Open
kak-rastoki wants to merge 1 commit intomainfrom
sprint4
Open

ref: complete ts migration#4
kak-rastoki wants to merge 1 commit intomainfrom
sprint4

Conversation

@kak-rastoki
Copy link
Copy Markdown
Owner

Натипизировал

Copy link
Copy Markdown

@gennady-bars gennady-bars left a comment

Choose a reason for hiding this comment

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

Поздравляю! Ваша работа принята.

Вы отлично потрудились.

  • Отлично, что знаете про тип KeyboardEvent для событий клавиатуры
  • Хорошая типизация функций и компонентов
  • Отлично типизировали хуки useSelector и useDispatch
  • Отлично типизировали стейт, диспатч

Можно лучше

  • Есть небольшая хитрость: можно всегда проверить, какой тип у функции или события. Для этого нужно навести мышкой на атрибут onChange, onSubmit, onClick и тд. Там высветится типизация того, что принимают эти атрибуты.

Comment thread src/services/store.ts
Comment on lines +25 to +26
export const useAppDispatch = useDispatch.withTypes<AppDispatch>();
export const useAppSelector = useSelector.withTypes<RootState>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • Отлично типизировали хуки useSelector и useDispatch
  • Отлично типизировали стейт, диспатч

const [forgotPassword, { isLoading, error }] = useForgotPasswordMutation();

const handleSubmit = async (e) => {
const handleSubmit = async (e: FormEvent<HTMLFormElement>): Promise<void> => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

FormEvent уже устарел, поэтому лучше использовать другой (новый тип): SubmitEvent

  const handleSubmit = async (e: SubmitEvent): Promise<void> => {

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