typeonly
typeonly copied to clipboard
Support for Generics
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>
).