如何使用对象键作为字符串和混合类型的值来流动类型的对象数组
how to flow type array of objects with object keys as string and values of mixed type
如何使用对象键作为字符串和混合类型的值来流动类型对象数组?
example : [
{"appId":13118,"id":100,"a":"hey","b":-1,"c":null,"d":0,"e":true}
]
现在我这样做是因为
示例:Array<{[string] : $ANY}>
是否可以在此处为任何类型定义可接受的类型?
您需要为 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
}
]
如何使用对象键作为字符串和混合类型的值来流动类型对象数组?
example : [
{"appId":13118,"id":100,"a":"hey","b":-1,"c":null,"d":0,"e":true}
]
现在我这样做是因为 示例:Array<{[string] : $ANY}>
是否可以在此处为任何类型定义可接受的类型?
您需要为 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
}
]