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
95%
Does it follow best practices?
Impact
76%
1.16xAverage score across 5 eval scenarios
Passed
No known issues
A SaaS product team manages a growing list of feature flags used to control which features are visible to which customer tiers. Currently, the flag registry is a plain JavaScript object and the lookup function returns boolean | undefined, giving no compile-time safety — developers frequently misspell flag names or look up flags that don't exist. The team wants a TypeScript-native flag system where:
string[].The team's TypeScript toolchain is on version 5.2, so modern language features are available. However, they would also like the implementation documented with a fallback approach that works on older TypeScript versions, for the benefit of other teams that haven't upgraded.
Produce the following files:
feature-flags.ts — the flag registry and lookup implementationtype-tests.ts — compile-time tests verifying:
@ts-expect-error)string)README.md — explains the two approaches (modern and fallback), the type-level mechanisms used, and when each technique applies