gustavopch / tsc-files

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

Commit on .js/.jsx files fails (.ts/.tsx is successful) #34

Closed mkosir closed 2 years ago

mkosir commented 2 years ago

Thanks for an awesome tool 🚀

I'm having an issue, if I try to commit .js/.jsx type of file, error is thrown: error TS5042: Option 'project' cannot be mixed with source files on a command line.

It works as expected for all other type of files. In tsconfig allowJs is set to true.

gustavopch commented 2 years ago

Thanks! Please show the command you're using. Also, check this: https://github.com/okonet/lint-staged/issues/468#issuecomment-605102567

mkosir commented 2 years ago

I'm running this command on staged files "tsc-files --noEmit -p tsconfig.dev.json src/types/images.d.ts".

Error happens in this repo, since .jsx files are used. In order to reproduce it, try to commit .tsx file (works as expected) and then try to commit one of the .jsx files, in which case error is thrown.

Edit: I guess the reason is related to this 🤔

AndrewWUw commented 2 years ago

With lint-staged, you could filter and run different commands based on file extension. So you could add a section into your package.json similar to below:

{
  "lint-staged": {
    "**/*.ts": "tsc-files --noEmit",
    "**/*.tsx": "tsc-files --noEmit",
    "**/*.js": <command to run>,
    "**/*.jsx": <command to run>,
  }
}
mkosir commented 2 years ago

@AndrewWUw thx 🙇‍♂️ , this approach makes much sense 👍