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-3/

Type-Safe Event System with Handler Inference

Problem/Feature Description

A React-like UI framework team is building an internal event system that needs to be genuinely type-safe across two dimensions. First, they want an event registry where adding a new event automatically derives the corresponding handler type map — so that onClick is always typed as (e: MouseEvent) => void and onKeyDown as (e: KeyboardEvent) => void, derived entirely from the registry rather than maintained manually. Second, the system needs to handle event lifecycle states (pending, dispatching, handled, cancelled) with a state machine that TypeScript can verify is exhaustive — if a new lifecycle state is added to the code, any switch statement that doesn't handle it should fail to compile.

The team also wants to make sure that the system's internal async dispatch loop handles type narrowing correctly given that narrowed types can sometimes reset inside callbacks.

Output Specification

Produce the following files:

  • event-system.ts — the event registry type infrastructure, handler map derivation, and lifecycle state machine
  • type-tests.ts — compile-time tests verifying:
    • Handler types are correctly derived from the event registry
    • Invalid handler types are rejected
    • Adding an unhandled lifecycle state causes a compile-time error
  • DESIGN.md — a short explanation covering: how the handler map type is derived from the registry, how the lifecycle state machine ensures all states are handled at the type level, and any considerations around type narrowing inside the async dispatch loop

evals

SKILL.md

tile.json