tsc-files icon indicating copy to clipboard operation
tsc-files copied to clipboard

fails when run as package.json script

Open reharik opened this issue 1 year ago • 1 comments

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.

reharik avatar Feb 08 '23 17:02 reharik

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.

gustavopch avatar Feb 08 '23 18:02 gustavopch