Commit faf33a2
fix: surface @deprecated on re-exported compat aliases (#6072)
* fix: surface @deprecated on re-exported compat aliases
JSDoc `@deprecated` placed on `export { X as Y }` / `export type { X as Y }`
specifiers is dropped when the alias is re-exported again, so IDEs never
flagged `ZodTypeAny`, `ZodSchema`, `Schema`, `TypeOf`, `Infer`,
`ZodFirstPartySchemaTypes`, `ZodFlattenedError`, `ZodFormattedError`,
`ZodErrorMap`, `_max` or `_min` as deprecated. Declare each as a standalone
aliased declaration (matching inferFlattenedErrors/BRAND) so the tag
propagates to the emitted types.
* fix(v4): keep the deprecated ZodType aliases generic
`ZodTypeAny`, `ZodSchema` and `Schema` were re-exports of `ZodType`, so they
inherited its three defaulted type parameters. Redeclaring them as
`export type ZodSchema = ZodType` surfaces the `@deprecated` tag but collapses
them to zero arity, so `z.ZodSchema<string>` — the Zod 3 idiom this compat
layer exists to serve — stops compiling with TS2315. Restate the parameters
and forward them.
Also revert the `core/api.ts` hunk. `_max` and `_min` are value re-exports,
and TypeScript already reports their deprecation through the alias; only
type-only export specifiers drop the tag. The change traded a hoisted
function re-export for a TDZ-bound const and fixed nothing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Colin McDonnell <3084745+colinhacks@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 3956224 commit faf33a2
2 files changed
Lines changed: 30 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
| |||
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
89 | 87 | | |
90 | 88 | | |
91 | 89 | | |
| |||
0 commit comments