diff --git a/README.md b/README.md index cba88d93..a9f3e570 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ add `@babel/preset-flow` to the `presets`-section. ### TypeScript Support -If the `tsconfig.json`-file is present in the project root directory and the +If the `tsconfig.json`-file is present in the project root directory and `typescript` is a dependency the `@babel/preset-typescript` will automatically get loaded when you use the default babel config that comes with `kcd-scripts`. If you customised your `.babelrc`-file you might need to manually add @@ -134,6 +134,8 @@ If you customised your `.babelrc`-file you might need to manually add `kcd-scripts` will automatically load any `.ts` and `.tsx` files, including the default entry point, so you don't have to worry about any rollup configuration. +`tsc --noemit` will run during lint-staged to verify that files will compile. + ## Inspiration This is inspired by `react-scripts`. diff --git a/src/config/lintstagedrc.js b/src/config/lintstagedrc.js index b367b89d..f447b8cf 100644 --- a/src/config/lintstagedrc.js +++ b/src/config/lintstagedrc.js @@ -1,4 +1,4 @@ -const {resolveKcdScripts, resolveBin} = require('../utils') +const {resolveKcdScripts, resolveBin, ifTypescript} = require('../utils') const kcdScripts = resolveKcdScripts() const doctoc = resolveBin('doctoc') @@ -10,4 +10,5 @@ module.exports = { `${kcdScripts} lint`, `${kcdScripts} test --findRelatedTests`, ], + '*.+(ts|tsx)': ifTypescript ? [`tsc --noEmit`] : undefined, }