CtrlK
BlogDocsLog inGet started
Tessl Logo

mcollina/typescript-magician

Designs complex generic types, refactors `any` types to strict alternatives, creates type guards and utility types, and resolves TypeScript compiler errors. Use when the user asks about TypeScript (TS) types, generics, type inference, type guards, removing `any` types, strict typing, type errors, `infer`, `extends`, conditional types, mapped types, template literal types, branded/opaque types, or utility types like `Partial`, `Record`, `ReturnType`, and `Awaited`.

87

1.16x
Quality

95%

Does it follow best practices?

Impact

76%

1.16x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-5/

Fixing a Loosely-Typed Data Pipeline Library

Problem/Feature Description

A small internal TypeScript library handles data transformation pipelines — it reads records from a source, transforms them through a chain of steps, and writes them to a destination. The library was written quickly and the original author leaned heavily on any to silence TypeScript errors during prototyping. The team is now preparing to open-source the library and wants it to be genuinely type-safe before release.

Your task is to audit the library, understand the current type errors and weaknesses, and produce a strictly-typed version. The team cares deeply about IntelliSense — consumers of the library should see accurate return types and autocompletion for all public APIs. They also want a clear record of what was wrong and how it was fixed, so that the PR reviewer can follow your reasoning.

Output Specification

Produce the following files:

  • src/pipeline.ts — the refactored library source with all any types replaced
  • src/type-tests.ts — compile-time tests verifying type constraints
  • tsconfig.json — TypeScript configuration for the project
  • tsc-before.txt — the TypeScript compiler output captured BEFORE your changes
  • tsc-after.txt — the TypeScript compiler output captured AFTER your changes
  • FIXES.md — a document explaining each fix: what the error was, what the root cause was, and how it was resolved (with before/after code blocks)

Input Files

The following files are provided as inputs. Extract them before beginning.

=============== FILE: src/pipeline.ts =============== // Data pipeline library — prototype quality, needs type-safe refactoring

export type TransformFn = (record: any) => any; export type FilterFn = (record: any) => boolean;

export interface Pipeline { source: any[]; transforms: any[]; filters: any[]; }

export function createPipeline(source: any[]): Pipeline { return { source, transforms: [], filters: [] }; }

export function addTransform(pipeline: Pipeline, fn: any): Pipeline { return { ...pipeline, transforms: [...pipeline.transforms, fn] }; }

export function addFilter(pipeline: Pipeline, fn: any): Pipeline { return { ...pipeline, filters: [...pipeline.filters, fn] }; }

export function runPipeline(pipeline: Pipeline): any[] { let records: any[] = pipeline.source; for (const filter of pipeline.filters) { records = records.filter(filter); } for (const transform of pipeline.transforms) { records = records.map(transform); } return records; }

// Gets a property from any object — callers get any back export function getField(obj: any, field: string): any { return obj[field]; }

// Wraps an async function to log its execution time export function withTiming(fn: any): any { return async (...args: any[]) => { const start = Date.now(); const result = await fn(...args); console.log(Took ${Date.now() - start}ms); return result; }; }

// Extracts and caches the return type of a function for documentation purposes export function describeReturnType(fn: any): string { // In real use this would introspect further; simplified here return typeof fn(); }

evals

SKILL.md

tile.json