I want to check typescript type before commit, So i use tsc --noEmit $(changedFile). However, This command can not specify config file.
I found --project option, But this option will check entire project and i just want to check changedFile, Because some old files has type error but do not need to handle.
So how can i only check changedFile type before commit ?
You can use an awesome tool called lint-staged.
This library lint your files before each commit. https://github.com/okonet/lint-staged
Installation
npx mrm lint-staged
Usage for TypeScript
// lint-staged.config.js
module.exports = {
'**/*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With