Skip to content

Conversation

@vtushar06
Copy link
Contributor

What kind of change does this PR introduce?
This PR completes the removal of 'any' type annotations from utility functions, library code, and test files.

Issue Number:

Summary
Finalizes the complete elimination of 'any' type annotations across the remaining library utilities, utility functions, blog pages, and Cypress test files.

Key changes included:

  • calendarUtils.ts: Imported CalendarResponse and VEvent types from node-ical, created CalendarEventInfo interface
  • getStaticMarkdownProps.ts: Added Props interface for type-safe parameter handling
  • getPartsOfJson.ts, getScopesOfParsedJsonSchema.ts, slugifyMarkdownHeadline.ts: Fixed reduce() operations with explicit type annotations
  • blog/index.page.tsx: Implemented type guards for category filtering with proper type predicates
  • pages/_app.page.tsx, pages/index.page.tsx, community/index.page.tsx: Fixed Frontmatter and data type annotations
  • Cypress tests (3 files): Updated with proper typing for component and plugin mocks

Type Safety Improvements:

  • Removed implicit 'any' from library exports and internal functions
  • Added type guards for blog category filtering
  • Proper typing of external library integration (node-ical)
  • Type-safe Cypress mock functions for testing

Does this PR introduce a breaking change?
No

Checklist

Please ensure the following tasks are completed before submitting this pull request.

  • Read, understood, and followed the contributing guidelines
  • TypeScript compilation: 0 errors
  • Linting passes with no warnings
  • Build succeeds successfully
  • Cypress tests properly typed

Copilot AI review requested due to automatic review settings December 7, 2025 03:46
@vtushar06 vtushar06 requested a review from a team as a code owner December 7, 2025 03:46
@github-project-automation github-project-automation bot moved this to Ready to review in PR - Triage Group Dec 7, 2025
@github-actions
Copy link

github-actions bot commented Dec 7, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
website ✅ Ready (View Log) Visit Preview 60e21c3

@vtushar06 vtushar06 changed the title fix(libs): Remove 'any' types from utilities, libraries, and tests fix(libs): Remove 'any' types from utilities, libraries, and tests (#1034) Dec 7, 2025
@codecov
Copy link

codecov bot commented Dec 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2dd1d24) to head (60e21c3).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1975   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           30        30           
  Lines          633       655   +22     
  Branches       196       214   +18     
=========================================
+ Hits           633       655   +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR successfully completes the removal of 'any' type annotations from utility functions, library code, and test files across the JSON Schema website codebase. The changes improve type safety, include defensive coding practices, and fix several potential runtime issues.

Key changes:

  • Created centralized type definitions in types/common.ts for reusable interfaces
  • Replaced all any types with proper TypeScript types across 40+ files
  • Added conditional rendering guards to prevent undefined values from causing errors
  • Improved date handling to avoid invalid Date object creation

Reviewed changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
types/common.ts New file with centralized type definitions (Frontmatter, BlogPost, CalendarEventInfo, etc.)
lib/calendarUtils.ts Added proper types from node-ical, created CalendarEventInfo interface, improved type safety
lib/getStaticMarkdownProps.ts Added proper return type and Frontmatter interface
lib/getScopesOfParsedJsonSchema.ts Added ParsedJsonSchema interface, improved reduce type annotations
lib/getPartsOfJson.ts Added proper types for reduce operations and array elements
lib/slugifyMarkdownHeadline.ts Improved type annotation for reduce operation
pages/blog/index.page.tsx Added type guards for category filtering, proper Frontmatter interface
pages/blog/posts/[slug].page.tsx Fixed date handling to avoid invalid Date objects
pages/blog/generateRssFeed.tsx Added BlogPost and BlogPostFrontmatter interfaces, improved optional property handling
pages/index.page.tsx Modernized file filtering with endsWith(), added proper blog post and event types
pages/community/index.page.tsx Added proper types for blog posts and calendar events
pages/_app.page.tsx Removed use of any for Component, added proper type for getLayout
pages/[slug].page.tsx Added Frontmatter type from common types
pages/specification/* Added proper types, conditional rendering for optional frontmatter fields
pages/draft/* Added DraftFrontmatter and BlocksData interfaces
pages/overview/* Added Frontmatter type, improved optional chaining
pages/learn/* Added Frontmatter type
pages/implementers/* Added Frontmatter type
pages/ambassadors/index.page.tsx Changed ambassadorData type from any to string
components/Layout.tsx Added proper store type, improved event.target casting
components/JsonEditor.tsx Added proper Slate types (RenderLeafProps, RenderElementProps), improved type safety throughout
components/GettingStarted.tsx Added proper types for options and instances
components/DocTable.tsx Added Author interface, conditional rendering for optional fields
components/Code.tsx Changed children type from any to React.ReactNode
cypress/plugins/mockNextRouterUtils.ts Added proper Cypress and Sinon stub types
cypress/components/*.cy.tsx Added proper types for mock functions and parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const files = fs.readdirSync(PATH);
const blogPosts = files
const blogPosts: BlogPost[] = files
.filter((file) => file.substr(-3) === '.md')
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] For consistency with the change made in pages/index.page.tsx line 31, consider using .endsWith('.md') instead of .substr(-3) === '.md'. The endsWith() method is more modern and clearer in intent.

Suggested change
.filter((file) => file.substr(-3) === '.md')
.filter((file) => file.endsWith('.md'))

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready to review

Development

Successfully merging this pull request may close these issues.

🐛 Bug: Search and remove any from codebase

1 participant