microsoft/typespec

Public

mirrored fromhttps://github.com/microsoft/typespecAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
ce9c567e5bfb441bb6415699a6b6fa797bc08f2e

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

docs/language-basics/intersections.md

21lines · modepreview

---
id: intersections
title: Intersections
---

# Intersections

Intersections in programming define a type that must encompass all the constituents of the intersection. You can declare an intersection using the `&` operator.

```typespec
alias Dog = Animal & Pet;
```

An intersection is functionally equivalent to [spreading](./models.md#spread) both types.

```typespec
alias Dog = {
  ...Animal;
  ...Pet;
};
```