AArtem UdovichenkoAdd ets2panda
0ee26c4f创建于 2023年10月10日历史提交

Indexed signatures are not supported

Rule arkts-no-indexed-signatures

Severity: error

ArkTS does not allow indexed signatures. Use arrays instead.

TypeScript


    // Interface with an indexed signature:
    interface StringArray {
        [index: number]: string
    }

    function getStringArray() : StringArray {
        return ["a", "b", "c"]
    }

    const myArray: StringArray = getStringArray()
    const secondItem = myArray[1]

ArkTS


    class X {
        public f: string[] = []
    }

    let myArray: X = new X()
    const secondItem = myArray.f[1]