@ficazam31/autotyper
v0.1.2
Published
<!-- Badges -->    
npm i -g @ficazam31/autotyperbun (global)
bun add -g @ficazam31/autotyperIf the binary is not picked up on your system:
bunx @ficazam31/autotyper --helpQuick start
Generate a TypeScript type:
autotyper "User email:s password:s name:s isAdmin?:b createdAt:d tags:s[]"Generate everything at once (type + interface + zod + example):
autotyper --mode all "User email:s password:s isAdmin?:b createdAt:d tags:s[]"Pipe input from stdin:
echo "User email:s createdAt:d" | autotyper --mode allDSL format (recommended)
The first token is the type name.
All following tokens are properties.
User email:s password:s name:s isAdmin?:b createdAt:d tags:s[]Property syntax
prop:type→ explicit typeprop→ type is inferredprop?→ optionalprop!→ required
Type shorthands
| Shorthand | Type |
|---------|------|
| s | string |
| n | number |
| b | boolean |
| d | Date |
| u | unknown |
| a | any |
Arrays are written as:
tags:s[]
scores:n[]
dates:d[]Passthrough types also work:
User id:UUID metadata:Record<string, string>Type inference rules
If you don’t provide a type, autotyper infers one:
createdAt,updatedOn, anything ending inAt/Onor containingdate→DateisAdmin,hasPets,canEdit,shouldRetry→booleanid,user_id,orderId→string- plural names like
tags,items,users→string[] - otherwise →
string
Example:
autotyper "User id email password isAdmin? createdAt tags"Output modes
autotyper --mode type "User email:s"
autotyper --mode interface "User email:s"
autotyper --mode zod "User email:s createdAt:d"
autotyper --mode all "User email:s createdAt:d"
autotyper --mode json "User email:s createdAt:d"Zod strict mode
autotyper --mode zod --strict "User email:s createdAt:d"Backwards compatibility (old format supported)
autotyper "type:user-email:s/password:s/name:s/isAdmin:b:o"Examples
Auth DTO
autotyper --mode all "LoginRequest email:s password:s"User model
autotyper --mode all "User id email name isAdmin?:b createdAt:d tags:s[]"Name sanitization
autotyper --mode type "user-profile first-name:s default:s 2faEnabled?:b"License
MIT
