npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tsc-files-workspace

v2.0.1

Published

A tiny tool to run tsc on specific files without ignoring tsconfig.json, with PNPM workspace support

Readme

tsc-files-workspace

A tiny tool to run tsc on specific files without ignoring tsconfig.json, with workspace support.

Why tsc-files-workspace?

Born out of real-world frustrations with pre-commit hooks in monorepo environments:

  1. nano-staged + eslint --fix: Too many conflicts when multiple files are being fixed simultaneously
  2. pnpm run test: Way too slow for just a simple commit - nobody wants to wait minutes for basic validation
  3. tsc --noEmit: Fast and reliable, but doesn't show which specific files have errors - debugging becomes a nightmare!
  4. tsc-files-workspace: Perfect solution for showing filenames with errors, but doesn't work in workspace/monorepo setups

This enhanced version detects workspace configurations automatically and ensures each file gets checked with its correct tsconfig.json. Now you get fast type checking with clear error reporting and proper workspace support - perfect for pre-commit hooks!

Features

  • ✅ Run TypeScript compiler on specific files
  • ✅ Respect tsconfig.json configuration
  • NEW: Automatic workspace detection
  • NEW: Group files by their closest tsconfig.json
  • NEW: Process each workspace package separately
  • ✅ Support for monorepo projects
  • ✅ Backward compatible with original tsc-files

Installation

npm install tsc-files-workspace
# or
pnpm add tsc-files-workspace
# or
yarn add tsc-files-workspace

Usage

Basic Usage (same as original tsc-files-workspace)

tsc-files-workspace src/file1.ts src/file2.ts

Workspace Support (NEW)

When used in a monorepo with workspaces, the tool automatically:

  1. Detects if you're in a workspace (looks for package.json with workspaces field)
  2. Groups files by their closest tsconfig.json
  3. Runs TypeScript compiler separately for each group
# In a monorepo, this will automatically group files by workspace packages
tsc-files-workspace packages/server/src/app.ts packages/client/src/main.ts packages/shared/src/utils.ts

Manual Project Specification

You can still specify a specific tsconfig.json to disable workspace detection:

tsc-files-workspace --project packages/server/tsconfig.json src/file1.ts src/file2.ts

How It Works

Workspace Detection

  1. Starts from current directory and walks up the directory tree
  2. Looks for package.json files with a workspaces field
  3. If found, enables workspace mode

File Grouping

For each TypeScript file:

  1. Finds the closest tsconfig.json by walking up from the file's directory
  2. Groups files that share the same tsconfig.json
  3. Creates temporary config files for each group
  4. Runs tsc separately for each group

Example Workspace Structure

my-monorepo/
├── package.json (with workspaces)
├── tsconfig.json
├── packages/
│   ├── server/
│   │   ├── tsconfig.json
│   │   └── src/
│   │       └── app.ts
│   ├── client/
│   │   ├── tsconfig.json
│   │   └── src/
│   │       └── main.ts
│   └── shared/
│       ├── tsconfig.json
│       └── src/
│           └── utils.ts

Running:

tsc-files-workspace packages/server/src/app.ts packages/client/src/main.ts packages/shared/src/utils.ts

Will:

  1. Group packages/server/src/app.ts with packages/server/tsconfig.json
  2. Group packages/client/src/main.ts with packages/client/tsconfig.json
  3. Group packages/shared/src/utils.ts with packages/shared/tsconfig.json
  4. Run TypeScript compiler 3 times, once for each group

Benefits

  • Accurate type checking: Each file is checked with its appropriate tsconfig.json
  • Faster CI/CD: Only check changed files while respecting workspace boundaries
  • Better error reporting: Errors are reported in the context of the correct workspace package
  • Monorepo friendly: Works seamlessly with Lerna, Rush, pnpm workspaces, npm workspaces, etc.

Husky Integration

This tool works great with Husky for pre-commit hooks. Here's how to set it up:

Installation with Husky

# Install husky and tsc-files-workspace
pnpm install --save-dev husky tsc-files-workspace

# Initialize husky
pnpx husky init

Pre-commit Hook Example

Create .husky/pre-commit:

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# Get staged TypeScript files
STAGED_TS_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(ts|tsx)$')

if [ -n "$STAGED_TS_FILES" ]; then
  echo "Type checking staged TypeScript files..."
  npx tsc-files-workspace $STAGED_TS_FILES --noEmit

  if [ $? -ne 0 ]; then
    echo "TypeScript type check failed. Please fix the errors before committing."
    exit 1
  fi
fi

Advanced Husky Setup with Lint-staged

For more advanced setups, combine with lint-staged:

npm install --save-dev lint-staged

Add to package.json:

{
  "lint-staged": {
    "*.{ts,tsx}": [
      "tsc-files-workspace --noEmit",
      "eslint --fix",
      "prettier --write"
    ]
  }
}

Update .husky/pre-commit:

pnpx lint-staged

Benefits of Using with Husky

  • Fast type checking: Only checks changed files
  • Workspace aware: Automatically uses correct tsconfig for each file
  • Early error detection: Catches type errors before they reach CI/CD
  • Consistent code quality: Ensures all commits pass type checking

Compatibility

  • Fully backward compatible with original tsc-files-workspace
  • Works with any TypeScript version >= 3.0
  • Supports all tsc command line options
  • Works with any workspace manager (pnpm, npm, yarn, lerna, etc.)
  • Integrates seamlessly with Husky, lint-staged, and other Git hooks

License

MIT