Configure your project to generate and commit typescript types #630
DanRibbens
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Payload includes a way to generate typescript types and you can take it one step further by adding a
pre-commit
hook to your git workflow to call the generate command and also add those changes to the commit!This is useful if you find yourself working on a typescript project and forgetting to generate types before commiting code changes.
Step 1
yarn add --dev pre-commit
Step 2
Update your package.json to run your script that calls your payload generate:types script:
"pre-commit": ["generate:types"]
Step 3
edit
.git/hooks/pre-commit
to addgit update-index --add payload-types.ts
as below:*Note: If you've customized your typescript output replace "payload-types.ts" with your destination instead or it will not be committed.
Beta Was this translation helpful? Give feedback.
All reactions