gustavopch / tsc-files

A tiny tool to run `tsc` on specific files without ignoring tsconfig.json
MIT License
234 stars 49 forks source link

Add Support for tsconfig.json include array #35

Closed lauchness closed 2 years ago

lauchness commented 2 years ago

Hello, thanks for maintaining this project!

I am trying to run tsc-files as part of a pre-commit hook.

In my tsconfig.json I have specified some values in the include property for custom module declarations, which are then overwritten in the tsc-files code: https://github.com/gustavopch/tsc-files/blob/master/lib/index.js#L39

We obviously don't want to bring in the entire include array, as that would defeat the purpose of only bringing the lint-staged files.

I need a means of including my specific declarations files.

lauchness commented 2 years ago

I think I found a solution.

I can include my specific *.d.ts files in my tsc-files call, which then appends those files the files property in the temporary tsconfig.json.

e.g. in package.json

"scripts": {
   // ...other scripts
    "type-check": "tsc-files --noEmit --pretty $(git diff --staged --name-only) *.d.ts",
  },

or in .lintstagedrc.js

module.exports = {
  "**/*.(ts|tsx)": [
    "tsc-files --noEmit --pretty scss.d.ts",
  ],
};