如何使用对象键作为字符串和混合类型的值来流动对象的类型数组?
example : [
{"appId":13118,"id":100,"a":"hey","b":-1,"c":null,"d":0,"e":true}
]
目前,我正在这样做例如:Array
是否可以在此处定义任何可接受的类型?
您需要对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
}
]