RedditPP Mascot

RedditPP

r/typescript • … • u/HugeLetters

The fastest way to check the file for errors

I've got a bunch of files which may or may not contain type errors and I would like to quickly go over all of them and output a list of files which DO have errors.

The way I do this at the moment is like this but it's kinda slow - I grab an array of filenames with glob package and then iterate over them. ``` import { exec } from "node:child_process"

function checkChallenge(file: string) { return new Promise<boolean>(resolve => { exec( `tsc ${file} --noEmit --strict --skipLibCheck --incremental --tsBuildInfoFile "./.tsbuildcache"`, e => resolve(!e || !e.code) ) }) } ```

Is there any faster way? I've heard about stc but it's in very early stages as I've heard so I'm not sure if it's a good fit - especially since some of these files use newer TS5.0 features. I use VSCode and opening a file usually reveal errors rather quickly(definitely faster than running tsc) so maybe there's a way to leverage its features?

— 0