Skip to content

Conversation

Copy link

Copilot AI commented Nov 13, 2025

Addresses type safety feedback on the defaultsValueFromSchema function which was using any types extensively in its signature.

Changes

  • Function signature: Added generic <T = any> and changed schema: S.Schema<any>S.Schema<T>
  • Parameter types: Changed record: Record<string, any>Record<string, unknown>
  • Return type: Changed anyT | Partial<T> | null | undefined to accurately reflect actual return values
  • Internal handling: Added type assertions for recursive calls where unknown types needed explicit casting

Example

// Before
export const defaultsValueFromSchema = (
  schema: S.Schema<any>,
  record: Record<string, any> = {}
): any => { ... }

// After
export const defaultsValueFromSchema = <T = any>(
  schema: S.Schema<T>,
  record: Record<string, unknown> = {}
): T | Partial<T> | null | undefined => { ... }

The generic parameter enables better type inference while maintaining backward compatibility through the T = any default.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 13, 2025
Copilot AI changed the title [WIP] Streamline default value management based on feedback Improve type safety in defaultsValueFromSchema with generics Nov 13, 2025
Copilot finished work on behalf of MakhBeth November 13, 2025 23:09
Copilot AI requested a review from MakhBeth November 13, 2025 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants