Skip to content

kidonng/typescript

Repository files navigation

TypeScript

A tiny redistribution of TypeScript

  • Main modules are minified (tsc.js in @kidonng/tsc & typescript.js in @kidonng/typescript)
  • Other modules are removed (including tsserver)
  • Localization data and diagnostics messages are removed

@kidonng/tsc install size

npm install @kidonng/tsc

Contains only the tsc executable. Choose this if:

  • Your build process only requires tsc
  • Your build tools don't import {stuff} from 'typescript' (e.g. esbuild)
  • You only use tsc for type checking (e.g. tsc --noEmit)

@kidonng/typescript install size

Override in npm/yarn 1
npm install typescript@npm:@kidonng/typescript
Override in pnpm

Add to package.json:

{
  "pnpm": {
    "overrides": {
      "typescript": "npm:@kidonng/typescript@^4.8.3"
    }
  }
}

Contains only the typescript.js module. Choose this if:

Note: this package does NOT include the tsc executable. Install @kidonng/tsc as well if you need it.

Motivation

Also read my post on r/javascript

There's only one bad thing about TypeScript: install size. Every package/project is small until it uses/depends on typescript.

TypeScript has been working on modularization but it is a very slow process. Meanwhile the usage is only soaring. This is an imperfect solution to the issue, but I hope it serves well.

The biggest offender seems to be tsserver, which is unnecessary most of the time because your editor already comes with one. Dropping it should be harmless most of the time.

Questions

Is there any compatibility issue?

It should be a drop-in replacement to the official package. Manual E2E test using the Vite repository has been successful.

The only compatibility issue is with Yarn 2+ (Berry), which patches TypeScript to solve its own compatibility issues.

How can I ensure this distribution does not contain malicious code?

While I'm not credible enough to guarantee anything, the build and publish process is publicly available in GitHub Actions log.

As with anything open source, you can always build this thing yourself.