Skip to content

fix: restore InferStructuralSharing and handleHashScroll in published .d.ts files - #5134

Merged
Sheraff merged 1 commit into
TanStack:mainfrom
vedant416:vedant/fix-published-exports
Sep 15, 2025
Merged

fix: restore InferStructuralSharing and handleHashScroll in published .d.ts files#5134
Sheraff merged 1 commit into
TanStack:mainfrom
vedant416:vedant/fix-published-exports

Conversation

@vedant416

@vedant416 vedant416 commented Sep 11, 2025

Copy link
Copy Markdown
Contributor

Fixes #5116

Root Cause

In PR #4907, the TypeScript compiler option stripInternal was enabled in tsconfig.json, which causes TypeScript to remove any declarations marked with @internal from the published .d.ts files.

This resulted in TypeScript compilation errors for library users who have set the TypeScript compiler option skipLibCheck to false, because the following members were missing:

  • InferStructuralSharing type in react-router
  • handleHashScroll function in router-core > scrollRestoration

Fix

  • This PR replaces the @internal annotation with the @private annotation.

Summary by CodeRabbit

  • Documentation
    • Updated internal API annotations in routing packages to mark certain items as private, improving the accuracy of generated developer documentation.
    • No changes to public APIs, behavior, or performance.
    • No user-facing impact.

@coderabbitai

coderabbitai Bot commented Sep 11, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Documentation annotations were updated from @internal to @Private in two TypeScript files. No code, types, signatures, or control flow changed. The updates affect visibility in generated docs only and address missing published type metadata without altering runtime or type behavior.

Changes

Cohort / File(s) Summary
Docs visibility annotations
packages/react-router/src/typePrimitives.ts, packages/router-core/src/scroll-restoration.ts
Switched JSDoc tags from @internal to @Private above InferStructuralSharing<TOptions> and handleHashScroll; no functional or type-signature changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Pre-merge checks (4 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately describes the primary change — restoring the missing InferStructuralSharing and handleHashScroll declarations in published .d.ts files — and directly reflects the modifications in the changeset without extraneous detail.
Linked Issues Check ✅ Passed The PR directly addresses issue #5116 by replacing @internal with @Private for InferStructuralSharing (react-router) and handleHashScroll (router-core), which preserves those declarations in published .d.ts files, and the raw_summary confirms only JSDoc visibility annotations changed with no signature or runtime modifications.
Out of Scope Changes Check ✅ Passed No out-of-scope changes were detected: both modified files only update JSDoc tags from @internal to @Private and the raw_summary indicates no other edits to signatures or behavior, which aligns with the PR objectives.

Poem

I thump my paw at docs so fine,
A subtle tag, a tidy line.
No scrolls unmoved, no types askew—
Just “private” signs to guide us through.
In clover fields of exports bright,
We publish what’s meant for sight.
Hop hop—ship it, crisp and light!

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/router-core/src/scroll-restoration.ts (1)

311-314: Throttle handler capture: avoid creating a new throttled function on each setup.

Minor: storing the throttled listener in a const avoids accidental multiple registrations with different closures if setupScrollRestoration is called again.

-  if (typeof document !== 'undefined') {
-    document.addEventListener('scroll', throttle(onScroll, 100), true)
-  }
+  if (typeof document !== 'undefined') {
+    const onScrollThrottled = throttle(onScroll, 100)
+    document.addEventListener('scroll', onScrollThrottled, true)
+    // Consider returning a disposer to remove the listener on teardown.
+  }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a600223 and b495d1a.

📒 Files selected for processing (2)
  • packages/react-router/src/typePrimitives.ts (1 hunks)
  • packages/router-core/src/scroll-restoration.ts (1 hunks)
🔇 Additional comments (4)
packages/router-core/src/scroll-restoration.ts (2)

349-355: Switching @internal@Private correctly prevents stripInternal from removing this export.

Good call—TypeScript only strips @internal, so @private preserves the declaration in published .d.ts files without changing runtime behavior.


361-364: No change needed — router.state.location.hash is already normalized (no leading '#')

router.parseLocation normalizes HistoryLocation.hash with hash.split('#').reverse()[0] (packages/router-core/src/router.ts), and restoreScroll already strips window.location.hash; handleHashScroll uses the parsed location.hash (no leading '#'), so the suggested change is unnecessary.

Likely an incorrect or invalid review comment.

packages/react-router/src/typePrimitives.ts (2)

34-36: @internal@Private restores InferStructuralSharing in published .d.ts.

This aligns with stripInternal: true while keeping the type available to consumers. No API or type changes—LGTM.


34-41: Add CI guard to ensure exported types are present in published .d.ts

Fail CI if key exports are missing after pnpm -w build. Location: packages/react-router/src/typePrimitives.ts (lines 34–41).

#!/bin/bash
set -euo pipefail
pnpm -w build

# ensure .d.ts files exist
if ! find . -type f -name '*.d.ts' -not -path './node_modules/*' -print -quit | grep -q .; then
  echo "No .d.ts files found after build"
  exit 1
fi

# verify exported symbols are present in built d.ts
if ! find . -type f -name '*.d.ts' -not -path './node_modules/*' -exec grep -En "export[^;]*InferStructuralSharing" {} + >/dev/null 2>&1; then
  echo "InferStructuralSharing missing in published d.ts"
  exit 1
fi

if ! find . -type f -name '*.d.ts' -not -path './node_modules/*' -exec grep -En "export[^;]*handleHashScroll" {} + >/dev/null 2>&1; then
  echo "handleHashScroll missing in published d.ts"
  exit 1
fi

# catch accidental @internal annotations in source
if find packages/router-core/src packages/react-router/src -type f -exec grep -En '@internal' {} + >/dev/null 2>&1; then
  echo "Found @internal in source; ensure stripInternal is enabled for the build"
  exit 1
fi

@nx-cloud

nx-cloud Bot commented Sep 15, 2025

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit b495d1a

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 5m 10s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 34s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-15 10:43:16 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 15, 2025

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5134

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5134

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5134

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5134

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5134

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5134

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5134

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5134

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5134

@tanstack/react-start-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-plugin@5134

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5134

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5134

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5134

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5134

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5134

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5134

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5134

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5134

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5134

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5134

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5134

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5134

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5134

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5134

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5134

@tanstack/solid-start-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-plugin@5134

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5134

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5134

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5134

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5134

@tanstack/start-server-functions-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-client@5134

@tanstack/start-server-functions-fetcher

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-fetcher@5134

@tanstack/start-server-functions-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-server@5134

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5134

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5134

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5134

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5134

commit: b495d1a

@Sheraff

Sheraff commented Sep 15, 2025

Copy link
Copy Markdown
Collaborator

@vedant416 out of curiosity, what is your use-case for skipLibCheck: false?

@Sheraff
Sheraff merged commit bfc466f into TanStack:main Sep 15, 2025
6 checks passed
@vedant416

Copy link
Copy Markdown
Contributor Author

@vedant416 out of curiosity, what is your use-case for skipLibCheck: false?

@Sheraff the original reporter of issue #5116, @perbergland, might be able to share more about their use case.
For reference, the skipLibCheck: false is default compiler option (see TS docs), so I think it was a good catch by @perbergland.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InferStructuralSharing missing in published types (esm/cjs)

2 participants