ts-json-schema-generator
ts-json-schema-generator copied to clipboard
Schema not generated for "base" type declaration with a generic parameter
Example types:
export type BaseExample<T> = {
results: T;
};
export type BaseExampleWithDefault<T = Record<string, unknown>[]> = {
results: T;
};
export type BaseExampleWithConstraint<T extends Record<string, unknown>[]> = {
results: T;
};
None of these result in a schema with these config options (or without):
expose=allskipTypeCheck=truetype=*
Running 2.4.0-next.7
This seems like an intentional omission; if so consider this a feature request. But it seemed like it should work looking at the generic-default valid data case. What's the difference between Generic there and MyObject if the latter does nothing but alias it?
https://github.com/vega/ts-json-schema-generator/issues/346 also seems to demonstrate the same issue but the test case for the fix in https://github.com/vega/ts-json-schema-generator/pull/347 omits the type arguments.
Also when I do add an implementation the type is given a quite verbose name that varies depending on what the implementation specifies for the argument, e.g.:
Example<Record<string, unknown>[]>Example<def-alias-t_lib_lib.es5.d.ts-73393-73519-t_lib_lib.es5.d.ts-0-217694<string,unknown>[]>
Example<object[]>Example<object-131809358-260-266-131809358-260-268-131809358-238-269-131809358-195-270-131809358-0-271[]>
This is maybe related to https://github.com/vega/ts-json-schema-generator/pull/2009
If the name itself is unique at least within the given file I would expect the definition to be named the same as the type, without any reference to it's arguments.