Creating Typescript Starter Project with Jest and Typedoc

Scenario

For our prototyping work we want a Typescript starter project preconfigured with Jest, Typedoc, and NPM Workflow Scripts.

Cloning it like this creates the project <project_name>:

git clone git@github.com:fireflysemantics/typescript-starter.git <project_name>

This is the final repository in case you want to get right to it:

Approach

First create a new Node project:

mkdir typescript-starter
cd typescript-starter
npm init -y

This initializes package.json for us.

NPM Workflow Scripts

The below install-devdeps will install the latest development dependencies needed:

"install-devdeps": "npm i -D typescript typedoc ts-node ts-jest source-map-support @types/node jest @types/jest"

The types/node package from provides access to types for the node APIs like file , process and so on.

The script install-tools install the latest development workflow packages:

"install-tools": "npm i -g del-cli npm-install-peers npm-check-updates @jsdevtools/version-bump-prompt http-server"

The script update will update the dependency versions and install them and the newer versions of peer dependencies:

"update": "ncu -u && npm i && npm-install-peers"

The pub script bumps the patch version and publishes the project to NPM:

"pub": "npm t && bump patch && npm run update && npm run build && npm publish"

The test script runs Jest:

"test": "jest"

The build script runs the build:

"build": "del-cli dist && tsc"

The doc script runs Typedoc:

"doc": "del-cli doc && typedoc --entryPointStrategy expand ./src/ --out doc --exclude **/*.spec.ts"

And the sdoc script runs Typedoc and serves up the results:

"sdoc": "npm run doc && http-server -o doc"

Typescript files are written to the doc directory.

Jest Configuration

We will be using this Jest configuration (jest.config.js):

Typescript Configuration

Our Typescript configuration is as follows:

Commit to Github

Create the Github repository fireflysemantics/typescript-starter .

Then add, commit, and push the files.

git add .
git commit -m "First Commit"
git remote add origin git@github.com:fireflysemantics/typescript-starter.git
git push --set-upstream origin master

Test Project Creation

We can now tryout the README.md instructions for the project:

git clone git@github.com:fireflysemantics/typescript-starter.git <project_name>cd <project_name>npm run install-allnpm test

--

--

--

Founder of Firefly Semantics Corporation

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What is the difference between let, const, and var in Javascript?

Getting Started with ONDC

Building a Storage dApp on Tezos: (Part 3, FrontEnd in React JS)

Priority Queue

How to Find Very Large Prime Numbers in JavaScript

“Strategy Design Pattern” — Supports the ‘O’ of SOLID Principle

getDerivedStateFromProps

TypeScript: What & Why?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ole Ersoy

Ole Ersoy

Founder of Firefly Semantics Corporation

More from Medium

Angular Modules part 3 — Implementation of Lazy Loading

Jest: Test Driven Development

Complete Dive Into TypeScript: Part 1

Easy binary serialization in TypeScript