在TypeScript中表示Adobe的类似数组的集合

时间:2017-09-10 21:32:11

标签: arrays typescript collections typing

Adob​​e的ExtendScript功能Number - 索引集合,例如ArtLayers类型。 document.artLayers[0]可能会让我获得本文档中的第一个ArtLayerArtLayers还有许多其他字段和方法。如何在.d.ts文件中最好地表示此类型?

1 个答案:

答案 0 :(得分:3)

ExtendScript的定义已经找到here。我看着它,看起来并不完美,但它可能是一个起点/参考点。

如果我必须像你描述的那样写一个类型,我可能会使用这样的东西:

interface ArtLayers {
    length: number;
    [index: number]: ArtLayer;
    parent: Document
    typename: string
    add(): void
    getByName(name: string): void
    removeAll(): void
}