I know this question has been already answered a lot, but I am curious why JavaScript and even TypeScript are not able to read the following code and throw a Syntax error:
const someVariable = 'abcd abcd some text'
const someObject = {
`${someVariable}andSomethingElse`: 'someValue'
}
The current Syntax requires me to store that in another variable, and call it with an “array-like-syntax”, which is a bit annoying:
const someVariable = 'abcd abcd some text'
const objectKey = `${someVariable}andSomethingElse`
const someObject = {
[objectKey]: 'someValue'
}
I’m curious why there is not even a change request in that regard, because it seems like such a useful thing, but not even TypeScript seems to support it (internally the transpiler could still turn it into the syntax as JS requires it).
I am curious, because honestly I don’t see anything wrong with this change, as it makes the lives of devs just easier.
So my question is: Why is this not possible in the year 2024?