You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This might be a fringe case and I'm going to workaround it using Enums instead but I still think this is intersting and should probably be fixed / we should add a proper error here.
When using a normal union type like so 'a' | 'b' the schema generator works just fine.
But when creating a union type from a Set (it's the same union) we an error.
to create the union first create a helper type like so: export type SetValues<T> = T extends Set<infer V> ? V : never;
Then call this type with your set (it is important to use as const with the provided array) type myUnion = SetValues<new Set(['a', 'b'] as const)> // 'a' | 'b'
use this type in an interface to generate a schema
Get following error:
UnknownNodeError: Unknown node of kind "NewExpression" at ChainNodeParser.getNodeParser (C:\project\node_modules\ts-json-schema-generator\src\ChainNodeParser.ts:50:15)
The text was updated successfully, but these errors were encountered:
This might be a fringe case and I'm going to workaround it using Enums instead but I still think this is intersting and should probably be fixed / we should add a proper error here.
When using a normal union type like so
'a' | 'b'
the schema generator works just fine.But when creating a union type from a Set (it's the same union) we an error.
to create the union first create a helper type like so:
export type SetValues<T> = T extends Set<infer V> ? V : never;
Then call this type with your set (it is important to use as const with the provided array)
type myUnion = SetValues<new Set(['a', 'b'] as const)>
// 'a' | 'b'use this type in an interface to generate a schema
Get following error:
UnknownNodeError: Unknown node of kind "NewExpression" at ChainNodeParser.getNodeParser (C:\project\node_modules\ts-json-schema-generator\src\ChainNodeParser.ts:50:15)
The text was updated successfully, but these errors were encountered: