Skip to content

jasonkuhrt/template-typescript-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

template-typescript-lib

trunk

Project template for Node libraries. Features:

  • ESM Module
  • Types: TypeScript
  • Tests: Vitest
  • Linting: oxlint
  • Formatting: dprint
  • Publishing: Dripip
  • Continuous Integration: GitHub Actions
  • Dependency Management: Renovate
  • Community: Issue Templates

Quick Start

Make sure you have corepack enabled:

$ corepack enable

Used as a GitHub Template Repo

The following will get you a ready to go new repository on GitHub based on this one.

  1. Run:

    gh repo create foobar --template jasonkuhrt/template-typescript-lib --clone --public && \
    cd foobar && \
    pnpm install && \
    pnpm bootstrap
    
  2. Setup a repo secret called NPM_TOKEN containing an npm token for CI package publishing.

Used With Manual Git Setup

The following will get you a ready to go new repository on GitHub based on this one.

  1. Run:

    gh repo clone jasonkuhrt/template-typescript-lib <directory> && \
    cd <directory> && \
    pnpm install && \
    pnpm bootstrap
    
  2. Setup a repo secret called NPM_TOKEN containing an npm token for CI package publishing.

Details

TypeScript for Type Safety & Productivity

  1. Optimal settings for type safety via @tsconfig/node22 and @tsconfig/strictest

  2. .tsbuildinfo cache setup, output discretely into node_modules/.cache

  3. Base tsconfig.json shared across tests and src.

  4. Optimal output setup for your users

    1. declaration so your users can power their intellisense with your packages typings.
    2. declarationMap enabled to make your published source code be navigated to when your users use "go to definition".
    3. sourceMap enabled to allow your users' tools to base off the source for e.g. stack traces instead of the less informative derived built JS.
    4. Publish src with build files so that jump-to-definition tools work optimally for users.
  5. tsx for running TypeScript scripts/modules.

oxlint For Linting

  1. Rust-based, extremely fast (~100x faster than ESLint)
  2. Zero config needed
  3. Setup as a CI check for PRs

Vitest for Testing

Just Works :)

Dripip for Releasing

Simple succinct friendly low-barrier issue templates

  1. Emojis โœˆ๏ธ
  2. Feature / bug / docs / something-else
  3. Config to display discussions link right in new issue type listing UI

dprint for code formatting

  1. Setup as a CI check for PRs
  2. npm script

npm scripts for development lifecycle

  1. clean to remove cache and build files
  2. build that runs clean beforehand
  3. prepublishOnly that runs build beforehand
  4. format to run dprint over whole codebase
  5. lint to run oxlint over whole codebase

CI with GitHub Actions

  1. Separate trunk and pull-request (PR) workflows.
  2. Dependency install cache enabled.
  3. On PR:
    1. Formatting Check
    2. Lint Check
    3. Type Check
    4. Tests across matrix of mac/linux/windows for Node 22
  4. On trunk:
    1. Tests across matrix of mac/linux/windows for Node 22
    2. Automated canary release

Renovate configuration

  1. JSON Schema setup for optimal intellisense
  2. Group all non-major devDependency updates into single PR (which "chore" conventional commit type)
  3. Group all major devDependency updates into single PR (with "chore" conventional commit type)
  4. Group all non-major dependency updates into single PR (with "deps" conventional commit type)
  5. Each major dependency update in own PR (with "deps" conventional commit type)

PnPM for package management

  1. Using Corepack. This means the PnPM specified in package.json will be used. And note this is a PnPM binary shipped with Node now. In a future version of Node you will not need to even opt-in into Corepack. Make sure you've done corepack enable at least once.

Zed Settings

This template does not include a .zed directory. Instead, it assumes you configure tsgo (the native Go-based TypeScript language server) in your global Zed settings (~/.config/zed/settings.json):

{
  "languages": {
    "TypeScript": {
      "language_servers": ["tsgo", "!vtsls", "oxc"]
    },
    "TSX": {
      "language_servers": ["tsgo", "!vtsls", "oxc"]
    }
  }
}

Readme Table of Contents

  1. Using markdown-toc

Useful TypeScript Libraries

Here are some TypeScript libraries you might want to use for your new project:

https://github.com/stars/jasonkuhrt/lists/typescript

Alt

About

๐ŸŽ›๏ธ Project template for TypeScript libraries

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •