Skip to content

docs: clarify model copying and inheritance - #12331

Merged
Timothee Guerin (timotheeguerin) merged 1 commit into
microsoft:mainfrom
timotheeguerin:docs/model-is-extends
Oct 26, 2026
Merged

Timothee Guerin (timotheeguerin) merged 1 commit into
microsoft:mainfrom
timotheeguerin:docs/model-is-extends

Conversation

@timotheeguerin

Copy link
Copy Markdown
Member

The models guide recommends is Record<T> over extends Record<T> as though they were interchangeable, obscuring their inheritance and decorator behavior.

Explain when to copy a model versus preserve an inheritance relationship, how model-level and property decorators are handled, and that both record forms enforce their indexer constraints. The is example now demonstrates adding a property while retaining the source model’s documentation.

Fixes #8541

@microsoft-github-policy-service microsoft-github-policy-service Bot added the meta:website TypeSpec.io updates label Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

@azure-sdk-automation

azure-sdk-automation Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused documentation changes match the reviewed compiler behavior and existing tests, with no unresolved issues.

No open issues 🎉

What changed in this PR

Clarifies model copying versus inheritance in the TypeSpec models guide, addressing the confusion raised in #8541 without changing compiler behavior.

Changes:

  • Explains when to use is versus extends, including record indexer constraints.
  • Documents how spread, inheritance, and copying handle properties and decorators.
  • Updates the is example to show an added property and preserved model documentation.
File Description
website/​src/​content/​docs/​docs/​language-basics/​models.md Clarifies model composition semantics and updates the copying example.

Review effort: Balanced

Merged via the queue into microsoft:main with commit cd8b22f Oct 26, 2026
30 checks passed
@timotheeguerin
Timothee Guerin (timotheeguerin) deleted the docs/model-is-extends branch October 26, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta:website TypeSpec.io updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Confusing and wrong documentation on is vs extend

3 participants