更漂亮与 ? 冲突。(问号和点)在 prop 括号内的 typescript-react 中,有语法错误

Vas*_*nta 5 typescript reactjs prettier

表达

<Button
        title={props.children?.toString()}
        buttonStyle={$.buttonStyle}
        titleStyle={$.titleStyle}

      />
Run Code Online (Sandbox Code Playgroud)

给出下一个错误

SyntaxError: Expression expected.
title={props.children?.toString()}
                      ^
Run Code Online (Sandbox Code Playgroud)

有什么办法可以解决吗?
带有 prettier-plugin 的 Eslint 给出了同样的错误。parser-typescript.js 的问题

Vas*_*nta 0

这个问题出现在新版本的 Prettier 4.5.0 中,
如果你将 Prettier 降级到 v4.0.0 - 你的问题就会崩溃:)