[compiler] Identifier interpolation#9791
[compiler] Identifier interpolation#9791witemple-msft wants to merge 5 commits intomicrosoft:mainfrom
Conversation
commit: |
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
| // Temporary solution to allow reserved keywords as identifiers in certain contexts. This should get expanded to a more general solution per keyword category. | ||
| allowReservedIdentifier?: boolean; | ||
| }): IdentifierNode { | ||
| if (token() === Token.StringTemplateHead) { |
There was a problem hiding this comment.
I think I don't like this way of implementing this. It seems too fragile to allow this anywhere we call parseIdentifier... I think it would be better to have a parseIdentifierOrInterpolated and only call that from syntactic positions where it should be allowed.
There was a problem hiding this comment.
On the other hand diagnostic behavior is probably better this way, since we get a clean "interpolation not allowed here" error instead of "unexpected token"...
WIP
This PR enables interpolation of string values into identifiers in many cases, reusing the existing syntax for keyword escapes.
Typedeclaration identifiers: model, union, enum, interface, etc. (with the limitation that these are not possible to reference by identifier, but they can still be declared. But NOT namespaces as this is just too fraught.