Skip to content

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Sep 11, 2025

This adds support for intersection types to the jsii compiler.

There are a number of restrictions to the use of intersection types:

  • They can only appear in argument position, or in structs that are exclusively used as the input to functions.
    • Not as return values of functions
    • Not in structs that are returned by functions
    • Not as arguments to constructors
    • Not as property types
  • They must intersect only (behavioral) interface types.
    • Not structs
    • Not primitives
    • Not class types
  • All shared members of interfaces that are intersected must have the same types and arguments as each other.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This adds support for intersection types to the jsii compiler.

There are a number of restrictions to the use of intersection types:

- They can only appear in argument position, or in structs that are
  exclusively used as the input to functions.
    - Not as return values of functions
    - Not in structs that are returned by functions
    - Not as arguments to constructors
    - Not as property types
- They must intersect only (behavioral) interface types.
    - Not structs
    - Not primitives
    - Not class types
- All shared members of interfaces that are intersected must have the
  same types and arguments as each other.
@rix0rrr rix0rrr requested a review from a team September 11, 2025 12:43
@mrgrain mrgrain marked this pull request as draft September 11, 2025 12:44
auto-merge was automatically disabled September 11, 2025 12:44

Pull request was converted to draft

Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

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

some feedback

@rix0rrr rix0rrr marked this pull request as ready for review September 15, 2025 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants