打字稿 - 无法键入样式根目录



我认为我必须对错误在根标记中给出的以下类型进行编码:

No overload matches this call.
Overload 1 of 2, '(style: Styles<Theme, {}, "root">, options?: Pick<WithStylesOptions<Theme>, "flip" | "element" | "defaultTheme" | "name" | "media" | "meta" | "index" | "link" | "generateId" | "classNamePrefix">): (props?: any) => Record<...>', gave the following error.
Type 'string' is not assignable to type 'CSSProperties | CreateCSSProperties<{}> | PropsFunc<{}, CreateCSSProperties<{}>>'

问题是我不知道怎么做,以前从来没有打过这样的字。您可以在此处找到代码:https://codesandbox.io/s/github/pedroRelvas/HowToTypeTheStyleRoot(你可以在文件demo.tsx中找到错误(。你能向我解释一下吗?

谢谢。

简单如下:

const useStyles = makeStyles({
root: `
background: linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%);
border-radius: 3px;
font-size: 16px;
border: 0;
color: white;
height: 48px;
padding: 0 30px;
box-shadow: 0 3px 5px 2px rgba(255, 105, 135, 0.3);
` as CSSProperties | CreateCSSProperties<{}> | PropsFunc<{}, CreateCSSProperties<{}>>,
});

最新更新