TypeScript Type Helper
Build a TypeScript type for a tricky scenario.
Added May 11, 20260 runs
Prompt
Act as a TypeScript guru. What I want to type: [DESCRIPTION] Example values that should be accepted: [VALID] Example values that should be rejected: [INVALID] Generic vs. concrete: [PREFERENCE] Produce: 1. The type definition (idiomatic TS, no any) 2. Inline comments explaining each piece if it uses advanced features 3. 3 test cases showing acceptance + 3 showing rejection 4. The error messages a developer would see when using it wrong 5. Notes on TS version requirements (template literal types, satisfies, etc.) 6. A simpler alternative if the type starts to feel too clever