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

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

Open
afonsof opened this issue Jun 20, 2024 · 2 comments
Labels

Comments

@afonsof
Copy link

afonsof commented Jun 20, 2024

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

  • Define a grandparent interface with a optional property.
  • Create a parent interface that extends the grandparent interface.
  • Create a new type using Omit to exclude a property from the parent interface.
  • Generate the schema using the Child type

#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
Copy link

abdalla-rko commented Sep 16, 2024

I have the same issue🙁

@arthurfiorette
Copy link
Collaborator

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

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

No branches or pull requests

3 participants