tsc
doesn't provide a direct way to process specified files with the project settings (if you pass files to tsc
, it ignores the config file), but it does allow you to extend a config file and override its list of included files, e.g.:
$ cat ./tsconfig-temp.json
{
"extends": "./tsconfig.json",
"include": ["./temp.ts"]
}
A wrapper script can be used to generate a config file like this on the fly with the specified file(s), e.g. (using jo
to create the JSON):
$ cat tsc-files.sh
#!/usr/bin/bash
TEMP='./tsconfig-temp.json'
trap 'rm "$TEMP"' EXIT
jo extends=./tsconfig.json include=$(jo -a "$@") > $TEMP \
&& tsc --noEmit --project "$TEMP"
usage
$ tsc-files.sh ./temp.ts
Alternatively, you can use the tsc-files package on npm, which does this for you:
usage
$ tsc-files --noEmit ./temp.ts