{"id":18874,"library":"typescript-compiler","title":"typescript-compiler","description":"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.","status":"abandoned","version":"1.4.1-2","language":"javascript","source_language":"en","source_url":"https://github.com/theblacksmith/typescript-compiler","tags":["javascript","TypeScript","compiler","language","api"],"install":[{"cmd":"npm install typescript-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add typescript-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Bundles a copy of TypeScript compiler; must match version expected by the wrapper.","package":"typescript","optional":true}],"imports":[{"note":"This package is CommonJS only; no ESM export available. Use require() to import.","wrong":"import tsc from 'typescript-compiler'","symbol":"typescript-compiler","correct":"const tsc = require('typescript-compiler')"},{"note":"The second argument must be an array of string arguments, not an options object.","wrong":"tsc.compile('file.ts', { out: 'out.js' })","symbol":"compile","correct":"tsc.compile(['file.ts'], ['--out', 'out.js'])"},{"note":"Options must be passed as string array, not as object. Example: tsc.compileString(src, ['--module', 'commonjs'])","wrong":"var js = tsc.compileString('class A {}', { module: 'commonjs' })","symbol":"compileString","correct":"var js = tsc.compileString('class A {}')"}],"quickstart":{"code":"const tsc = require('typescript-compiler');\n// Compile a TypeScript string\nconst result = tsc.compileString('let x: number = 1;', ['--noLib', '--target', 'ES5']);\nconsole.log(result);","lang":"javascript","description":"Shows how to load the library and compile a simple TypeScript string with compiler arguments."},"warnings":[{"fix":"Use tscArgs string array instead of the options object.","message":"The 'options' parameter is deprecated and will be removed in the next version.","severity":"deprecated","affected_versions":">=1.0"},{"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.","message":"Package bundles an outdated TypeScript compiler (likely 1.x).","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Ensure 'typescript' is installed separately if you want to use a different version.","message":"Missing TypeScript dependency: The package does not list 'typescript' as a peer dependency.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Pass an object with filenames as keys and source code as values.","message":"compileStrings() expects a Map/dictionary object, not an array.","severity":"breaking","affected_versions":">=1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install typescript-compiler' and ensure it is in your package.json.","cause":"npm install failed or package not in node_modules.","error":"Cannot find module 'typescript-compiler'"},{"fix":"Use 'const tsc = require('typescript-compiler')' instead of 'import'.","cause":"Incorrect import using ES6 import syntax.","error":"tsc.compile is not a function"},{"fix":"Pass compiler arguments as a string array (e.g., ['--out', 'file.js']) instead of an object.","cause":"Passing second argument as an options object to compile/compileString.","error":"The 'options' parameter is deprecated and will be removed."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}