Skip to content

feat: support decorators on type expressions#5

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/add-decorators-support
Draft

feat: support decorators on type expressions#5
Copilot wants to merge 5 commits intomainfrom
copilot/add-decorators-support

Conversation

Copy link

Copilot AI commented Feb 19, 2026

Decorators were previously rejected on all type expressions. This adds a DecoratedExpression AST node that wraps any expression with decorators, enabling inline decoration of models, type references, unions, and is/extends targets.

model Pet {
  owner: @doc("Owner contact info") { name: string; phone: string };
}

alias Address = @doc("A mailing address") { street: string; city: string };

model Extended is @tag("extended") Base { extra: string }

Compiler changes

  • types.ts: New SyntaxKind.DecoratedExpression, DecoratedExpressionNode interface, added to Expression union
  • parser.ts: parsePrimaryExpression now calls parseDecoratedExpression() instead of reportInvalidDecorators; visitChildren updated
  • checker.ts: checkDecoratedExpression checks target then applies decorators individually (avoids re-applying existing decorators on already-finished types). checkModelIs and checkClassHeritage unwrap DecoratedExpression to validate the inner target correctly
  • printer.ts: printDecoratedExpression for formatter support
  • ast/index.ts: Export DecoratedExpressionNode

Tests

  • 6 parser tests: decorated inline models, aliases, type references, is, unions, arrays
  • 6 checker tests: @doc on inline models and aliases, decorators on type references, is expressions, custom decorators, union expressions

Documentation

  • decorators.md: Updated scope description; new "Decorating expressions" section
  • models.md: New "Decorating inline models" section
  • Documentation sample updated with @doc on an inline model expression

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 19, 2026 03:10
…ter support

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
…ge; add tests

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
…decorated expressions

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
…ting ones

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for decorating model expressions with tests feat: support decorators on type expressions Feb 19, 2026
Copilot AI requested a review from johanste February 19, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments