Skip to content

spec: arbitrary choice of BindingIdentifier in index signature not clearly documented #35422

Closed
@jgehrcke

Description

@jgehrcke

This is a point about the specification itself (and I do hope that it's OK to report it here).

In an Index Signature -- currently documented in these paragraphs -- there is the BindingIdentifier.

Based on my own testing, based on an answer to this question on StackOverflow, and based on some blog posts the precise choice of the BindingIdentifier in an index signature does not matter to TypeScript.

It seems like one can choose an arbitrary value, and people seem to like key or index to make the intent explicit, readable. Let me quote this resource:

the name of the index signature e.g. index in { [index:string] : {message: string} } has no significance for TypeScript and is only for readability.

Now, I am new to TypeScript, and I really wanted to see a comment on that aspect in the source of truth, in the language specification. But I couldn't find that part commented on in section 3.9.4, and also not elsewhere in the spec. I have probably missed it elsewhere.

Action items depend on answers to these questions:

  • is that behavior specified somewhere in the spec?
  • if it is: should we link to that from section 3.9.4?
  • if it is not commented on in the spec: should this be added somewhere?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions