Skip to content

fix(volar): use ts.idText() instead of .text in sfc-typed-router#2607

Merged
posva merged 1 commit intovuejs:mainfrom
peter50216:patch-1
Jan 30, 2026
Merged

fix(volar): use ts.idText() instead of .text in sfc-typed-router#2607
posva merged 1 commit intovuejs:mainfrom
peter50216:patch-1

Conversation

@peter50216
Copy link
Contributor

@peter50216 peter50216 commented Jan 30, 2026

The sfc-typed-router Volar plugin fails to transform useRoute() calls when used with vue-tsc because it uses node.expression.text to check for the identifier name.

The .text getter only exists on IdentifierObject (TypeScript Language Service nodes), but Volar uses ts.createSourceFile() which produces raw Compiler API nodes that only have .escapedText.

Use ts.idText(node.expression) which works with both node types.

Summary by CodeRabbit

  • Refactor
    • Improved robustness of router type-checking mechanisms by enhancing identifier resolution logic.

✏️ Tip: You can customize this high-level summary in your review settings.

@netlify
Copy link

netlify bot commented Jan 30, 2026

Deploy Preview for vue-router canceled.

Name Link
🔨 Latest commit eb9da31
🔍 Latest deploy log https://app.netlify.com/projects/vue-router/deploys/697c3520b5f6710008aeb033

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

A minor refactoring in the router's Volar entry point replaces direct property access with the TypeScript API's ts.idText() method to retrieve an identifier name for a no-argument useRoute call check.

Changes

Cohort / File(s) Summary
TypeScript API Enhancement
packages/router/src/volar/entries/sfc-typed-router.ts
Replaced node.expression.text with ts.idText(node.expression) for more robust identifier retrieval using the TypeScript API.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hop and a bound through the TypeScript code,
We danced with the API down the refactored road,
No longer direct, but through proper calls we go,
ts.idText() shines—our robustness will grow!

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: replacing .text with ts.idText() in the sfc-typed-router plugin, which is the exact fix implemented.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 30, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vue-router@2607

commit: eb9da31

@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.26%. Comparing base (20c018b) to head (eb9da31).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2607   +/-   ##
=======================================
  Coverage   85.26%   85.26%           
=======================================
  Files          84       84           
  Lines        9774     9774           
  Branches     2218     2218           
=======================================
  Hits         8334     8334           
  Misses       1428     1428           
  Partials       12       12           

☔ 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
Member

@posva posva left a comment

Choose a reason for hiding this comment

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

Nice, thanks a lot! This fixes vue-tsc usage

@posva posva merged commit 7845e32 into vuejs:main Jan 30, 2026
9 checks passed
This was referenced Jan 30, 2026
This was referenced Feb 12, 2026
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