Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when Intersect objects with same key #67

Closed
thezzisu opened this issue Apr 10, 2021 · 1 comment · Fixed by #68
Closed

Error when Intersect objects with same key #67

thezzisu opened this issue Apr 10, 2021 · 1 comment · Fixed by #68

Comments

@thezzisu
Copy link
Contributor

Step to reproduce

const A = Type.Object({
      a: Type.String(),
})
const B = Type.Object({
      a: Type.String()
})
const T = Type.Intersect([A, B])

output

Error: schema is invalid: data/required should NOT have duplicate items (items ## 1 and 0 are identical)

generated schema

{
  type: 'object',
  kind: Symbol(ObjectKind),
  additionalProperties: false,
  properties: { a: { kind: Symbol(StringKind), type: 'string' } },
  required: [ 'a', 'a' ]
}

expected

{
  type: 'object',
  kind: Symbol(ObjectKind),
  additionalProperties: false,
  properties: { a: { kind: Symbol(StringKind), type: 'string' } },
  required: [ 'a' ]
}
@thezzisu
Copy link
Contributor Author

However there's a workaround:

const c = Type.Intersect([a as any, b as any])
c.required = [...new Set(c.required)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant