1

我有以下函数为 ReactMarkdown 做一些样式。

  td: (td: HTMLTableCellElement) => {
    const { children, style } = td;
    return (
      <td style={style} className="border px-8 py-4">
        {children}
      </td>
    );
  },

虽然这有效,但tsc抱怨style不兼容

Type 'CSSStyleDeclaration' is not assignable to type 'Properties<string | number, string & {}>'.
  Types of property 'appearance' are incompatible.
    Type 'string' is not assignable to type 'Appearance | undefined'.

td.styleCSSStyleDeclaration
JSX 样式属性:CSSProperties | undefined

您能否启发我,这两种类型之间有什么区别以及为什么它们不完全兼容。

4

0 回答 0