Giter Site home page Giter Site logo

Comments (3)

trevorr avatar trevorr commented on July 23, 2024

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?

from datatype-expansion.

trevorr avatar trevorr commented on July 23, 2024

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.

from datatype-expansion.

psixdev avatar psixdev commented on July 23, 2024

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.

from datatype-expansion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.