0
class TodoFunctions {
type TodoTy = { // ERROR : Unexpected identifier
text:string;
completed:boolean;
id:number;
};
make(t:string,id:number):TodoTy{
return {text:t,id:id,completed:false}
}
toggle(t:TodoTy):TodoTy {
return {...t, completed:!t.completed};
}
}
是否有可能在類中聲明類型?像在斯卡拉?然後將它們稱爲TodoFunctions.TodoTy
?FlowType,定義類中的類型
這似乎是相關的:https://github.com/facebook/flow/issues/938 – jhegedus
這樣的事情似乎是可能的https://flowtype.org/blog/2015/02/18/Import-Types。 html – jhegedus
似乎是不可能的:https://flowtype.org/docs/modules.html#_如果它應該在這裏提到... – jhegedus