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

Support for Generics #4

Open
shane-lab opened this issue Feb 7, 2020 · 0 comments
Open

Support for Generics #4

shane-lab opened this issue Feb 7, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@shane-lab
Copy link

Hi,

This is one of the only library that I have come across that does what I need it to do: parse definitions to json (schemas).

Awesome!

I am facing one problem, and that is the ability to be able to parse custom type definitions with one or more generic types. I aware, at least from what I can guess, that this is meant for staticly typed defintions.

I use generic types extensively. I can workaround most of them, but there are some scenarios where I rather do not. Here's a simplified example:

// types/index.d.ts
export type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]> }

// types/x.d.ts
interface X {
  a: string,
  b: boolean,
  c?: number,
  d: {
    e: any,
    f: any,
    g: any,
  },
}
export type DetailsX = DeepPartial<X>

// src/create-or-update-x.ts
const upsertWithX = (x: DetailsX): X => ...;

I wonder what your thoughts are for generating a JSON mapping for DetailsX (ideally DeepPartial<X>).

@paleo paleo added the enhancement New feature or request label Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants