Skip to content

janik6n/typescript-starter

Repository files navigation

TypeScript Starter 🔋

This is my batteries included generic TypeScript starter, with:

  • 🟩 Node.js 20
  • ✏️ TypeScript 5.3
  • 📚 ECMAScript Modules
  • ⚙️ NPM package manager
  • 🚥 testing with Jest
  • 📦 bundling with esbuild
  • ⚗️ Code linting & formatting with ESLint + Prettier
  • 🔬 VS Code configuration for debugging
  • 🔥 hot reloading
  • 🔁 GitHub Actions workflow to run code quality checks and tests

✅ Prerequisites

  • Make sure you have Node.js installed. This is built, configured and tested with Node.js 20.
  • Install VS Code, and the following extensions:

📌 Getting started

How to use this template?

  1. Make sure prerequisites are met.
  2. Clone this repository.
  3. Delete package-lock.json.
  4. Replace janik6n in package.json with your own username.
  5. Install dependencies by running npm install on the project root directory.
  6. Start developing. See below for available scripts.

⚙️ Run development server

To run TypeScript to JavaScript transpiling and to run transpiled dist/index.js in watch mode (a.k.a. hot reloading), run npm run dev.

🚥 Run tests

To run tests, you have a couple of options:

  • run npm run test
  • to include coverage report, run npm run test:cov
  • to run tests in watch mode, run npm run test:watch in separate terminal session than your development server.

⚗️ Lint source code

Lint a.k.a. check the formatting of the source code with npm run lint.

Basic idea is to run ESLint & Prettier on VS Code as you code, so this script is mostly for code quality checks in CI. Prettier is run as ESLint plugin.

📦 Build production bundle

Build the production bundle with esbuild by running npm run build. Build is configured in build.js.

Future plans: build as Docker container with npm run build:container.

⚙️ Serve production bundle

Serve the built app with npm run start.

🐛 Known issues

  • Jest module mocking does not work. Haven't been able to figure out yet what's the issue with this. Most likely related to kulshekhar/ts-jest#4207.

📚 Further reading

Jest

VSCode TS debugging

VSCode debugging & Jest

🔁 Changelog

CHANGELOG

⚖️ License

MIT License. Copyright janik6n.