我有一个自定义对象声明(ThreadObj),我想创建一个THREADLISTS,持有多个Threadlist数组。所以
Threadlist:ThreadObj[]=[];
THREADLISTS:[ThreadObj[]][ThreadObj]=[][]; //how to type and init?
第一个dim是ThreadObj [],第二个是ThreadObj。
干杯
答案 0 :(得分:2)
示例:
type ThreadObj = {foo:string}
type ThreadList = ThreadObj[];
type ThreadListList = ThreadList[];
const obj: ThreadObj = {
foo: '123'
}
const singleDim: ThreadList = [
obj
]
const multiDim: ThreadListList = [
singleDim,
singleDim
]
一步到位:
const allInOneStep: {foo:string}[][] = [
[
{
foo: 'hello'
},
{
foo: 'is it me'
}
],
[
{
foo: 'you are looking for'
}
]
]
答案 1 :(得分:2)
不会那样:
let arr:ThreadObj[][] = []