Skip to content

Commit 6ec8414

Browse files
authored
"one of" is an alias for "either" (#514)
1 parent 5d1f242 commit 6ec8414

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/type-parser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export class TypeParser {
169169
};
170170
}
171171
}
172-
if (this.eat(/^either\b/i)) {
172+
if (this.eat(/^(?:either|one of)\b/i)) {
173173
let nextFieldIsLast = false;
174174
const unionTypes = [];
175175
while (true) {

test/type-parser.js

+18
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,24 @@ describe('type parsing', () => {
158158
],
159159
});
160160

161+
assert.deepStrictEqual(TypeParser.parse(`one of X, Y, or Z`), {
162+
kind: 'union',
163+
types: [
164+
{
165+
kind: 'opaque',
166+
type: 'X',
167+
},
168+
{
169+
kind: 'opaque',
170+
type: 'Y',
171+
},
172+
{
173+
kind: 'opaque',
174+
type: 'Z',
175+
},
176+
],
177+
});
178+
161179
assert.deepStrictEqual(TypeParser.parse(`a List`), {
162180
kind: 'list',
163181
elements: null,

0 commit comments

Comments
 (0)