clang-format is available via npm
Thanks to the effort of my colleague Alex Eagle (mostly),
clang-format is now available via npm. You can install it via
npm install -g clang-format, and then just use the
clang-format command normally. Binaries are available for Mac OS X and Linux, both 64 bit.
clang-format now does a pretty decent job at formatting TypeScript, too, including support for classes, interfaces, generics, and of course type annotations. While TypeScript comes with a simple indenter, that doesn’t really support full formatting - e.g. it won’t wrap overlong lines, doesn’t align function parameters, etc. This is of course highly subjective, but I think clang-format does a better job, and it’s nice to be able to use the same formatter across more or less all your languages (C++, Java, JS, TypeScript).