ftst - Fast TypeScript Transpiler (Type Stripping)
raw JSON → 1.2.2 verified Fri May 01 auth: no javascript
ftst (v1.2.2) is a minimal TypeScript transpiler that removes type annotations from TypeScript files, leaving readable JavaScript where the output is line-by-line equivalent to the input. This eliminates the need for source maps during debugging. It supports only ES2019, ES2020, and ESNext script targets, and offers a command-line runner (node -r ftst filename.ts) as well as JS API functions transpileModule and transpile. Compared to tsc or other transpilers, ftst focuses solely on type stripping without full compilation, making it extremely fast and suitable for quick type removal tasks or debugging scenarios. It is dependency-free and works in Node.js environments.
Common errors
error Cannot find module 'ftst/transpiler' ↓
cause Typo or incorrect path; correct path is 'ftst/transpiler'.
fix
Ensure you import from 'ftst/transpiler' (not 'ftst/transpile' or 'ftst').
error TypeError: ftst.transpileModule is not a function ↓
cause Importing from wrong module (main 'ftst' instead of 'ftst/transpiler') or using default import incorrectly.
fix
Use: import { transpileModule } from 'ftst/transpiler';
error Unsupported target 'ES5' specified. Only ES2019, ES2020, ESNext are allowed. ↓
cause Setting unsupported script target in compilerOptions.
fix
Set target to one of: ScriptTarget.ES2019, ScriptTarget.ES2020, ScriptTarget.ESNext.
Warnings
gotcha Only ES2019, ES2020, and ESNext script targets are supported. Using other targets may produce incorrect output or errors. ↓
fix Set compilerOptions.target to ScriptTarget.ES2019, ScriptTarget.ES2020, or ScriptTarget.ESNext.
gotcha The main module export (require('ftst')) may not expose the transpile functions directly. Use 'ftst/transpiler' instead. ↓
fix Import from 'ftst/transpiler' for transpileModule, transpile, and enums.
gotcha The remove parameter in transpileModule affects whether types are commented out or fully removed. When true, types are stripped entirely; when false, they are replaced with comments. ↓
fix Set remove to true to avoid commented types in output.
breaking No major breaking changes reported; however, the package is minimal and may not handle all TypeScript syntax (e.g., advanced type constructs or decorators). ↓
fix Test your code thoroughly; consider using full tsc for complex TypeScript features.
Install
npm install ftst yarn add ftst pnpm add ftst Imports
- transpileModule wrong
import ftst from 'ftst'; ftst.transpileModule(...)correctimport { transpileModule } from 'ftst/transpiler' - transpile wrong
const { transpile } = require('ftst/transpiler');correctimport { transpile } from 'ftst/transpiler' - ModuleKind wrong
const { ModuleKind } = require('ftst');correctimport { ModuleKind } from 'ftst/transpiler' - ScriptTarget
import { ScriptTarget } from 'ftst/transpiler'
Quickstart
import { transpileModule, ModuleKind, ScriptTarget } from 'ftst/transpiler';
const source = `
interface Person {
name: string;
age: number;
}
function greet(person: Person): string {
return `Hello, ${person.name}!`;
}
`;
const options = {
compilerOptions: {
target: ScriptTarget.ES2020,
module: ModuleKind.CommonJS,
removeComments: false,
noEmitHelpers: true,
preserveConstEnums: true,
noImplicitUseStrict: true,
newLine: 'lf',
downlevelIteration: true,
suppressExcessPropertyErrors: true
},
reportDiagnostics: true
};
const result = transpileModule(source, options, true);
console.log(result.outputText);
// Expected output: function greet(person) { return 'Hello, ' + person.name + '!'; }