Skip to content

fix: add explicit types to resolve all implicit 'any' parameters#5277

Open
PPRAMANIK62 wants to merge 5 commits intoasyncapi:masterfrom
PPRAMANIK62:fix/implicit-any-types
Open

fix: add explicit types to resolve all implicit 'any' parameters#5277
PPRAMANIK62 wants to merge 5 commits intoasyncapi:masterfrom
PPRAMANIK62:fix/implicit-any-types

Conversation

@PPRAMANIK62
Copy link
Copy Markdown

@PPRAMANIK62 PPRAMANIK62 commented Mar 25, 2026

Add proper TypeScript type annotations to 27 callback parameters across components and pages that were implicitly inferred as 'any'. Also adds @types/json-schema to resolve the missing module declaration for json-schema in Visualizer.tsx.

Closes #5073

Description

  • Add proper TypeScript type annotations to 27 callback parameters across components and
    pages that were implicitly inferred as any
  • Add @types/json-schema dev dependency to resolve the missing module declaration in
    Visualizer.tsx
  • Zero implicit any errors remain (tsc --noEmit verified)

Summary by CodeRabbit

  • Refactor

    • Improved TypeScript annotations across the app; strengthens compile-time checks without changing runtime behavior or UI.
    • Minor internal cleanups to author list rendering and data handling to ensure safer typing (no visible changes).
  • Chores

    • Added development type definitions for JSON Schema to improve build-time validation and developer tooling.
    • No user-facing behavior or API changes.

Add proper TypeScript type annotations to 27 callback parameters across
components and pages that were implicitly inferred as 'any'. Also adds
@types/json-schema to resolve the missing module declaration for
json-schema in Visualizer.tsx.

Closes asyncapi#5073

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 25, 2026

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 83c5be7
🔍 Latest deploy log https://app.netlify.com/projects/asyncapi-website/deploys/69c41d72317c8f0008a0a6b3
😎 Deploy Preview https://deploy-preview-5277--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 25, 2026

📝 Walkthrough

Walkthrough

Applied explicit TypeScript parameter annotations across several components and one page to remove implicit any in callbacks (map, filter, sort, find). Added a dev dependency for JSON Schema typings. No runtime logic, control flow, or exported API signatures were changed.

Changes

Cohort / File(s) Summary
Component & Page Type Annotations
components/CaseStudyCard.tsx, components/FinancialSummary/BarChartComponent.tsx, components/FinancialSummary/Card.tsx, components/layout/BlogLayout.tsx, components/layout/Layout.tsx, components/navigation/BlogPostItem.tsx, components/newsroom/FeaturedBlogPost.tsx, components/newsroom/NewsroomBlogPosts.tsx, components/newsroom/NewsroomSection.tsx, pages/casestudies/[id].tsx
Added explicit TypeScript typings to callback parameters in map, filter, sort, and find callbacks (e.g., ICaseStudy, IBlogPost, IDoc, ExpensesLinkItem). These are type-only edits; JSX and runtime behavior remain unchanged.
Type Dependencies
package.json
Added @types/json-schema (^7.0.15) to devDependencies for JSON Schema typings.

Sequence Diagram(s)

(omitted — changes are type-only and do not introduce new multi-component control flow)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble at types with gentle paws,

Chasing implicit anys from codeous laws.
Annotations snug, the warnings take flight,
Hop — the types are tidy tonight. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The PR addresses the primary objective from #5073 by adding explicit type annotations to callback parameters across components. However, the specific mention of serve-definitions.test.ts in the issue is not covered in the changeset shown. Verify that serve-definitions.test.ts has been updated with explicit types for the 'req' parameter to fully satisfy issue #5073's requirements.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main objective: adding explicit types to resolve implicit 'any' parameters across the codebase.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving implicit 'any' types. The addition of @types/json-schema is necessary for TypeScript definitions, and all component updates add explicit type annotations to callback parameters.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@PPRAMANIK62 PPRAMANIK62 marked this pull request as draft March 25, 2026 16:58
The .map() returns (string | JSX.Element)[], so .reduce() params
must match that union type instead of React.ReactNode or string.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
components/newsroom/FeaturedBlogPost.tsx (1)

89-98: ⚠️ Potential issue | 🟠 Major

Type mismatch in reduce callback may cause incorrect rendering.

The .map() returns either a <span> JSX element (when author.link exists) or a string (author name). However, the .reduce() callback types prev and curr as string and calls .join('') on an array containing these values.

