Skip to content

Commit 6a1a141

Browse files
rix0rrriankhou
andauthored
docs: describe type intersections in the jsii doc page (#4942)
--- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0 --------- Co-authored-by: Ian Hou <[email protected]>
1 parent ace3745 commit 6a1a141

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

gh-pages/content/specification/2-type-system.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ array is produced each time it is passed through the process boundary.
4444
!!! info
4545
Items in the list may be passed by-reference (according to their type's specification), in which case mutating
4646
operations performed on those may be visible across the process boundary.
47-
47+
4848
[Find out more here](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#arrays)
4949

5050
### Enum
@@ -109,7 +109,7 @@ boundary. As a consequence, they may not include any method.
109109
!!! question
110110
The by-value nature of `object` is problematic because **TypeScript** makes no guarantee with respects to the
111111
absence of methods on `object`, and properties may be dynamic.
112-
112+
113113
[Find out more here](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#object-types)
114114

115115
### Promises
@@ -188,6 +188,25 @@ API.
188188

189189
[Find out more here](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
190190

191+
### Type Intersections
192+
193+
Type intersections are supported, with limitations. Type intersections indicate that values, specifically object
194+
instances, must implement two or more interfaces simultaneously. They are written as `TypeA & TypeB`. Type intersections
195+
are supported with the following limitations:
196+
197+
- All branches of the type intersection must be (behavioral) interfaces, not _structs_.
198+
- Type intersections may only appear in input position. That means they may only appear as a function argument,
199+
or a member of a struct that is exclusively used as a function argument. That excludes them appearing as function
200+
return types, class or behavioral interface members, or as struct members that are the return types of functions.
201+
202+
Type intersection support was added in:
203+
204+
| Tool | Version |
205+
|------|---------|
206+
| `jsii` | `>= 5.9.6` |
207+
| `jsii-rosetta` | `>= 5.9.5` |
208+
| `jsii-pacmak`, `jsii-reflect`, `jsii-diff` | `>= 1.115.0` |
209+
191210
## Serialization Behavior
192211

193212
When values are passed between the _host_ process and the `node` process, they are serialized as JSON documents. They

0 commit comments

Comments
 (0)