Skip to content

Clarify why a property name is required in Index Signatures #60982

Closed
@gitspeaks

Description

@gitspeaks

Acknowledgement

  • I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

Comment

According to the TypeScript Handbook, the syntax for an index signature requires a property name, as shown in the example:

interface StringArray {
  [index: number]: string;
}

However, it seems like the following syntax could also work and might be more concise:

interface StringArray {
  [number]: string;
}

Could you please clarify in the documentation why a property name (like index in the example above) is required in index signatures? It would be helpful to understand its purpose, especially when it seems unused in the object definition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions