Comparing version 1.0.0 to 1.0.1
@@ -44,2 +44,9 @@ var __defProp = Object.defineProperty; | ||
}; | ||
var identifierRE = /^[A-Za-z_$][A-Za-z0-9_$]*$/; | ||
var getIdentifierOrStringLiteral = (str) => { | ||
if (identifierRE.test(str)) { | ||
return f.createIdentifier(str); | ||
} | ||
return f.createStringLiteral(str); | ||
}; | ||
@@ -90,3 +97,3 @@ // src/index.ts | ||
const isOptional = nextZodNodeTypeName === "ZodOptional" || nextZodNode.isOptional(); | ||
return f2.createPropertySignature(void 0, f2.createIdentifier(key), isOptional ? f2.createToken(ts2.SyntaxKind.QuestionToken) : void 0, type); | ||
return f2.createPropertySignature(void 0, getIdentifierOrStringLiteral(key), isOptional ? f2.createToken(ts2.SyntaxKind.QuestionToken) : void 0, type); | ||
}); | ||
@@ -118,3 +125,4 @@ return f2.createTypeLiteralNode(members); | ||
const enumMembers = Object.entries(zod._def.values).map(([key, value]) => { | ||
return f2.createEnumMember(f2.createIdentifier(key), f2.createStringLiteral(value)); | ||
const literal = typeof value === "number" ? f2.createNumericLiteral(value) : f2.createStringLiteral(value); | ||
return f2.createEnumMember(getIdentifierOrStringLiteral(key), literal); | ||
}); | ||
@@ -121,0 +129,0 @@ if (ts2.isIdentifier(type)) { |
{ | ||
"name": "zod-to-ts", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"type": "module", | ||
@@ -36,18 +36,18 @@ "description": "generate TypeScript types from your Zod schema", | ||
"devDependencies": { | ||
"@types/node": "17.0.21", | ||
"@typescript-eslint/eslint-plugin": "5.12.1", | ||
"@typescript-eslint/parser": "5.12.1", | ||
"dprint": "0.23.0", | ||
"esbuild-node-loader": "0.6.5", | ||
"eslint": "8.10.0", | ||
"eslint-config-prettier": "8.4.0", | ||
"@types/node": "17.0.30", | ||
"@typescript-eslint/eslint-plugin": "5.21.0", | ||
"@typescript-eslint/parser": "5.21.0", | ||
"dprint": "0.27.0", | ||
"esbuild-node-loader": "0.8.0", | ||
"eslint": "8.14.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"husky": "7.0.4", | ||
"lint-staged": "12.3.4", | ||
"lint-staged": "12.4.1", | ||
"npm-run-all": "4.1.5", | ||
"rimraf": "3.0.2", | ||
"tsup": "5.11.13", | ||
"typescript": "4.5.5", | ||
"vite": "2.8.4", | ||
"vitest": "0.5.8", | ||
"zod": "3.12.0" | ||
"tsup": "5.12.6", | ||
"typescript": "4.6.4", | ||
"vite": "2.9.6", | ||
"vitest": "0.10.0", | ||
"zod": "3.14.4" | ||
}, | ||
@@ -54,0 +54,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39840
554