You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
IIRC, the precedence of the array and union operators is not what you'd expect. Based on your spacing, it's obvious to a human that you want a union of arrays (and possibly nil). However, the type parser doesn't consider spacing and applies different rules. Could you try wrapping your arrays in parentheses and see if that gives the result you expect?
BTW, the code for that is here. As you can probably see, it's an ad hoc parser, and it doesn't follow consistent precedence rules. Unfortunately, AFAIK the RAML spec does not provide a grammar or precedences rules for type expressions.
If I try to use type (integer[]) | (string[]) the tools.expandedForm throws an error:
Error: could not resolve: integer[])
at expandForm (/node_modules/datatype-expansion/src/expanded.js:134:11)
at form.anyOf.form.anyOf.map.elem (/node_modules/datatype-expansion/src/expanded.js:226:39)
at Array.map (<anonymous>)
at expandUnion (/node_modules/datatype-expansion/src/expanded.js:226:27)
at expandForm (/node_modules/datatype-expansion/src/expanded.js:104:14)
at expandForm (/node_modules/datatype-expansion/src/expanded.js:96:16)
at expandForm (/node_modules/datatype-expansion/src/expanded.js:165:36)
at Object.expandedForm (/node_modules/datatype-expansion/src/expanded.js:33:12)
Is this the library bug?
But I can use type ((integer[]) | (string[])) and get the result I expect, thank you.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have the context:
And I output expanded and canonical forms for types:
U1
expanded
canonical
U2
expanded
canonical
As you can see, the array of strings in the first union is turned into a string. It looks like a bug.
The text was updated successfully, but these errors were encountered: