superstruct
superstruct copied to clipboard
Infer using lazy() creates `any` type.
I'm unable to infer a type based off an object:
const ContainerNode = object({
key: string(),
selector: string(),
children: lazy(() => ContainerNode),
array: optional(boolean())
});
export type ContainerNode = Infer<typeof ContainerNode>; // = any
Removing children works as expected.
I just noticed documentation states that this is a thing. It'd be cool to somehow force the type when using "Describe" mode. as well.
With the inverse Describe method, you have to disable strict null checking for it to work.
I think this is likely a limitation of TypeScript.