Skip to content

Conversation

@vtushar06
Copy link
Contributor

What kind of change does this PR introduce?
This PR eliminates 'any' type annotations from core React components through proper type guards and specific type definitions.

Issue Number:

Summary

Removes implicit 'any' types from 4 React components.

Key changes included:

  • JsonEditor.tsx: Replaced Record<string, any> with Record<string, RangeWithSyntaxPart[]> and null | any with Record<string, unknown> | null
  • Code.tsx, GettingStarted.tsx, Layout.tsx: Fixed reduce() type issues with explicit type annotations

Type Safety Improvements:

  • Removed implicit 'any' in component props and internal state
  • Added proper typing for array operations (map, reduce, filter)
  • Implemented discriminated unions for polymorphic data structures

Does this PR introduce a breaking change?

No. Component interfaces remain backward compatible.

Checklist

  • Read, understood, and followed the contributing guidelines
  • TypeScript compilation: 0 errors
  • Linting passes with no warnings
  • Components maintain existing functionality

Copilot AI review requested due to automatic review settings December 7, 2025 03:41
@vtushar06 vtushar06 requested a review from a team as a code owner December 7, 2025 03:41
@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 d141e96

@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 (d141e96).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1974   +/-   ##
=========================================
  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.

@vtushar06 vtushar06 changed the title fix(components): Remove 'any' types from React components fix(components): Remove 'any' types from React components (#1034) Dec 7, 2025
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 removes 'any' type annotations from core React components and page files, replacing them with proper TypeScript types. The changes improve type safety across 4 main components (JsonEditor, Layout, GettingStarted, Code) and multiple page files that handle markdown content rendering.

Key changes:

  • Created a centralized types/common.ts file with shared type definitions (Frontmatter, Author, NavLink, etc.)
  • Replaced 'any' types in component props with specific types (Frontmatter, string, React.ReactNode)
  • Added explicit type annotations to array operations (reduce, map, find) in JsonEditor and GettingStarted
  • Improved event handler type safety in Layout component

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated no comments.

Show a summary per file
File Description
types/common.ts New centralized type definitions file with interfaces for Frontmatter, Author, NavLink, and other shared types
components/JsonEditor.tsx Comprehensive type safety improvements: added RenderLeafProps/RenderElementProps types, explicit reduce() type annotations, proper type guards for Descendant iteration, and Record<string, RangeWithSyntaxPart[]> for decoration maps
components/Layout.tsx Replaced 'any' with explicit store state type { overlayNavigation: string | null } and proper event.target casting to Node
components/GettingStarted.tsx Added inline type annotations for find() operations and proper SchemaOption/InstanceOption interfaces
components/Code.tsx Replaced 'any' with React.ReactNode for children prop
components/DocTable.tsx Made frontmatter properties optional and added proper type handling with conditional rendering for optional fields
pages/understanding-json-schema/reference/[slug].page.tsx Replaced 'any' types with Frontmatter and string, added Frontmatter import, changed || to ?? for null coalescing
pages/understanding-json-schema/index.page.tsx Simplified component props by removing unused frontmatter and content parameters, typed blocks as string[]
pages/understanding-json-schema/[slug].page.tsx Replaced 'any' types with Frontmatter and string, added Frontmatter import, used nullish coalescing operator
pages/specification/release-notes/index.page.tsx Added BlocksData interface, typed frontmatter as Frontmatter, added conditional rendering for optional blocks.body
pages/specification/migration/index.page.tsx Added BlocksData interface, typed frontmatter as Frontmatter, added conditional rendering for optional blocks.body
pages/specification/json-hyper-schema/index.page.tsx Added SpecificationFrontmatter and BlocksData interfaces, conditional rendering for optional frontmatter fields
pages/overview/sponsors/index.page.tsx Typed blocks prop as string[] instead of any[]
pages/overview/code-of-conduct/index.page.tsx Simplified component props to only include blocks: string[], removed unused parameters
pages/overview/[slug].page.tsx Replaced 'any' with Frontmatter and string, added optional chaining for navigation links
pages/learn/getting-started-step-by-step/index.page.tsx Simplified component props to blocks: string[]
pages/learn/[slug].page.tsx Replaced 'any' types with Frontmatter and string, used nullish coalescing
pages/implementers/index.page.tsx Typed blocks as string[] instead of any[]
pages/implementers/[slug].page.tsx Replaced 'any' types with Frontmatter and string
pages/draft/2020-12/index.page.tsx Added DraftFrontmatter and BlocksData interfaces extending base types
pages/draft/2020-12/[slug].page.tsx Replaced 'any' with Frontmatter and string types
pages/draft/2019-09/index.page.tsx Added DraftFrontmatter and BlocksData interfaces
pages/draft/2019-09/[slug].page.tsx Replaced 'any' with Frontmatter and string types
pages/draft-07/index.page.tsx Added DraftFrontmatter and BlocksData interfaces
pages/draft-07/[slug].page.tsx Replaced 'any' with Frontmatter and string types
pages/draft-06/index.page.tsx Added DraftFrontmatter and BlocksData interfaces
pages/draft-06/[slug].page.tsx Replaced 'any' with Frontmatter and string types
pages/draft-05/index.page.tsx Added DraftFrontmatter and BlocksData interfaces with required body field
pages/ambassadors/index.page.tsx Typed ambassadorData as string instead of any
pages/[slug].page.tsx Replaced 'any' with Frontmatter and string, used type import

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

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