Skip to content

samchon/ttsc

Repository files navigation

ttsc

banner of ttsc

GitHub license NPM Version NPM Downloads Build Status Guide Documents Discord Badge

A typescript-go toolchain for compiler-powered plugins and type-safe execution.

  • ttsc: build, check, and transform.
  • ttsx: execute TypeScript with type checking.
  • @ttsc/lint: lint violations as compiler errors.
  • @ttsc/graph: MCP code graph that reduces agent token usage.
  • plugin support: compiler-powered libraries, such as typia.

Setup

ttsc is a drop-in replacement for tsc. It reads the same tsconfig.json, takes the same flags, and emits the same JavaScript, then runs your plugins in the pass that type-checks the project.

npm install -D ttsc typescript
npx ttsx src/index.ts   # run a file, type-checked first
npx ttsc                # build
npx ttsc --noEmit       # check only
npx ttsc --watch        # rebuild on save

ttsx runs a file the way tsx or ts-node does, but it type-checks the whole project first, so a type error stops the run before anything executes.

That covers the CLI. The integrations each have a short guide:

Lint

Lint and format at compiler speed: up to 800x faster than ESLint.

@ttsc/lint replaces ESLint and Prettier with rules that run inside the type-check. It shares one AST pass with the compiler, so linting and formatting add almost nothing to the build you already run.

Configuration is a single file. Each rule takes "error", "warning", or "off", and the format block mirrors .prettierrc.

npm install -D @ttsc/lint
// lint.config.ts
import type { ITtscLintConfig } from "@ttsc/lint";

export default {
  rules: {
    "no-var": "error",
    "prefer-const": "error",
    "typescript/no-explicit-any": "warning",
  },
  format: {
    printWidth: 100,
    singleQuote: true,
    trailingComma: "all",
  },
} satisfies ITtscLintConfig;

Violations surface as compiler diagnostics, in the same stream as type errors, so the CI step that already runs ttsc --noEmit gates lint without a second job:

// src/index.ts
var count = 3;
let total = count;
$ npx ttsc --noEmit
src/index.ts:2:5 - error TS17397: [prefer-const] Use const instead of let.

2 let total = count;
      ~~~~~~~~~~~~~

src/index.ts:1:1 - error TS11966: [no-var] Unexpected var, use let or const instead.

1 var count = 3;
  ~~~~~~~~~~~~~~

Clean the project in place:

npx ttsc fix      # lint autofixes + format edits
npx ttsc format   # format edits only, never changes behavior

The rule catalog and every format key are in the Lint & Format guide.

Graph

Your coding agent answers from the compiler, spending roughly 90% fewer tokens.

@ttsc/graph is an MCP server that gives the agent a compiler-resolved graph of your project: what calls what, what a change would touch, and where to start reading. The agent asks the type checker instead of grepping and re-reading files.

Register it with your MCP client. For Claude Code, a .mcp.json in the project root:

npm install -D ttsc @ttsc/graph typescript
{
  "mcpServers": {
    "ttsc-graph": {
      "command": "npx",
      "args": ["-y", "@ttsc/graph"]
    }
  }
}

On the agent-cost benchmark, Claude agents answer reading zero files, cutting tokens by roughly 90% and tool calls by 93% to 96%. The design and per-repository numbers are in the Code Graph guide and the benchmark.

Median tokens on the shared onboarding question, lower is better

Plugins

A plugin hooks the compile to add checks, transforms, or type-driven code generation, all driven by the types the checker has already resolved. It runs on every ttsc build and ttsx run, with no extra step.

typia is the canonical one. Ask it for a validator of any type, and the transform writes the implementation at build time:

import typia from "typia";

export const isStringArray = typia.createIs<string[]>();

No schema, no decorator. The call compiles to a plain function:

export const isStringArray = (() => {
  return (input) =>
    Array.isArray(input) && input.every((elem) => "string" === typeof elem);
})();

Utility plugins shipped in this repository:

  • @ttsc/banner: adds @packageDocumentation JSDoc banners.
  • @ttsc/lint: lints and formats TypeScript source.
  • @ttsc/graph: MCP server exposing a checker-resolved code graph to coding agents.
  • @ttsc/paths: rewrites source path aliases so JS and declaration emit receive relative imports.
  • @ttsc/strip: removes configured calls and debugger statements.
  • @ttsc/unplugin: runs ttsc plugins inside bundlers supported by unplugin.
  • @ttsc/metro: runs ttsc plugins inside Metro for React Native and Expo.

Ecosystem plugins; PRs adding yours are welcome:

  • nestia: generates NestJS routes, OpenAPI, and SDKs.
  • typia: generates validators, serializers, and type-driven runtime code.

To write your own, start from Plugin Development.

Sponsors

Sponsors

Thanks for your support.

Your donation encourages ttsc development.

References

About

A `typescript-go` toolchain for compiler-powered plugins + type-safe execution + 800x faster linter + codegraph reducing 90% AI tokens

Topics

Resources

License

Stars

275 stars

Watchers

2 watching

Forks

Sponsor this project

 

Packages

 
 
 

Contributors