Suggest a PR with a small improvement
- User
Suggest a PR with a small improvement
Assistant
diff--- a/app.ts +++ b/app.ts @@ -66,10 +66,7 @@ return values.map(x => Math.round(x)) } -export function constNull() : any { return null } - -export function pushN(n: number, val: () => any = constNull ) { - const a: any[] = [] +export function pushN<T>(n: number, val: () => T = () => null ): T[] { for (let i = 0; i < n; i++) a.push(val()) return a }This PR addresses a minor type issue within the
pushNfunction. Originally, the function was implicitly returningany[], lacking specific type information. This change introduces generics topushNso that it now returns an array of the correct type, improving type safety and making it easier for TypeScript to catch potential errors. The default value is stillnull, maintaining the original functionality when no value generator is provided. This small change enhances the overall type correctness of the library.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.