Skip to content

Document union extends scenarios for language review - #11977

Draft
iscai-msft wants to merge 2 commits into
microsoft:mainfrom
iscai-msft:union-extends-scenarios
Draft

iscai-msft wants to merge 2 commits into
microsoft:mainfrom
iscai-msft:union-extends-scenarios

Conversation

@iscai-msft

@iscai-msft iscai-msft commented Sep 15, 2026

Copy link
Copy Markdown
Member

Union extends language review

Review the 12 scenarios: inheritance, structural compatibility, spread/model-is, ancestry, variant reuse, direct use, explicit base/default alternatives, union composition, and non-model constraints.

Please comment using this template. Group case IDs when the answer is the same:

Language:
Case ID(s):
Proposed public API sketch (union/base/variants/operation signature):
Request construction:
Response handling + accessing variant-specific data:
Serialization (tags/envelopes/inheritance/conversions):
Reuse impact:
Required restrictions with concrete language/runtime reason:

Distinguish a limitation of the chosen representation from functionality that simply needs implementation. union extends is structural; it does not imply nominal inheritance, openness, or serialization.

Open question: Does an object-envelope default describe the payload or the complete envelope, and how does its constraint apply? These semantics remain unspecified; the document does not invent a wire contract.

Related: Azure/typespec-azure#5390, microsoft/typespec#2737, and compiler PR #11771. This review informs, rather than implements, the Azure lint design.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added lib:http-specs For issues/prs related to the @typespec/http-specs package spector Issues related to spector and the spec sets labels Sep 15, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-specs@11977

commit: d1c0904

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

Replace runtime fixtures and Spector changes with a compact12-case review document.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@iscai-msft iscai-msft changed the title Add union extends Spector matrix and scoped feature configuration Document union extends scenarios for language review Sep 15, 2026
@azure-sdk-automation

azure-sdk-automation Bot commented Sep 15, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

union OpenPets extends Named { cat: Cat, dog: Dog, UnknownPet }

// UE11: Nested variant versus named/anonymous union constraint.
union NestedPets extends Named { pets: Pets, bird: Bird }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will the Pets be flattened here?

union OpenStatus extends string { known: "known", custom: string }
enum Direction { left, right }
union Directions extends Direction { left: Direction.left, right: Direction.right }
union PetArrays extends Named[] { cats: Cat[], dogs: Dog[] }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How does this case work? Limit to Named array?


## Serialization variations

For applicable cases, consider these formats without repeating identical answers:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this section for discriminated union? I suppose extends only add constraints but should not have any impact for API/payload.

compiler-invalid. Inline arrays need a separate wire design, not a claimed
compiler prohibition. Do not infer unknown-tag fallback for closed unions.

## Language response template

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Little bit confused about the ask for languages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:http-specs For issues/prs related to the @typespec/http-specs package spector Issues related to spector and the spec sets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants