Woah, I just learned that tsconfig.json allows comments


Woah, I just learned that tsconfig.json allows comments!

json doesn't normally allow comments, but comments are valid in tsconfig.json. It's officially supported by TypeScript! 😍 (VSCode understands it too 👍)

This is a nice way to document why we've chosen a given setting.

Oh, and related TypeScript tip: I learned this by generating a tsconfig.json via the command line like this

npx tsc --init

That command generates the tsconfig I showed in the previous tweet, with all the settings commented.
Oh, and what's going on here is a standard called JSON5.

JSON5 is a superset of JSON that allows comments, single quotes, trailing commas, whitespace characters and more.

This picture contains valid JSON5.

Details: https://json5.org/

View original on X