Я работаю над приложением react
с material-ui
в typescript
. Интересно, где я могу найти определение всех типов для material
компонента. Я пытался установить @types/material-ui
, но он не работает хорошо. См. Пример ниже:
import * as React from 'react';
import SvgIcon from '@material-ui/core/SvgIcon';
import { SvgIconProps } from "material-ui";
export const Logo = (props: SvgIconProps) => (
<SvgIcon {...props}>
<path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" />
</SvgIcon>
);
Я получил ошибку ниже при компиляции:
Type '{ children: Element; color?: string | undefined; hoverColor?: string | undefined; onMouseEnter?: ((event: MouseEvent<{}, MouseEvent>) => void) | undefined; onMouseLeave?: ((event: MouseEvent<{}, MouseEvent>) => void) | undefined; ... 413 more ...; ref?: string | ... 3 more ... | undefined; }' is not assignable to type 'SvgIconProps'.
Types of property 'color' are incompatible.
Type 'string | undefined' is not assignable to type '"inherit" | "default" | "disabled" | "error" | "primary" | "secondary" | "action" | undefined'.
Type 'string' is not assignable to type '"inherit" | "default" | "disabled" | "error" | "primary" | "secondary" | "action" | undefined'.