Registry / testing / ts-migration

ts-migration

JSON →
library1.0.1jsnpmunverified

A TypeScript library for defining typesafe bidirectional migrations between object shapes. Current stable version is 1.0.1, released on npm with infrequent updates. It allows compile-time validation of migration schemas using TypeScript types. Key differentiators: fully typed migrations (forward and reverse), supports both 1-1 and unidirectional transformations, and uses a fluent API with CompileMigration. Alternative libraries like transmutable or object-mapper lack bidirectional typing or compile-time safety.

npm install ts-migration
INSTALL
IMPORT
SIG · TS-MIGRATION
T
ts-migration
testingjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CompileMigration
✓ import CompileMigration from 'ts-migration'
✗ import { CompileMigration } from 'ts-migration'
Default export only; named import does not exist.
compiled type
✓ import type { Migration } from 'ts-migration'
Type exports available for Migration type (inferred from CompileMigration return).

Create a bidirectional migration between two object shapes using CompileMigration.

import CompileMigration from 'ts-migration' const myObj = { a: 1, b: 'hello' } const otherObj = { x: 1, y: 'hello' } const migration = CompileMigration( myObj, otherObj, ({ left, right }) => ({ [left.a]: right.x, [left.b]: right.y, [right.x]: left.a, [right.y]: left.b, }) ) const resultForward = migration.forward(myObj) const resultReverse = migration.reverse(otherObj)
Debug
Known issues
gotchaMigration objects must have all keys from both shapes defined; missing keys cause runtime errors.
fix
Ensure every property from both object types is present in the migration mapping.
affects: >=1.0.0
gotchaThe CompileMigration function expects mutable objects; passing frozen objects may cause unexpected behavior.
fix
Use plain object literals or clone objects before passing.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'split')
Unidirectional mapping function expects the correct type but receives a different argument order or type.
fix
Ensure unidirectional functions accept the correct parameter type (left for right-to-left, right for left-to-right).
Module not found: Can't resolve 'ts-migration'
Package not installed or import path incorrect.
fix
Install: npm install ts-migration. Import: import CompileMigration from 'ts-migration'
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
typescriptoptionalRequired for type safety at compile time; the library relies heavily on TypeScript's type system
Agent activity
20 hits · last 30 days
node
18
Resources
ts-migration — npm install ts-migration · libregistry