At Realm we love TypeScript! We've seen great success in working across multiple remote teams with it and want to share our base template when creating projects.
- Has TypeScript
- Has TypeScript Lint (aka. tslint)
- Has Visual Studio Code Debugging!
- Has Testing with Mocha + Chai
- Has Gitignore
This is a great starting point for using Node.JS, TypeScript, and Visual Studio Code. All artifacts get created in the dist
folder. All the sourcecode is in src
Just clone this repo and point to your new origin!
- Run
git clone https://github.com/realm/node-template-project.git --depth 1
- Run
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
- Cd into the directory and run
npm install
(or if you haveyarn
)
After npm install
- To Build
npm run build
- To Clean Artifacts
npm run clean
- To Test
npm run test
- To Lint
npm run lint
- To Buld and Watch when you make changes
npm run watch
- Set a breakpoint in your code ending in
.ts
or your test ending in.spec.ts
- Run Either
src/index.ts
orAll Tests
in the debug pane.
Never use arrow functions on the Mocha
test handlers. Why? The callback has its own set of methods. The arrow function does not have an easy way to reference this
Say you want to increase the timeout of the function callback in your tests
it('should do something', () => {
this.timeout(2000) // this is not the callback function!
})