Skip to content

My batteries included TypeScript starter for 2025

Published: | 4 min read

Table of contents

Open Table of contents

Intro

Internet is full of project templates, and you can generate unlimited amount more with AI tools. Yet, I like to start my projects from a known baseline, which I understand. All the moving parts are chosen and configured by me, so I can edit the setup without fearing that everything will collapse like a house of cards.

In my experience, a solid baseline will also help AI tools such as GitHub Copilot to offer more relevant completions.

I changed quite a lot in this iteration of the template, for example Jest was ousted by Vitest, and production-ready Docker image can be built. Additionally few other dependencies were removed to simplify the setup, all thanks to development on few utilized projects. Let’s dig in.

What’s inside

This is My Batteries included TypeScript starter for 2025, with:

What’s not inside

✅ Prerequisites

📌 Getting started

How to use this template?

  1. Make sure prerequisites are met.
  2. Download the repository as zip so you don’t have to deal with git history of this repository.
  3. Delete package-lock.json.
  4. Replace janik6n in package.json with your own username, along with other info.
  5. Install dependencies by running npm install on the project root directory.
  6. Start developing. See below for available scripts.

Available scripts

⚙️ Run development server

To run TypeScript to JavaScript transpiling and to run transpiled ./dist/index.mjs run npm run dev. Watch mode (a.k.a. hot reloading) is available with npm run dev:watch. Development serving is handled with tsx.

🚥 Run tests

Test are run with Vitest, and different test scenarios are handled with Vitest workspaces.

To run tests, you have a several of options:

⚗️ Format source code

Format the source code with Prettier by running npm run format.

⚗️ Lint source code

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

The 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.

Build command explained: "build": "rimraf ./dist && npx tsc --noEmit && node build.js":

Sometimes it’s necessary to see the built app with just transpiling without bundling. This can be accomplished with npm run build:tsc.

⚙️ Run production bundle

Run the built app with npm run start.

🐳 Build as container

Run npm run build:container to build the app as Docker container. Multi-stage build is used to minimize the production image size. Debian-based image is used to minimize the risk of compatibility issues.

🐳 Run as container

Run the containerized app with npm run start:container.

You can find the template on GitHub janik6n/typescript-starter: Batteries included TypeScript starter for 2025.