Files
nahodka-front/src/components/Toast.d.ts
2026-10-06 01:24:28 +03:00

22 lines
1018 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Типы для Toast.
*
* Почему отдельный .d.ts, а не JSDoc в Toast.jsx: у функции с деструктурированным
* параметром TS сворачивает тип в `string` (JSDoc-теги применяются к самому
* объекту параметра, а не к его полям). Из-за этого любой .tsx-файл, рендерящий
* <Toast .../>, падал с TS2322. Объявление отделяет контракт от реализации.
*/
type ToastType = "error" | "success";
interface ToastProps {
/** Текст сообщения. Пустая строка/null — тост не рендерится. */
message: string | null | undefined;
type?: ToastType;
/** Вызывается по истечении duration и по клику на крестик. */
onDismiss?: () => void;
duration?: number;
}
declare function Toast(props: ToastProps): JSX.Element | null;
export default Toast;