Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jgehrcke opened this issue Nov 29, 2019 · 3 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@jgehrcke
Copy link

jgehrcke commented Nov 29, 2019

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?
@MartinJohns
Copy link
Contributor

Forget about the spec. It's not maintained at all and heavily outdated. The last real update was done in January 2016, almost 3 years ago. So realistically TypeScript has no specification anymore.

See #15711.

@fatcerberus
Copy link

The specific identifier used in an index signature is like the the names of parameters in a function type: it doesn’t affect anything at compile time, it’s just there for documentation.

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Dec 2, 2019
@typescript-bot
Copy link
Collaborator

This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

5 participants