【发布时间】:2023-03-30 19:07:01
【问题描述】:
我对 TypeScript 有一些经验,但我一直在想一件事。我知道Array<string> 和string[] 之间的区别。我知道声明可以互换使用,f.e.
export class SomeClass {
someDeclaration: Array<SomeObject>;
otherDeclaration: SomeObject[];
}
但在我的工作中,我遇到了其他的声明结构,即:
export class OtherClass {
strangeDeclaration: [SomeObject];
}
我的问题是:声明数组的方法是否正确?这种方式和其他(最流行的)方式有什么区别?结构从何而来?
【问题讨论】:
标签: arrays typescript declaration