When prev or curr is a JSX element, calling .join('') will produce "[object Object]" instead of the author name, resulting in incorrect rendering.

🐛 Proposed fix to use React.ReactNode consistently
                       {post.authors
                         .map((author: IBlogPost['authors'][number], index: number) =>
                           author.link ? (
                             <span key={index} data-alt={author.name} rel='noreferrer'>
                               {author.name}
                             </span>
                           ) : (
                             author.name
                           )
                         )
-                        .reduce((prev: string, curr: string) => [prev, ' & ', curr].join(''))}
+                        .reduce((prev: React.ReactNode, curr: React.ReactNode) => [prev, ' & ', curr] as React.ReactNode[])}

This aligns with the pattern used in BlogLayout.tsx (line 70).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/newsroom/FeaturedBlogPost.tsx` around lines 89 - 98, The map
currently returns a mix of string and JSX (in FeaturedBlogPost.tsx mapping over
IBlogPost['authors']) but the reduce types both as string and uses .join(''),
causing "[object Object]" for JSX nodes; change the pipeline to treat items as
React.ReactNode (update the map's return type) and rewrite the reduce callback
to operate on React.ReactNode (e.g., reduce<React.ReactNode>((prev, curr, i) =>
i ? <>{prev} & {curr}</> : curr)) so separators are inserted as React nodes
instead of calling .join on an array; update type annotations for the map/reduce
callbacks to React.ReactNode and adjust the reduce initial/value handling
accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@components/newsroom/FeaturedBlogPost.tsx`:
- Around line 89-98: The map currently returns a mix of string and JSX (in
FeaturedBlogPost.tsx mapping over IBlogPost['authors']) but the reduce types
both as string and uses .join(''), causing "[object Object]" for JSX nodes;
change the pipeline to treat items as React.ReactNode (update the map's return
type) and rewrite the reduce callback to operate on React.ReactNode (e.g.,
reduce<React.ReactNode>((prev, curr, i) => i ? <>{prev} & {curr}</> : curr)) so
separators are inserted as React nodes instead of calling .join on an array;
update type annotations for the map/reduce callbacks to React.ReactNode and
adjust the reduce initial/value handling accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1d86da5f-0172-445b-83d1-2b345ad93792

📥 Commits

Reviewing files that changed from the base of the PR and between 867b4b1 and 9b5c231.

📒 Files selected for processing (11)
  • components/CaseStudyCard.tsx
  • components/FinancialSummary/BarChartComponent.tsx
  • components/FinancialSummary/Card.tsx
  • components/layout/BlogLayout.tsx
  • components/layout/Layout.tsx
  • components/navigation/BlogPostItem.tsx
  • components/newsroom/FeaturedBlogPost.tsx
  • components/newsroom/NewsroomBlogPosts.tsx
  • components/newsroom/NewsroomSection.tsx
  • package.json
  • pages/casestudies/[id].tsx

@PPRAMANIK62 PPRAMANIK62 marked this pull request as ready for review March 25, 2026 17:05
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@components/layout/BlogLayout.tsx`:
- Line 70: In BlogLayout replace the unsafe .reduce(...) on post.authors (which
uses the cast as unknown as string & React.JSX.Element and breaks on empty
arrays) with a safe map rendering: check post.authors.length first, then map
authors to elements and insert separators conditionally using the index (e.g.,
authors.map((a, i) => <>{i>0 && " • "}{...}</>)), and eliminate the unsafe cast;
also remove nested <a> tags by following the BlogPostItem/FeaturedBlogPost
pattern — render author names as non-interactive <span> or as <button
onClick={() => window.open(url, "_blank")}> when an interactive element is
required (use onClick instead of nested anchors) so hydration and type-safety
issues are resolved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 78aecd7f-921e-470c-aa6e-dd8fbb433cb0

📥 Commits

Reviewing files that changed from the base of the PR and between 9b5c231 and 4994ef8.

📒 Files selected for processing (2)
  • components/layout/BlogLayout.tsx
  • components/newsroom/FeaturedBlogPost.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/newsroom/FeaturedBlogPost.tsx

Replace fragile .reduce() pattern with .map() + React.Fragment for
joining author names. The reduce approach had unsafe type casts and
would throw on empty arrays. The map approach is type-safe, handles
empty arrays, and produces the same visual output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@components/newsroom/FeaturedBlogPost.tsx`:
- Around line 88-99: In FeaturedBlogPost.tsx, remove the invalid
rel='noreferrer' attribute from the <span> used inside the post.authors.map(...)
fragment (the JSX returning <span data-alt={author.name} rel='noreferrer'>)
since rel is only valid on <a>/<link>/<area>; keep data-alt and the conditional
rendering logic intact and ensure the key remains on the React.Fragment for
index-based mapping.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bc983c10-4481-440e-aa7b-fdadad74b300

