Skip to content

Support for Generics #4

Description

@shane-lab

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>).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions