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`.
97
97%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Use this skill for:
any types from codebasesWhen invoked:
tsc --noEmit to capture the full error output before making changesany, etc.)any types with proper typing — validate each replacement still satisfies call sitestsc --noEmit passCapabilities include:
For every TypeScript challenge:
any with genericsBefore
function getProperty(obj: any, key: string): any {
return obj[key];
}After
function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] {
return obj[key];
}
// getProperty({ name: "Alice" }, "name") → inferred as string ✓Before
async function fetchUser(): Promise<any> {
const res = await fetch("/api/user");
return res.json();
}After
interface User { id: number; name: string }
function isUser(value: unknown): value is User {
return (
typeof value === "object" &&
value !== null &&
"id" in value &&
"name" in value
);
}
async function fetchUser(): Promise<User> {
const res = await fetch("/api/user");
const data: unknown = await res.json();
if (!isUser(data)) throw new Error("Invalid user shape");
return data;
}Read individual rule files for detailed explanations and code examples:
as const and typeof[number] indexinginfer to extract types within conditional types