About a year ago I wrote about when to use TypeScript. Today I'm releasing a boilerplate for Node applications. The main use case is a library that is going to be published as a NPM module with documentation on github.
This is a typescript boilerplate project that supports:
- visual studio code + node debugging in IDE
- tslint
- mocha / chai tests
- jsdoc and HTML document generation
- Clean JS output that's ready to use in Node projects (using
tslib
) - TS type definition files that's ready to use in TS projects
- Pre-commit task to keep the documents up to date
git clone git@github.com:userpixel/typescript.git
Or just Download it.
Then modify the files as you wish.
- Get VSCode.
- Make sure you have Node (and NPM)
- Install TSLint
- Open the code dir and make sure to install the dependencies (
yarn
on command line or F1 > "Run Task" > "install" in VSCode).
Every time you wanna run it just press Ctrl+Shift+B to build. To run tests, press F1 > "Run Task" > "test".
src/
Write your TypeScript files here. It can have sub directories if you want. Each file has its own test next to it namedFILENAME.spec.ts
orFILENAME.test.ts
..vscode
Your Visual Studio Code configurations. You can tweak them if you want but the main part is thetasks.json
which defines thecompile
build task as well astest
anddocument
.
The following directories are auto generated and shouldn't be changed manually:
build/
the Javascript version of the TypeScript files. They contain documentation and are cleanly compiled so they are readable.docs
HTML version if your JSDoc annotations from the codetest
Javascript test files (all files namedFILENAME.spec.ts
andFILENAME.tests.ts
end up here after compilation)tsdecl
TypeScript declaration files that can be used when you release this module as a library and your user wants to use it their in TypeScript projects.
It's MIT so you can use the code for proprietary projects or extend it without contributing back.
Remember the use case of this project. It's not going to be used for React and front end code. Just node and ideally a published lib to npm (and github).
- Discuss issues and ideas at https://github.com/userpixel/typescript/issues
- Make PRs