📥 Commits

Reviewing files that changed from the base of the PR and between 4994ef8 and 4705da7.

📒 Files selected for processing (2)
  • components/layout/BlogLayout.tsx
  • components/newsroom/FeaturedBlogPost.tsx

@PPRAMANIK62 PPRAMANIK62 marked this pull request as draft March 25, 2026 17:27
- Remove invalid rel='noreferrer' from <span> in FeaturedBlogPost
- Replace unsafe .reduce() with .map() + React.Fragment in BlogPostItem
  for consistency and empty-array safety

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@PPRAMANIK62 PPRAMANIK62 marked this pull request as ready for review March 25, 2026 17:41
@asyncapi-bot
Copy link
Copy Markdown
Contributor

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 48
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-5277--asyncapi-website.netlify.app/

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
components/newsroom/FeaturedBlogPost.tsx (1)

88-99: Type annotations and refactor look good; verify author link behavior is intentional.

The explicit type annotations and the refactor from .reduce() to .map() with React.Fragment are correct. The removal of the invalid rel='noreferrer' attribute from the <span> (flagged in a previous review) has been addressed.

The index-as-key usage is acceptable here for the same reasons as in BlogPostItem.tsx (static, small list without stable unique IDs).

One observation: unlike BlogPostItem.tsx which uses a <button> with onClick to open author links, this component renders a plain <span> when author.link is truthy, making the author name non-clickable. If this is intentional (to avoid hydration issues as per learnings), the author.link conditional and data-alt attribute appear to be remnants with no functional purpose.

Based on learnings, using anchor tags for author names in this component leads to hydration issues, so the non-interactive approach may be intentional—but then consider removing the conditional check for author.link entirely to simplify the code.

,

♻️ Optional simplification if author links are intentionally non-interactive
                      {post.authors.map((author: IBlogPost['authors'][number], index: number) => (
                        <React.Fragment key={index}>
                          {index > 0 && ' & '}
-                          {author.link ? (
-                            <span data-alt={author.name}>
-                              {author.name}
-                            </span>
-                          ) : (
-                            author.name
-                          )}
+                          {author.name}
                        </React.Fragment>
                      ))}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/newsroom/FeaturedBlogPost.tsx` around lines 88 - 99, In
FeaturedBlogPost, the conditional branch around post.authors.map that checks
author.link and renders a <span data-alt=...> leaves a non-functional check and
a redundant data-alt when author links are intentionally non-interactive;
simplify by removing the author.link conditional and data-alt so you always
render the author name inside the React.Fragment (keep the existing
React.Fragment key usage and the ' & ' separator), or if you actually want
clickable authors, replace the span with the same clickable <button> + onClick
behavior used in BlogPostItem to open author.link—update the mapping in
FeaturedBlogPost (post.authors, React.Fragment, and any data-alt usage)
accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@components/newsroom/FeaturedBlogPost.tsx`:
- Around line 88-99: In FeaturedBlogPost, the conditional branch around
post.authors.map that checks author.link and renders a <span data-alt=...>
leaves a non-functional check and a redundant data-alt when author links are
intentionally non-interactive; simplify by removing the author.link conditional
and data-alt so you always render the author name inside the React.Fragment
(keep the existing React.Fragment key usage and the ' & ' separator), or if you
actually want clickable authors, replace the span with the same clickable
<button> + onClick behavior used in BlogPostItem to open author.link—update the
mapping in FeaturedBlogPost (post.authors, React.Fragment, and any data-alt
usage) accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 19ae6df0-4f13-4424-b7d1-3cc360598634

📥 Commits

Reviewing files that changed from the base of the PR and between 4705da7 and 83c5be7.

📒 Files selected for processing (2)
  • components/navigation/BlogPostItem.tsx
  • components/newsroom/FeaturedBlogPost.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Be Triaged

Development

Successfully merging this pull request may close these issues.

[BUG] :fix implicit 'any' type for 'req' in serve-definitions tests

2 participants