Skip to content

Any name for index type signatures like TS (not just "key"). #1972

@trusktr

Description

@trusktr

Input:

class MyClass {
    [coolKeys: number]: boolean
}

const o = new MyClass 

o[1] = true

TypeScript playground (works)

AssemblyScript playground (error)

The error had me thinking that it was an unsupported feature:

;; ERROR TS1005: 'key' expected.
;; 
;;      [coolKeys: number]: boolean

I thought "a key is required here? I put a key there, but it must not support it".

I didn't realize that it is saying I need to actually name my key "key". Changing it to "key" gets past that error, although in the following example it has some other error I don't understand:

AssemblyScript playground (no more "'key' expected" error)

In asdom I did not have the new error that the previous example has, and it all is working well (NodeList bindings with [] indexed access).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions