在 TSX 中输入 var 作为函数时出错

Error when typing a var as a Function in TSX

我是 TS 新手。我没有收到此代码的错误:

interface Props {
  active: boolean
  error: any // unknown
  input: any // unknown
  onActivate: Function
  onKeyUp: Function
  onSelect: Function
  onUpdate: Function
  readonly: boolean
  selected: boolean
  value: string
}

但是在这里,我收到一条错误消息:

Cannot redeclare block-scoped variable 'Function'.ts(2451)

对于 Function 的每个声明:

const EditableCell: React.FC<Props> = (props) => {
  const {
    input: any,
    value: string,
    selected: Function,
    active: boolean
    onSelect: Function,
    onActivate: Function,
    onUpdate: Function
  } = props

顺便说一句,这两个代码块紧接着一个

在解构 props 时删除类型分配。

const {
  active,
  error, // unknown
  input, // unknown
  onActivate,
  onKeyUp,
  onSelect,
  onUpdate,
  readonly,
  selected,
  value
} = props

注意-

不要使用任何和 Function 类型,使用适当的类型代替它们!