zod icon indicating copy to clipboard operation
zod copied to clipboard

fix: adds ` | never` to `objectOutputType` as a signal to the LSP tha…

Open ahrjarrett opened this issue 8 months ago • 1 comments

This small PR updates the type of objectOutputType to fully evaluate the type.

This only seems to occur with catchall schemas, and only sometimes.

Before:

Screenshot 2024-06-17 at 12 12 45 PM

You can see in the screenshot that the output type includes the type constructor that created it (objectOutputType).

The fix for this when it occurs is to unify the result that objectOutputType returns with never.

The union of any type with the bottom (never) is the first type ( | never is an identity operation), so this is a no-op in every context except for the LSP, which interprets a union as a signal that it needs to evaluate the node.

After:

Screenshot 2024-06-17 at 12 14 26 PM

ahrjarrett avatar Jun 17 '24 17:06 ahrjarrett