如何在createStyles中正确访问道具?

时间:2019-06-04 19:37:49

标签: material-ui

我正在尝试弄清如何在TypeScript项目的createStyles中访问type Props = { isActive: boolean; } const useStyles = makeStyles<Theme, Props>((theme: Theme) => createStyles({ root: props => ({ border: `1px ${props.isActive ? `dashed` : `solid`} ${theme.palette.grey[500]}`, }), ); 。我找不到任何好的例子。

这是我要执行的操作的简化示例:

Type '(props: Props) => { border: string; }' is not assignable to type 'CSSProperties'.
  Index signature is missing in type '(props: Props) => { border: string; }'.

尝试以这种方式使用它时出现此错误:

props

如果我删除了createStyles,道具就可以工作,但是在我的真实代码中,我需要在其中的createStyles才能使键入正常工作。

有人对如何使diff --git a/sympy/printing/str.py b/sympy/printing/str.py index ee560ca..cb0db5e 100644 --- a/sympy/printing/str.py +++ b/sympy/printing/str.py @@ -51,6 +51,8 @@ def _print_Add(self, expr, order=None): PREC = precedence(expr) l = [] + if len(terms) == 2 and str(terms[0])[0] == '-' and str(terms[1])[0] != '-': + terms.reverse() for term in terms: t = self._print(term) if t.startswith('-'): 正常工作有任何想法或例子吗?

1 个答案:

答案 0 :(得分:0)

原来,这与TypeScript 3.5无关。类型扩展正常工作,不再需要createStyles