typescript-plus

raw JSON →
3.1.5 verified Fri May 01 auth: no javascript

An enhanced TypeScript compiler (v3.1.5) built on top of tsc 3.1.3, adding features like accessor optimization, class reflection metadata emission, conditional compilation via defines, and automatic file reordering based on dependency analysis. Primarily maintained as part of the Egret Engine ecosystem. Releases track upstream TypeScript versions but lag behind, with current stable based on 3.1.3. Use this if you need its extra features, but be aware of possible incompatibility with standard TypeScript tooling and potential build issues due to non-standard compiler behavior. Not recommended for general-purpose projects unless you depend on Egret or its specific enhancements.

error error TS5023: Unknown compiler option 'accessorOptimization'.
cause Using the option with official tsc instead of typescript-plus binary.
fix
Run 'npx tsc-plus' instead of 'npx tsc'.
error Cannot find module 'typescript-plus'
cause Package not installed, or wrong import path in Node.js (CJS vs ESM).
fix
Run 'npm install typescript-plus' and use 'import * as ts from "typescript-plus"' (ESM) or 'const ts = require("typescript-plus")' (CJS).
error TypeError: ts.createProgram is not a function
cause Importing from 'typescript' instead of 'typescript-plus'.
fix
Change import to 'import { createProgram } from "typescript-plus"'.
error error TS6046: Name 'DEBUG' not found in 'defines'.
cause defines option expects a string key matching a variable declared with 'var' or a global.
fix
Ensure the variable is declared as 'var DEBUG = true;' at global scope, not 'const' or 'let'.
error Error: Cannot find module 'typescript' from 'typescript-plus'
cause typescript-plus has an optional dependency on 'typescript' that may be missing.
fix
Install typescript as a peer dependency: 'npm install typescript@3.1.3'.
breaking This package lags behind upstream TypeScript versions by several releases; using it with modern TypeScript features may cause errors.
fix Use official TypeScript for modern code; typescript-plus is intended for Egret Engine compatibility.
gotcha The 'reorderFiles' option can change module load order unexpectedly, potentially breaking code that relies on side effects of module declaration order.
fix Set 'reorderFiles' to false if your code depends on file order, or ensure no side effects in modules.
gotcha The 'defines' option replaces global variables at compile time but does not work with const or let; only var or global declarations can be replaced.
fix Use 'var DEBUG = true;' in source code and define in tsconfig as 'defines: { DEBUG: false }'.
deprecated This package is not actively maintained for new TypeScript versions; last update tracked tsc 3.1.3.
fix Consider migrating to official TypeScript and isolate Egret-specific features if needed.
critical Security vulnerability: this package has transitive dependencies on outdated versions of 'chalk' and 'supports-color' with known CVE-2023-26102 (prototype pollution).
fix Audit your lockfile and consider npm audit fix; if not used in production, this may be low priority.
breaking The 'emitReflection' option produces non-standard metadata that may not be consumed by standard reflect-metadata polyfill; it outputs a custom format.
fix Only use 'emitReflection' if your runtime (e.g., Egret) explicitly supports the output format.
npm install typescript-plus
yarn add typescript-plus
pnpm add typescript-plus

Shows tsconfig.json with extra options and both CLI and programmatic compilation using typescript-plus.

// Create a simple tsconfig.json with extra features
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "emitReflection": true,
    "reorderFiles": true,
    "defines": {
      "DEBUG": false
    }
  },
  "files": ["index.ts"]
}

// Then compile:
// npx tsc-plus --reorderFiles

// Programmatic usage:
import * as ts from 'typescript-plus';
const program = ts.createProgram(['index.ts'], {
  target: ts.ScriptTarget.ES5,
  module: ts.ModuleKind.CommonJS,
  emitReflection: true,
  reorderFiles: true,
  defines: { DEBUG: false }
});
const emitResult = program.emit();