Skip to content

Support properties + anyOf together #243

@bradzacher

Description

@bradzacher

#229 and #167 both proposed this, but were closed even though it is not supported - the workaround in #167 was to change the schema, which I can't do because I don't control the schemas.

{
  type: 'object',
  properties: {
    a: { type: 'string' },
    b: { type: 'number' }
  },
  anyOf: [
    { required: ['a'] },
    { required: ['b'] }
  ]
}

Should produce:

type T = 
  | {
    a: string,
    b?: number,
  }
  | {
    a?: string,
    b: number,
  }

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