Skip to content

Conversation

@shetzel
Copy link
Contributor

@shetzel shetzel commented Jun 23, 2025

Adds a new XOR type definition so that we can define types that behave like this:

interface A { name: string; }
interface B { id: string; }

type MyXORType = XOR<A, B>;

const valid1: MyXORType = { name: 'My_Foo' }; // Valid
const valid2: MyXORType = { id: '0xT0000cxxxeeRGtHM' };    // Valid

const invalid1: MyXORType = { name: 'My_Foo', id:'0xT0000cxxxeeRGtHM' }; // Error: Object literal may only specify known properties
const invalid2: MyXORType = {}; // Error: Property 'name' or 'id' is missing

@W-18851777@

@shetzel shetzel requested a review from a team as a code owner June 23, 2025 17:35
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.

3 participants