{"id":"code-col-ts-generic-stub-with-jsdoc","audience":"college","category":"coding","track":"coding","technique":"constraints","title":"Write a generic TypeScript stub with exact JSDoc lines","free":false,"task":"Your team is splitting a utils file: you write signatures, Priya writes bodies. Write a stub for groupBy with exactly this signature: export function groupBy<T, K extends PropertyKey>(items: readonly T[], keyOf: (item: T) => K): Record<K, T[]>. Above it, a JSDoc block with a one-line summary and exactly the tags @param items, @param keyOf and @returns. The body is only throw new Error(\"TODO: Priya\"). Exactly 1 code block of at most 10 lines, under 20 words of text.","materialLabel":"The spec from the team board (attached to your prompt automatically)","material":"Card #31 - utils/groupBy  (team: Larkspur, CS 4120 capstone)\n\nWhat: Group a list of things by a key, e.g. group study sessions by\ncourse code, or tasks by assignee.\n\nExample:\n  groupBy(sessions, (s) => s.course)\n  // { \"CS 4120\": [ ...sessions ], \"MA 3110\": [ ... ] }\n\nRequirements\n- generic: works for any item type\n- key function decides the group; keys are strings, numbers or symbols\n- input array must not be modified\n- result: object from key -> array of items, in original order\n\nSplit of work\n- signature + docs: you (by Wednesday, so the UI team can code against it)\n- implementation + tests: Priya (by Friday)\n\nRepo conventions\n- TypeScript 5.5, \"strict\": true\n- every exported function has JSDoc with @param for each parameter and\n  @returns; no @example blocks (they go stale)\n- no lodash: we removed it in week 3","rules":[{"type":"codeBlocks","count":1},{"type":"maxCodeLines","max":10},{"type":"maxProseWords","max":20}],"mistakes":[{"title":"Getting an implementation","why":"The AI writes the reduce loop, which is Priya's task.","fix":"Say: \"Stub only: the body is throw new Error(\\\"TODO: Priya\\\").\"","checks":["r1","maxCodeLines"]},{"title":"A slightly different signature","why":"The AI picks its own names or drops readonly, so the UI team codes against the wrong thing.","fix":"Paste the exact signature.","checks":["r0"]},{"title":"Off-convention docs","why":"The AI adds an @example block or skips @returns.","fix":"Add: \"JSDoc: one-line summary, @param items, @param keyOf, @returns. No @example.\"","checks":["r2"]},{"title":"Extras around it","why":"The AI explains generics and suggests lodash.","fix":"Add: \"One code block, no text.\"","checks":["codeBlocks","maxProseWords"]}],"promptHints":[{"label":"Asks for a stub","patterns":["stub","TODO","not implement","no (logic|implementation)"]},{"label":"Gives the signature","patterns":["PropertyKey","readonly T\\[\\]","Record<K, T\\[\\]>"]},{"label":"Specifies the JSDoc","patterns":["jsdoc","@param","@returns"]},{"label":"Rules out @example","patterns":["no @example","@example"]},{"label":"Limits the reply","patterns":["no (text|explanation)","one code block"]}],"hint":"A shared signature only helps if it's exact. Paste it, say the body stays empty, and spell out which doc tags your repo wants.","rubricLabels":["The signature is exactly export function groupBy<T, K extends PropertyKey>(items: readonly T[], keyOf: (item: T) => K): Record<K, T[]>","The body contains only throw new Error(\"TODO: Priya\"), with no grouping logic and no imports or lodash","Above the function is a JSDoc block with a one-line summary and exactly the tags @param items, @param keyOf and @returns (no @example or other tags)"]}