Skip to content

fix(types): only strip extensions that ts retries#4297

Merged
pi0 merged 1 commit into
mainfrom
fix/tsconfig-paths
Jun 1, 2026
Merged

fix(types): only strip extensions that ts retries#4297
pi0 merged 1 commit into
mainfrom
fix/tsconfig-paths

Conversation

@danielroe
Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

spotted this when testing nuxt v5. this also needs to be fixed in nuxt, and is very weird. I was not aware of this behaviour, but here's what it looks like:

https://stackblitz.com/edit/node-4mtandbr?file=tsconfig.json,index.ts

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe requested a review from pi0 as a code owner May 31, 2026 19:14
@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nitro.build Ready Ready Preview, Comment May 31, 2026 7:14pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors path extension normalization in src/build/types.ts by extracting an inline regex replacement into a dedicated utility function. The new stripPathsExt helper removes only TypeScript and JavaScript extensions, and is integrated into the tsConfig paths builder where extension stripping is already conditional on detecting existing files.

Changes

Path Extension Stripping Refactoring

Layer / File(s) Summary
Strip paths extension utility definition
src/build/types.ts
Defines PATHS_STRIPPABLE_EXT_RE constant to match .ts/.tsx/.js/.mjs/.cjs extensions and exports stripPathsExt(path: string) function to remove those extensions from paths.
Integrate path extension stripping in tsConfig paths normalization
src/build/types.ts
The existing-file normalization branch in writeTypes calls stripPathsExt instead of using an inline regex to strip extensions from tsConfig.compilerOptions.paths entries.

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title follows conventional commits format with 'fix' type, scope 'types', and a clear description of the change.
Description check ✅ Passed The description is related to the changeset, explaining the bug fix and providing context about the issue discovered during Nuxt v5 testing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tsconfig-paths

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.

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

🧹 Nitpick comments (1)
src/build/types.ts (1)

1-292: 💤 Low value

Consider future refactoring to reduce file length.

The file is now 292 lines, which exceeds the 200 LoC guideline. While this PR only adds 7 lines to an existing file, consider splitting this module in a future refactor to improve maintainability.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/build/types.ts` around lines 1 - 292, The file exceeds the 200 LoC
guideline and should be split for maintainability; extract logical parts into
separate modules (for example move type-file generation helpers and TS config
logic into new modules) by splitting responsibilities around writeTypes (keep
core orchestration here), move helper utilities relativeWithDot and
stripPathsExt into a small utils/types.ts, and relocate TS config building (the
tsConfig construction and related path normalization loop) into a separate
buildTsConfig function in a new module that writeTypes imports and calls; ensure
exported symbols and imports are updated so writeTypes, relativeWithDot, and
stripPathsExt references resolve correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/build/types.ts`:
- Around line 286-288: The PATHS_STRIPPABLE_EXT_RE constant currently misses
.mts and .cts and should be updated so module resolution strips those too;
update the regex assigned to PATHS_STRIPPABLE_EXT_RE to include mts and cts
alongside ts/tsx/jsx/[cm]js (so it matches .ts .tsx .mts .cts .jsx .cjs .mjs) so
path normalization behaves like TypeScript's moduleNameResolver retry logic.

---

Nitpick comments:
In `@src/build/types.ts`:
- Around line 1-292: The file exceeds the 200 LoC guideline and should be split
for maintainability; extract logical parts into separate modules (for example
move type-file generation helpers and TS config logic into new modules) by
splitting responsibilities around writeTypes (keep core orchestration here),
move helper utilities relativeWithDot and stripPathsExt into a small
utils/types.ts, and relocate TS config building (the tsConfig construction and
related path normalization loop) into a separate buildTsConfig function in a new
module that writeTypes imports and calls; ensure exported symbols and imports
are updated so writeTypes, relativeWithDot, and stripPathsExt references resolve
correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9afa4acb-2a27-4aa0-ae14-3047a2fe0218

📥 Commits

Reviewing files that changed from the base of the PR and between 255b254 and 054222c.

📒 Files selected for processing (1)
  • src/build/types.ts

Comment thread src/build/types.ts
@pi0 pi0 merged commit 3c588dc into main Jun 1, 2026
12 checks passed
@pi0 pi0 deleted the fix/tsconfig-paths branch June 1, 2026 11:04
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