{"id":12191,"library":"tsc","title":"TypeScript Compiler (Deprecated `tsc` package)","description":"The `tsc` npm package is a **deprecated** placeholder that offered an older, unsupported release of the TypeScript compiler. Users seeking the TypeScript compiler's command-line interface (`tsc`) should install the official `typescript` npm package instead. The current stable version of the `typescript` package is 6.0.3, released recently (as of April 2026). TypeScript generally follows a quarterly release cadence for major versions, with monthly patch updates to address bugs and regressions. Key differentiators of the `typescript` package include its comprehensive static type-checking capabilities, support for modern ECMAScript features, and rich tooling integration. It transpile TypeScript code into various JavaScript targets, ensuring broad compatibility across browsers and Node.js environments.","status":"deprecated","version":"2.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/basarat/tsc","tags":["javascript","typescript"],"install":[{"cmd":"npm install tsc","lang":"bash","label":"npm"},{"cmd":"yarn add tsc","lang":"bash","label":"yarn"},{"cmd":"pnpm add tsc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This `tsc` package is deprecated. The `typescript` package is the correct, official way to install and use the TypeScript compiler (`tsc`) CLI and its programmatic APIs.","package":"typescript","optional":false}],"imports":[{"note":"The deprecated `tsc` package offered no programmatic APIs. For direct interaction with the TypeScript compiler from JavaScript/TypeScript, you must import `typescript` after installing the official `typescript` npm package.","wrong":"import { tsc } from 'tsc'; // The 'tsc' package does not expose programmatic APIs.","symbol":"Programmatic usage of TypeScript compiler","correct":"import ts from 'typescript';\n\nconst program = ts.createProgram(['./src/index.ts'], {\n  target: ts.ScriptTarget.ES2020,\n  module: ts.ModuleKind.CommonJS,\n});\n// ... further programmatic compilation steps"}],"quickstart":{"code":"/*\n  This quickstart demonstrates how to set up and use the actual TypeScript compiler (tsc) \n  by installing the officially supported 'typescript' npm package.\n*/\n\n// 1. Initialize a new Node.js project\n// npm init -y\n\n// 2. Install the official TypeScript compiler as a development dependency\n// npm install --save-dev typescript\n\n// 3. Initialize a tsconfig.json file for your project (optional, but recommended)\n// npx tsc --init\n\n// 4. Create a TypeScript file (e.g., src/index.ts)\n// (You would typically create this file manually or through your IDE)\n\n// src/index.ts\ninterface User {\n  id: number;\n  name: string;\n  email?: string;\n}\n\nfunction greetUser(user: User): string {\n  return `Hello, ${user.name} (ID: ${user.id})!`;\n}\n\nconst newUser: User = {\n  id: 1,\n  name: 'Alice',\n  email: 'alice@example.com',\n};\n\nconsole.log(greetUser(newUser));\n\n// 5. Compile your TypeScript code to JavaScript\n// npx tsc\n\n// This will create a 'dist' folder (or your configured outDir) with index.js\n// You can then run the compiled JavaScript:\n// node dist/index.js\n\n// Output in console: Hello, Alice (ID: 1)!\n","lang":"typescript","description":"This quickstart demonstrates how to install and use the `tsc` command-line interface provided by the official `typescript` npm package to compile a basic TypeScript project."},"warnings":[{"fix":"Migrate immediately to the `typescript` npm package. Uninstall `tsc` and install `typescript`: `npm uninstall tsc && npm install -D typescript`.","message":"The `tsc` npm package is officially deprecated and should not be used. It contains an outdated version of the TypeScript compiler and may lack critical features, bug fixes, or security patches present in the official `typescript` package.","severity":"breaking","affected_versions":">=2.0.4"},{"fix":"Always install `typescript` (e.g., `npm install -D typescript`) to ensure you have the latest stable TypeScript compiler. Use `npx tsc` or define `\"tsc\": \"tsc\"` in your `package.json` scripts to ensure the locally installed version is used.","message":"Attempting to use `tsc` directly after installing the deprecated `tsc` package will result in an outdated compiler version. This can lead to unexpected syntax errors, missing type definitions, or incompatibilities with modern TypeScript language features or libraries.","severity":"gotcha","affected_versions":">=2.0.4"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"If `typescript` is installed locally (`npm install -D typescript`), use `npx tsc` to execute the local version. If you intend to use it globally, install it via `npm install -g typescript`.","cause":"The `tsc` command-line tool is not found in your system's PATH. This usually happens if `typescript` is installed locally but not globally, or if `npm`'s bin directory isn't in PATH.","error":"'tsc' is not recognized as an internal or external command, operable program or batch file."},{"fix":"Ensure you are using the latest `typescript` package. Run `npm uninstall tsc && npm install -D typescript` in your project. If you have a global installation, run `npm update -g typescript`.","cause":"You are using an outdated version of the TypeScript compiler, possibly from the deprecated `tsc` package or an older global `typescript` installation.","error":"error TSxxxx: <Some error related to an old TypeScript feature>"}],"ecosystem":"npm"}