tsconfigcheck
v2.0.0
Published
Quickly check your tsconfig.json for missing properties.
Downloads
19
Maintainers
Readme
tsconfigcheck
Quickly check your tsconfig.json
for missing properties.
- Compares your
tsconfig.json
against ALL "properties" from the official tsconfig schema - Uncomment's all commented-out properties in your
tsconfig.json
prior to checking so that they don't show up as missing
Why?
tsc --init
only includes a subset of all truly possible tsconfig properties.- The tsconfig reference itself doesn't necessarily document each and every possible property.
- Opening a browser window every time just to check for new properties can be a hassle.
- ?
- OCD (probably)
Install
npm i -g tsconfigcheck
For one-off/impromptu invocations without worrying about local or global installation, skip the installation step above and use npx
(see usage).
You may also install the cli/binary locally inside of your package if you'd like. The following will add tsconfigcheck
to your developer dependencies (via the -D
flag) inside your package.json
and will place the physical binary inside of the local node_modules
directory.
# Note: cd into your package's root directory first
npm i -D tsconfigcheck
Then, to run the locally installed binary, use npx
(see usage).
If you don't have a
tsconfig.json
yet for your TypeScript project, you can generate one withtsc --init
. You can also make the contents oftsconfig.json
an empty object{}
in order to simply get back a list of all valid properties from the schema.
Usage
# Missing path defaults to tsconfig.json in the current directory
tsconfigcheck [tsconfigpath]
# To run a local installation, or, if you skipped the installation step
npx tsconfigcheck [tsconfigpath]
Note: this is quite a rough and small program atm, hence why it has been restricted to checking tsconfigs only. In my opinion, it should really only be used as an interactive cli tool to help ensure yourself that you've gone over absolutely all of the current, published tsconfig settings (as reported by the official schema) when scaffolding a new project, and should probably not be relied upon for anything too serious (including using it in CI and other such automated environments). I imagine it is best used manually/by hand and by humans rather than machines, although merely piping the output into sed/awk/grep probably wouldn't hurt either if you'd like to do that in order to filter the output).
Missing properties are output as JSON property paths (more formally known as JavaScript Object Notation (JSON) Pointers), one per line. For any listed missing properties that you would like to introduce to your tsconfig.json
, you will have to go back and add them to your tsconfig.json
by hand.
Caveats, Etcetera
The buildOptions
root property from the tsconfig schema does not appear to be documented in the public tsconfig reference, so it very well may not be a valid tsconfig.json
property. It might only be listed in order to document cli-only options/flags, or it may simply exist for internal use only. You may want to ignore this property and everything under it.
The ts-node
root property (including everything under it) is used for options to ts-node. It is typically only used/needed in projects that actually use ts-node.
This tool does not do any schema validation against tsconfig.json
as it is not meant for that. Use a different tool to validate your tsconfig.json
.
Missing properties output by this tool must be added to your tsconfig.json
(if you wish to do so) manually/by-hand, or via any other such external means. The feature of automatically adding missing properties along with their default values (and possibly descriptions etc.) may come at a later time sometime in the future, as may a cli flag for generating a tsconfig.json
complete with every single property.
Since, prior to comparing your tsconfig.json
against the tsconfig schema, this tool attempts to uncomment any properties that have been commented-out via //
in your tsconfig.json
, any non-JSON appearing inside such comments will cause issues. If you are having issues with parser errors, make sure that every single property has a trailing comma before running this tool. Any JSON properties commented out via /* */
multiline comment markers will be falsely reported as missing from the file.
JSON pointers containing escape sequences are not properly handled yet, but this probably isn't an issue since there aren't any tsconfig.json
properties that contain ~
or /
.
Finally, issues and pull-requests are both welcomed and encouraged!