TypeScript Type Stripping: What Gets Removed and What Stays
TypeScript to JavaScript conversion is primarily about removing type annotations. Understanding what gets stripped and what remains helps you write better TypeScript and predict the JavaScript output.
TypeScript to JavaScript Converter
Strip TypeScript types, interfaces, enums, and generics to get clean JavaScript. Paste your .ts or .tsx code and get .js output instantly.
Ctrl+Enter to copy output · Conversion is instant as you type
What TypeScript removes during compilation
TypeScript strips all type-only constructs: interface declarations, type aliases, type annotations on variables and parameters, generic type parameters, type assertions (as Type), access modifiers (public/private/protected), the readonly keyword, implements clauses, declare statements, and non-null assertions (!). These exist only for the type checker and have zero runtime impact.
// TypeScript type stripping — remove types, keep logic
// Before (TypeScript)
interface User {
name: string;
age: number;
}
function greet(user: User): string {
return `Hello, ${user.name}`;
}
const users: User[] = [{ name: "Alice", age: 30 }];
// After (JavaScript) — types removed, logic preserved
function greet(user) {
return `Hello, ${user.name}`;
}
const users = [{ name: "Alice", age: 30 }];
// Node.js 22+ supports --experimental-strip-types
// node --experimental-strip-types app.tsWhat TypeScript keeps or transforms
Enums are converted to JavaScript objects. Decorators are transformed to function calls. Class fields with initializers are preserved. Optional chaining (?.) and nullish coalescing (??) are kept as-is for modern targets or polyfilled for older targets. Import statements are rewritten based on the module format (CommonJS vs ESM). JSX is either preserved or compiled to React.createElement calls depending on the jsx compiler option.
Type-only imports and exports
TypeScript 3.8+ supports 'import type' and 'export type' syntax, which are completely erased during compilation. Regular imports of types are also removed if the compiler can determine they are type-only. This is called 'import elision' and helps produce cleaner JavaScript output with no unused imports.
Frequently Asked Questions
Does TypeScript add any runtime code?
In most cases, no. TypeScript is a compile-time-only type system. Exceptions: enums generate runtime objects, decorators generate function calls, and downlevel compilation (targeting ES5) may add helper functions for async/await, spread operators, and class features.
Can I strip TypeScript types without the full compiler?
Yes. Tools like sucrase, esbuild, and SWC perform type stripping without full type checking, which is much faster. Node.js 23.6+ also has experimental --experimental-strip-types flag for native type stripping. This DevBolt tool strips types client-side without any server processing.
Related Convert Tools
CSS Unit Converter
Convert between px, rem, em, pt, vw, vh, and % — single values or batch-convert entire CSS files with configurable base font size
Base64 Codec
Encode and decode Base64 strings with Unicode support
Color Converter
Convert colors between HEX, RGB, and HSL formats
Epoch Converter
Convert Unix timestamps to dates and back