【发布时间】:2020-02-07 14:59:17
【问题描述】:
如何以对象键为字符串和混合类型的值来流动类型的对象数组?
example : [
{"appId":13118,"id":100,"a":"hey","b":-1,"c":null,"d":0,"e":true}
]
现在我正在这样做 示例:数组
是否可以在这里定义任何可接受的类型?
【问题讨论】:
标签: javascript flowtype
如何以对象键为字符串和混合类型的值来流动类型的对象数组?
example : [
{"appId":13118,"id":100,"a":"hey","b":-1,"c":null,"d":0,"e":true}
]
现在我正在这样做 示例:数组
是否可以在这里定义任何可接受的类型?
【问题讨论】:
标签: javascript flowtype
您需要使用 objects as maps 的 Flow 语法。
const example : Array<{[string] : mixed }> = [
{ "appId": 13118, "id": 100, "a": "hey", "b": -1, "c": null, "d": 0, "e": true }
]
附带说明,在 JavaScript 中,对象键始终是字符串,因此您无需在键周围加上引号:
const example : Array<{[string] : mixed }> = [
{
appId: 13118,
id: 100,
a: "hey",
b: -1,
c: null,
d: 0,
e: true
}
]
【讨论】: