Skip to content

Commit

Permalink
"one of" is an alias for "either" (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Jan 24, 2023
1 parent 5d1f242 commit 6ec8414
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/type-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class TypeParser {
};
}
}
if (this.eat(/^either\b/i)) {
if (this.eat(/^(?:either|one of)\b/i)) {
let nextFieldIsLast = false;
const unionTypes = [];
while (true) {
Expand Down
18 changes: 18 additions & 0 deletions test/type-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,24 @@ describe('type parsing', () => {
],
});

assert.deepStrictEqual(TypeParser.parse(`one of X, Y, or Z`), {
kind: 'union',
types: [
{
kind: 'opaque',
type: 'X',
},
{
kind: 'opaque',
type: 'Y',
},
{
kind: 'opaque',
type: 'Z',
},
],
});

assert.deepStrictEqual(TypeParser.parse(`a List`), {
kind: 'list',
elements: null,
Expand Down

0 comments on commit 6ec8414

Please sign in to comment.