Skip to content

Releases: sachinraja/zod-to-ts

v1.2.0

16 Aug 16:03
0a57f0e
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.1.4...v1.2.0

v1.1.4

07 Apr 16:43
a9e1992
Compare
Choose a tag to compare
  • support typescript v5

v1.1.3

07 Apr 16:37
60e5d84
Compare
Choose a tag to compare
  • fix getType being erased on .describe() #30

v1.1.2

30 Dec 16:20
8fe9eaa
Compare
Choose a tag to compare

What's Changed

v1.1.1

12 Jun 05:51
8e053a3
Compare
Choose a tag to compare

What's Changed

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

03 Jun 15:24
a3cee7a
Compare
Choose a tag to compare

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

29 Apr 02:23
4d1149e
Compare
Choose a tag to compare

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

26 Apr 23:53
09afc8a
Compare
Choose a tag to compare

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

New Contributors

Full Changelog: v0.2.2...v1.0.0

v0.2.2

28 Feb 03:11
4f70207
Compare
Choose a tag to compare
  • remove console.log

v0.2.1

28 Feb 02:46
7cd5895
Compare
Choose a tag to compare