Skip to content

Regression in 0.4.0 #12

Description

@piranna

With version 0.3.0, the string warning is valid with the next code:

const {parsedTypeParse} = require('levn')
const {parseType} = require('type-check')

const entry = '(String | Number, Undefined | {...})'
const ruleTypeDesc = `${entry} | [${entry}] | {...}`

const ruleType = parseType(ruleTypeDesc)

if(typeof rules === 'string') rules = parsedTypeParse(ruleType, rules)

After upgrading to 0.4.1, I get the next error:

Value "warning" does not type check against [{"structure":"tuple","of":[[{"type":"String"},{"type":"Number"}],[{"type":"Undefined"},{"structure":"fields","of":{},"subset":true}]]},{"structure":"array","of":[{"structure":"tuple","of":[[{"type":"String"},{"type":"Number"}],[{"type":"Undefined"},{"structure":"fields","of":{},"subset":true}]]}]},{"structure":"fields","of":{},"subset":true}].

What I was trying to do, is that the warning string gets parsed and converted as one-tuple with a warning string as its first and only value (or two-tuple of string-undefined, that's the same for this use case).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions