Releases: sachinraja/zod-to-ts
v1.2.0
What's Changed
- support converting native enum to union by @shaketbaby in #34
New Contributors
- @shaketbaby made their first contribution in #34
Full Changelog: v1.1.4...v1.2.0
v1.1.4
- support typescript v5
v1.1.3
v1.1.2
What's Changed
- update to
[email protected]
and update usage of deprecated functions
v1.1.1
What's Changed
- put jsdoc comments on their own lines by @RobinTail in #15
using this schema:
z.object({
name: z.string().describe('first name')
})
previous version printed this:
type User = {
/** first name */ name: string
}
this version prints this:
type User = {
/** first name */
name: string
}
v1.1.0
z.describe()
/ descriptions are now supported for object properties:
example input:
const schema = z.object({
num: z.number().describe('a number')
})
output before update:
{
num: number
}
output after update:
{
/** a number */ num: number
}
Additionally, you can now add comments in createTypeAlias
too:
const schema = z.object({
name: z.string()
price: z.number()
}).describe('an item')
const typeAlias = createTypeAlias(
schema,
'Item',
// can optionally pass a comment here
// this example just passes the description from the zod schema - 'an item'
schema.description
)
v1.0.1
Changes
Properties are now correctly handled as identifiers or string literals.
example input:
const schema = z.object({
'needs-quotes': z.string()
})
output before update (not valid TS):
{
needs-quotes: string
}
output after update:
{
"needs-quotes": string
}
Additionally, numeric values in enums are now handled correctly (only string values could be passed before).
Full Changelog: v1.0.0...v1.0.1
v1.0.0
Changes
Optionals are now correctly generated in accordance with Zod's z.infer
.
For example, if we have this schema:
const schema = z.object({
foo: z.number().optional()
})
previously this was generated:
{
foo: number | undefined
}
after this update, this is generated:
{
foo?: number | undefined
}
PRs
- fix handling of optionals in objects by @NoahDavey in #11
New Contributors
- @mordv made their first contribution in #9
- @NoahDavey made their first contribution in #11
Full Changelog: v0.2.2...v1.0.0
v0.2.2
- remove
console.log
v0.2.1
- allow using
withGetType
to override any type