Skip to content

feat: migrate from TypeScript compilation to type stripping#239

Merged
mcollina merged 5 commits into
mainfrom
migrate-to-type-stripping
Feb 7, 2026
Merged

feat: migrate from TypeScript compilation to type stripping#239
mcollina merged 5 commits into
mainfrom
migrate-to-type-stripping

Conversation

@mcollina

@mcollina mcollina commented Feb 2, 2026

Copy link
Copy Markdown
Owner

Summary

This PR migrates borp from TypeScript compilation (tsc) to Node.js native type stripping, simplifying the architecture and improving test execution speed.

Breaking Changes

Removed CLI Options

  • --no-typescript / -T - No longer needed, type stripping is always used
  • --post-compile / -P - No compilation step exists to hook into

Removed Features

  • Source map support (not needed with type stripping)
  • outDir handling - tests run directly from source
  • tsconfig.json project references / --build support

Removed Fixtures

The following fixtures that relied on compilation were removed:

  • ts-cjs - no CJS transformation support
  • ts-cjs-post-compile - post-compile hook obsolete
  • ts-esm-post-compile - post-compile hook obsolete
  • ts-esm-source-map - source maps not needed
  • src-to-dist - outDir pattern not applicable
  • monorepo - project references not supported

Requirements

  • Node.js >= 22.6.0 (22.19.0+, 24.x+, or 25.x+ recommended for best type stripping support)

Benefits

  • Faster test runs: No compilation step required
  • Simpler architecture: ~100 lines of code removed
  • Native TypeScript: Uses Node.js built-in type stripping
  • Better line numbers: Source maps not needed, original .ts line numbers preserved
  • Reduced dependencies: No direct TypeScript dependency needed

Architecture Changes

Simplified Core (lib/run.js)

  • Renamed runWithTypeScriptrunTests
  • Removed TypeScript compiler API usage
  • Removed watch mode tsc integration (now uses Node.js --watch)
  • Simplified to glob expansion + node:test run()

Updated CLI (borp.js)

  • Added Node.js version requirement
  • Removed TypeScript-related options
  • Fixed ignore patterns for auto-discovery
  • Updated coverage handling

Updated Imports

All TypeScript test files now use .ts extensions:

// Before
import { add } from '../src/add.js'

// After  
import { add } from '../src/add.ts'

TypeScript Constraints

Type stripping has some limitations. Code must follow these rules:

  • Use type-only imports: import type { Foo } or import { type Foo }
  • No enums: Use const objects with as const instead
  • No namespaces: Use regular modules
  • No parameter properties: Explicitly declare class properties
  • File extensions: Import .ts files with .ts extension

See Node.js TypeScript documentation for full details.

Migration Guide for Users

  1. Update imports: Change .js to .ts in TypeScript import statements
  2. Remove outDir: Tests run from source, not dist/ folder
  3. Review code: Ensure no enums, namespaces, or parameter properties
  4. Update tsconfig.json: Use noEmit: true for type checking only

CI Updates

Updated test matrix to focus on Node versions with type stripping support:

  • Added: 25.x
  • Kept: 22.x, 24.x
  • Dropped: 18.x, 20.x, 21.x, 23.x

Test Results

  • ✅ All 35 tests pass
  • ✅ 96.17% statement coverage
  • ✅ Verified on Node 22.x, 24.x, and 25.x

Documentation Updates

  • Updated README with new TypeScript documentation
  • Added migration guide from borp < 1.0
  • Updated example project setup
  • Added type stripping constraints section

Breaking changes:
- Remove TypeScript compilation (tsc) in favor of Node.js native type stripping
- Require Node.js >= 22.6.0 (type stripping support)
- Remove --no-typescript (-T) and --post-compile (-P) CLI options
- Remove outDir/prefix handling - tests run directly from source
- Remove source map support - not needed with type stripping
- Update all TypeScript imports to use .ts extensions
- Remove fixtures that relied on compilation (ts-cjs, post-compile, source-map, src-to-dist, monorepo)
- Reimplement watch mode using Node.js --watch flag

Benefits:
- Faster test execution (no compilation step)
- Simpler architecture (~100 lines removed)
- Native Node.js TypeScript support
- Source maps not needed (line numbers preserved)

Other changes:
- Update README with new TypeScript documentation
- Add .pi and .githuman to .gitignore
- Delete plan.md
- Remove TypeScript compilation in favor of Node.js native type stripping
- Remove --no-typescript and --post-compile CLI options
- Rename runWithTypeScript to runTests
- Fix ignore patterns for auto-discovery
- Update CI to test Node 22.x and 24.x (drop 18, 20, 21, 23)
- Update README with new TypeScript documentation
- Add .pi and .githuman to .gitignore
@mcollina

mcollina commented Feb 2, 2026

Copy link
Copy Markdown
Owner Author

cc @jsumners

@jsumners jsumners left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use borp to solve missing features of node --test. I don't have any opinion on the TypeScript aspects of the tool.

Comment thread borp.js Outdated
Comment on lines +63 to +64
process.stderr.write(`parsed config: ${foundConfig.join(' ')}
`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is way less clear than \n.

Address review comment: using template literal with a literal newline
is less clear than using \n for the newline character.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mcollina mcollina merged commit a695fd5 into main Feb 7, 2026
12 checks passed
@mcollina mcollina deleted the migrate-to-type-stripping branch February 7, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants