Repository navigation
feat(compiler): allow inline decorators on declaration expressions - #31
Closed
timotheeguerin wants to merge 2 commits into
Closed
timotheeguerin wants to merge 2 commits into
timotheeguerin wants to merge 2 commits into
Conversation
timotheeguerin
force-pushed
the
decl-expr-inline-decorators
branch
from
June 22, 2026 16:49
5894e7b to
24d23ff
Compare
Owner
Author
|
Closing in favor of bundling this work directly into the base declaration-expressions PR microsoft#11019. Following a design-meeting decision, inline decorators (and augment decorators) on declaration expressions are now part of that single feature rather than a separate stacked change. The changes have been moved onto the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on top of the declarations-as-expressions work (microsoft#11019, branch
decl-expr).Enables applying decorators inline to
model,enum,union, andscalardeclarations used in expression position.Changes
parser.ts): the@case inparsePrimaryExpressionnow parses a decorator list and, when followed by amodel/enum/union/scalarkeyword, dispatches to the correspondingparse*Statement(withposcaptured at@so the node span includes the decorators). Decorators before any other expression still reportinvalid-decorator-location("Cannot decorate expression.").spec.emu.html): added the optionalDecoratorList?prefix to the four*DeclarationExpressionproductions.printer.ts): the fourprint*Statementprinters now passtryInline: isInExpressionPosition(path), keeping decorators on the same line in expression position while statement-position decorators still break to their own line. Output is idempotent.Tests
@docapplies to anonymous enum, named model, keyword union, and scalar declaration expressions (verified viagetDoc), plus a negative case (decorator before astringreference still rejected).Discussion
parse*Statementalready plumbsdecoratorsonto the AST node and the checker already appliesnode.decorators. The only blocker was the parser discarding decorators in expression position.