Open
Conversation
Add optional `id` field to `ModelExpressionNode` to support inline
named models in property type positions. Example:
```typespec
model Parent {
child: model Child {
age: int32;
}
}
```
Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for inline named models with tests and documentation
feat: add support for inline named model expressions
Feb 10, 2026
Owner
|
@copilot update the changelog |
Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Author
…rator and nesting support with tests Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
…st, response, and template parameter Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Copilot
AI
changed the title
feat: add support for inline named model expressions
feat: inline named model expressions
Feb 10, 2026
Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Owner
|
@copilot fix the failing checks |
Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Author
…med-models-support
|
All changed packages have been documented.
Show changes
|
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.
Adds support for defining named models inline in type expression positions:
Inline named models are declared in the enclosing namespace/script scope, making them referenceable by augment decorators and subject to standard duplicate-name detection. Arbitrarily deep nesting is supported.
Compiler
types.ts): Optionalid: IdentifierNodeonModelExpressionNodeparser.ts):ModelKeywordcase inparsePrimaryExpressiondispatches toparseInlineNamedModelExpression();visitChildrentraverses optionalidbinder.ts):bindModelExpressionusesgetEnclosingDeclarationScope()to walk up to the nearest namespace/script scope for symbol declarationchecker.ts):checkModelExpressionuses explicitcreateType(matchingcheckModelStatementpattern), setsModel.namefromnode.id, processes augment decorators for named inline modelsprinter.ts): Emitsmodel <Name>prefix for named model expressionsGrammar & Semantic Tokens
inlineNamedModelExpressionTextMate rule formodel <Name> { ... }in expression positionstatementKeywordExceptModel/universalEndExceptModelpreventmodelfrom prematurely terminating type annotation and model property contextsclassify.tshandlesModelExpressionwithidfor semantic token highlightingTests
model.is(),model.getEffectiveModel(),type.getPlausibleName(),type.clone(),type.isAssignableTo(),type.resolve()Sample
Updated playground
http.tspwith inline named models in a model property, operation response, and template parameter position.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.