Metano Runtime
raw JSON → 1.0.3 verified Fri May 01 auth: no javascript
Runtime support library for code generated by the Metano C# → TypeScript transpiler (v1.0.3, updated April 2026). Provides C#-compatible primitives such as HashCode (xxHash32), HashSet with structural equality, a full LINQ API via Enumerable, a branded UUID type for System.Guid mapping, runtime type guards (isInt32, isString, etc.), and JSON serialization (system/json). Release cadence is active (multiple versions per month). Key differentiator: automatically added by Metano to generated projects; side-effect-free for tree-shaking. Requires @typescript/native-preview (peer dep). Only relevant for Metano users; not designed for general-purpose use.
Common errors
error Error: Cannot find module 'metano-runtime' ↓
cause metano-runtime is not installed; Metano should add it automatically but missing npm install step.
fix
Run 'npm install' after code generation, or manually add 'metano-runtime' to dependencies.
error TypeError: Class extends value undefined is not a constructor or null ↓
cause Missing peer dependency @typescript/native-preview v7, required for generic type utilities.
fix
Run 'npm install @typescript/native-preview@^7'.
error Cannot find module 'metano-runtime/system/json' ↓
cause Subpath imports may not be supported by older bundlers or Node.js versions (<12).
fix
Update Node.js to >=14 or use a bundler that supports the 'exports' field in package.json.
Warnings
gotcha This library is auto-installed by the Metano transpiler; manual use is discouraged. The public API is unstable across Metano versions. ↓
fix Only consume via generated code; do not depend on it directly.
deprecated The 'Erasable' annotation was renamed to 'NoContainer' in v1.0.0. ↓
fix Use [NoContainer] attribute instead of [Erasable] in generated code.
breaking Peer dependency @typescript/native-preview ^7 required since v1.0.0. Older versions did not require it. ↓
fix Add @typescript/native-preview@^7 as a dependency or devDependency.
Install
npm install metano-runtime yarn add metano-runtime pnpm add metano-runtime Imports
- HashCode wrong
import HashCode from 'metano-runtime'correctimport { HashCode } from 'metano-runtime' - HashSet wrong
const { HashSet } = require('metano-runtime')correctimport { HashSet } from 'metano-runtime' - Enumerable wrong
import { Enumerable } from 'metano-runtime/enumerable'correctimport { Enumerable } from 'metano-runtime' - UUID wrong
import { Uuid } from 'metano-runtime'correctimport { UUID } from 'metano-runtime' - JsonSerializer wrong
import { JsonSerializer } from 'metano-runtime'correctimport { JsonSerializer } from 'metano-runtime/system/json'
Quickstart
import { HashCode, HashSet, Enumerable, UUID, isInt32 } from 'metano-runtime';
// HashCode usage
const hc = new HashCode();
hc.add('hello');
hc.add(42);
const hash = hc.toHashCode(); // number
// HashSet with structural equality
class Point {
constructor(readonly x: number, readonly y: number) {}
equals(other: Point) { return this.x === other.x && this.y === other.y; }
hashCode() {
const hc = new HashCode();
hc.add(this.x);
hc.add(this.y);
return hc.toHashCode();
}
}
const set = new HashSet<Point>();
set.add(new Point(1, 2));
console.log(set.has(new Point(1, 2))); // true
// Enumerable (LINQ)
const result = Enumerable.from([1, 2, 3, 4, 5])
.where(x => x > 1)
.select(x => x * 2)
.toArray(); // [4, 6, 8, 10]
// UUID
const id = UUID.newUuid();
console.log(id); // "550e8400-e29b-41d4-a716-446655440000"
if (UUID.isUuid(id)) { console.log('valid UUID'); }
// Type guard
console.log(isInt32(123)); // true
console.log(isInt32(1.5)); // false