Registry / serialization / typescript-compiler

typescript-compiler

JSON →
library1.4.1-2jsnpmunverified

A JavaScript library that wraps the TypeScript command-line compiler, providing programmatic API to compile TypeScript files and strings. The library exposes compile(), compileString(), and compileStrings() methods, allowing developers to integrate TypeScript compilation into Node.js workflows without shelling out to tsc. It supports passing compiler options, error callbacks, and can handle multiple source files with reference tags. Version 1.4.1-2 is the latest release, updated sporadically; no active development observed since 2016. Unlike ts-node or ts-jest, this wrapper is minimal and does not include a resolver, so all imports must be fully resolved.

npm install typescript-compiler
INSTALL
IMPORT
SIG · TYPESCRIPT-COMPILE
T
typescript-compiler
serializationjavascriptv1.4.1-2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

typescript-compiler
const tsc = require('typescript-compiler')
import tsc from 'typescript-compiler'
This package is CommonJS only; no ESM export available. Use require() to import.
compile
tsc.compile(['file.ts'], ['--out', 'out.js'])
tsc.compile('file.ts', { out: 'out.js' })
The second argument must be an array of string arguments, not an options object.
compileString
var js = tsc.compileString('class A {}')
var js = tsc.compileString('class A {}', { module: 'commonjs' })
Options must be passed as string array, not as object. Example: tsc.compileString(src, ['--module', 'commonjs'])

Shows how to load the library and compile a simple TypeScript string with compiler arguments.

const tsc = require('typescript-compiler'); // Compile a TypeScript string const result = tsc.compileString('let x: number = 1;', ['--noLib', '--target', 'ES5']); console.log(result);
Debug
Known issues
deprecatedThe 'options' parameter is deprecated and will be removed in the next version.
fix
Use tscArgs string array instead of the options object.
affects: >=1.0
gotchaPackage bundles an outdated TypeScript compiler (likely 1.x).
fix
Install a separate TypeScript version and use the 'options' parameter to point to a different compiler? Not supported. Consider using ts-node or a modern wrapper.
affects: >=1.0
gotchaMissing TypeScript dependency: The package does not list 'typescript' as a peer dependency.
fix
Ensure 'typescript' is installed separately if you want to use a different version.
affects: >=1.0
breakingcompileStrings() expects a Map/dictionary object, not an array.
fix
Pass an object with filenames as keys and source code as values.
affects: >=1.0
Errors
Common errors & fixes
Cannot find module 'typescript-compiler'
npm install failed or package not in node_modules.
fix
Run 'npm install typescript-compiler' and ensure it is in your package.json.
tsc.compile is not a function
Incorrect import using ES6 import syntax.
fix
Use 'const tsc = require('typescript-compiler')' instead of 'import'.
The 'options' parameter is deprecated and will be removed.
Passing second argument as an options object to compile/compileString.
fix
Pass compiler arguments as a string array (e.g., ['--out', 'file.js']) instead of an object.
Upgrade
Version history
1.4.1-2latest on npm
Audit
Dependencies
typescriptoptionalBundles a copy of TypeScript compiler; must match version expected by the wrapper.
Agent activity
10 hits · last 30 days
node
8
Bingbot
1
OpenAI (training)
1
Resources
typescript-compiler — npm install typescript-compiler · libregistry