gustavopch / tsc-files

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

fails when run as package.json script #53

Open reharik opened 1 year ago

reharik commented 1 year ago

Hi, I'm not using eslint-staged or whatever. I have a script entry in package.json "tsc-files": "git getMyFiles | tsc-files --noEmit"
That's not working so great yet, so I hardcoded a file in there e.g "tsc-files": "tsc-files --noEmit myFile/hasAnError.ts" when this is run the spawnSync just exits right away. No error, no visible attempt to tsc.
I dug in and basically took the result of the tsconfig that you generate and ran tsc against it and it worked. e.g. the tsconfig had the line files: ['myFile/hasAnError.ts'] and indeed it found that file and found the error.
So it seems that tsc-files spawnSync is returning directly and not actually running tsc or returning directly and perhaps running tsc but it doesn't matter because it has returned.

Any help would be appreciated.

gustavopch commented 1 year ago

Maybe some problem with the path resolution here? https://github.com/gustavopch/tsc-files/blob/27a82464f2c0ff26ccb5b5b152b589aa580bd5a6/lib/index.js#L45-L48

Check if the resolved path exists in your file system and actually points to the tsc binary. I believe it doesn't work with pNPM for example.