coffee-script-to-typescript
raw JSON → 0.1.0 verified Fri May 01 auth: no javascript deprecated
Transpile CoffeeScript code to TypeScript (v0.1.0, last updated 2013). Aims to produce idiomatic TypeScript rather than perfectly equivalent code, targeting migration of codebases to TypeScript. Key differentiator: focuses on translation to TypeScript syntax, not JavaScript. Release cadence: single initial release only. Note: outdated, may not work with modern Node.js or TypeScript.
Common errors
error Error: Cannot find module 'underscore' ↓
cause Missing peer dependency underscore required by generated code or library itself
fix
npm install underscore && require('underscore') before using the library.
error RangeError: Invalid array length at _.range ↓
cause CoffeeScript range [9...0] generates _.range(9,0) which returns empty array instead of descending
fix
Use custom range function or manually adjust generated code for descending ranges.
Warnings
breaking Generated code may have type errors due to missing type annotations ↓
fix Manually add type annotations after transpilation.
breaking Requires underscore runtime: uses _.range for CoffeeScript ranges ↓
fix Install underscore and ensure it's available in the runtime.
breaking Does not support modern CoffeeScript syntax (e.g., ES6 modules) ↓
fix Use alternatives like decaffeinate or ts-ify for modern codebases.
deprecated Package is unmaintained since 2013 ↓
fix Migrate to decaffeinate or TypeScript compiler with CoffeeScript plugin.
Install
npm install coffee-script-to-typescript yarn add coffee-script-to-typescript pnpm add coffee-script-to-typescript Imports
- default wrong
const coffeeToTypescript = require('coffee-script-to-typescript')correctimport coffeeToTypescript from 'coffee-script-to-typescript'
Quickstart
const { transpile } = require('coffee-script-to-typescript');
const coffeeCode = `square = (x) -> x * x`;
try {
const tsCode = transpile(coffeeCode, { comments: true });
console.log(tsCode);
} catch (err) {
console.error('Transpilation failed:', err.message);
}