vega / ts-json-schema-generator

Generate JSON schema from your Typescript sources
MIT License
1.44k stars 190 forks source link

Incorrect typing when a type uses Omit and inherits properties from a grandparent interface #1998

Open afonsof opened 3 months ago

afonsof commented 3 months ago

I am experiencing an incorrect typing issue in TypeScript when using Omit on an interface that inherits properties from a grandparent interface.

Steps to Reproduce

Code Example

interface Grandparent {
  a?: string
}

interface Parent extends Grandparent {
  b: string
}

export type Child = Omit<Parent, 'b'>

Generated output

{
  "definitions": {
    "Child": {
      "properties": {
        "a": {}
      },
      "required": [
        "a"
      ],
    }
  }
}

Expected Behavior

The grandparent property should be correctly typed and not be required


{
  "definitions": {
    "Child": {
      "properties": {
        "a": {
          "type": "string"
         }
      }
    }
  }
}
abdalla-rko commented 2 weeks ago

I have the same issue🙁

arthurfiorette commented 2 weeks ago

Hi! Thanks for the bug report, would you want to open a PR to address this? Remember to add unit tests.