Javascript 如何使用FlowType和ES6简洁地注释对象分解?

Javascript 如何使用FlowType和ES6简洁地注释对象分解?,javascript,flowtype,Javascript,Flowtype,目前,我正在使用以下代码来注释对象分解(内联) 我想知道是否有更简洁的形式,例如不使用内联注释 你能给我举个例子吗 /@flow 从“React”导入React 从“时刻”导入时刻 从“../../shared/icon/IconWeather”导入IconWeather const ForecastDay=({date,tempMin,tempMax,iconCode,weatherDescription}:{+date:date,+tempMin:number,+tempMax:numbe

目前,我正在使用以下代码来注释对象分解(内联)

我想知道是否有更简洁的形式,例如不使用内联注释

你能给我举个例子吗

/@flow
从“React”导入React
从“时刻”导入时刻
从“../../shared/icon/IconWeather”导入IconWeather
const ForecastDay=({date,tempMin,tempMax,iconCode,weatherDescription}:{+date:date,+tempMin:number,+tempMax:number,+iconCode:string,+weatherDescription:string})=>{
const dateFormat=moment.unix(date.format('ddd,MMM D'))
const tempMinRounded=Math.round(tempMin)
const tempMaxRounded=Math.round(tempMax)
返回(
{dateFormat}
{tempMinRounded}°;
{tempMaxRounded}°;
{weatherDescription}
)
}

导出默认ForecastDay
我找到了一个可能的解决方案,将注释分离到一个单独的类型上

如果你有更好的解决方案,请向我汇报,我想了解更多

我使用的代码:

/@flow
从“React”导入*作为React
从“时刻”导入时刻
从“../../shared/icon/IconWeather”导入IconWeather
/*eslint禁用无未定义*/
类型PropsType={
日期:年月日,
+tempMin:数字,
+tempMax:数字,
+iconCode:number,
+天气描述:字符串
}
/*eslint启用无未定义*/
const ForecastDay=({date,tempMin,tempMax,iconCode,weatherDescription}:PropsType)=>{
const dateFormat=moment.unix(date.format('ddd,MMM D'))
const tempMinRounded=Math.round(tempMin)
const tempMaxRounded=Math.round(tempMax)
返回(
{dateFormat}
{tempMinRounded}°;
{tempMaxRounded}°;
{weatherDescription}
)
}
导出默认预报日