为什么这个流类型定义不起作用?

Why doesn't this flow type definition work?

我正在尝试使用流输入所有内容。使用此代码,表示第二行的逗号是 "unexpected token":

const WizardNavGuide = ({ index: number, 
                          steps: Array<string>,
                          classes: any }) => {

我这样做有什么问题吗?

您将输入与 object destructing alias 混淆了。

你想做的是:

const WizardNavGuide = ({ index, steps, classes }: {index: number; steps: Array<string>; classes: any }) => {}

或者这样:

interface Props {
  index: number;
  steps: Array<string>;
  classes: any;
}

const WizardNavGuide = ({ index, steps, classes }: Props) => {}