Skip to content

jmorag/incremental-tsc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

incremental-tsc

A small script to run tsc on a subset of project files, while respecting other settings from tsconfig.json and tsconfig.paths.json

Usage:

incremental-tsc src/components/*.tsx

As of v0.0.4, you can also pass a URL to the github API enpoint for a specific pull request and run the typechecker only on files changed in that PR. Use the flag --changed-lines-only to only report errors on lines touched by the PR. If the environment variables GITHUB_USER and GITHUB_PASSWORD are set, they will be used to authenticate the request.

incremental-tsc https://api.github.com/repos/<username>/<repo>/pulls/<prnum>/files --changed-lines-only

Running in CircleCI

Assuming you have suitable GITHUB_[USER|PASSWORD] environment variables set, the following bash script will run check only lines changed in the pr that CI is running in.

if [ -z "$CIRCLE_PULL_REQUEST" ]; then
    echo "Not in a Pull Request, skipping incremental-tsc check"
    exit 0
fi

BASE_URL=https://github.com/<owner>/<repo>/pull/
PR_NUM=${CIRCLE_PULL_REQUEST:${#BASE_URL}}
URL="https://api.github.com/repos/<owner>/<repo>/pulls/${PR_NUM}/files"
./node_modules/.bin/incremental-tsc --changed-lines-only "$URL"

Running locally

After staging a file or hunk but before committing, you can run

incremental-tsc --changed-lines-only [filename(s)]

to run the typechecker on changed lines. This can be integrated with lint-staged to run before every commit.

  {
    "*.{ts,tsx}": "incremental-tsc --changed-lines-only"
  }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published