-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate Zod typing from library (#350)
## Summary <!-- Succinctly describe your change, providing context, what you've changed, and why. --> Separates Zod typing requirements from the Zod library itself, hopefully allowing us to support multiple client versions. ## Checklist <!-- Tick these items off as you progress. --> <!-- If an item isn't applicable, ideally please strikeout the item by wrapping it in "~~"" and suffix it with "N/A My reason for skipping this." --> <!-- e.g. "- [ ] ~~Added tests~~ N/A Only touches docs" --> - [ ] ~~Added a [docs PR](https://github.com/inngest/website) that references this PR~~ N/A Bug fix - [ ] ~~Added unit/integration tests~~ N/A Exists already - [x] Added changesets if applicable ## Related <!-- A space for any related links, issues, or PRs. --> <!-- Linear issues are autolinked. --> <!-- e.g. - INN-123 --> <!-- GitHub issues/PRs can be linked using shorthand. --> <!-- e.g. "- inngest/inngest#123" --> <!-- Feel free to remove this section if there are no applicable related links.--> - Alternative to #336
- Loading branch information
1 parent
b5f0532
commit 933b998
Showing
4 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"inngest": patch | ||
--- | ||
|
||
Separate Zod typing from library, enabling minor-agnostic versioning support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/** | ||
* Shim for Zod types to ensure hopeful compatibility between minor versions; | ||
* let developers the latest version of Zod without having to have Inngest match | ||
* the same version. | ||
* | ||
* Feels weird to be using internal properties like this, but types break across | ||
* minors anyway, so at least with this we rely on fewer fields staying the | ||
* same. | ||
*/ | ||
export type ZodLiteral<TValue = any> = { | ||
get value(): TValue; | ||
_def: { | ||
typeName: "ZodLiteral"; | ||
}; | ||
}; | ||
|
||
export type ZodTypeAny = { | ||
_type: any; | ||
_output: any; | ||
_input: any; | ||
_def: any; | ||
}; | ||
|
||
export type ZodObject<TShape = { [k: string]: ZodTypeAny }> = { | ||
get shape(): TShape; | ||
_def: { | ||
typeName: "ZodObject"; | ||
}; | ||
}; | ||
|
||
export type AnyZodObject = ZodObject<any>; | ||
|
||
export type ZodAny = { | ||
_any: true; | ||
}; | ||
|
||
export type infer<T extends ZodTypeAny> = T["_output"]; |