generate types from schemas so you never have to type z.infer again
| .gitignore | ||
| index.ts | ||
| package-lock.json | ||
| package.json | ||
| readme.md | ||
zodoinfer
currently it expects Node >= 22.18 and a specific (sveltekit) file structure:
- src
- lib
- types
- index.ts
- something.schema.ts
- generated
- (generated types go here)
- types
- lib
all lines matching the naming pattern "XyzSchema" will generate equivalent type "Xyz"
but you could modify it pretty easily to do what you want
generate types on-save
vscode
- install "emeraldwalk.RunOnSave" extension
- add the following to vscode settings.json:
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.schema\\.ts$",
"isAsync": true,
"cmd": "node your/path/to/zodoinfer ${file}"
}
]
}