Skip to content

fix: missing closing quote in generated import#2688

Merged
posva merged 2 commits into
vuejs:mainfrom
zjy040525:fix/missing-closing-quote
Apr 22, 2026
Merged

fix: missing closing quote in generated import#2688
posva merged 2 commits into
vuejs:mainfrom
zjy040525:fix/missing-closing-quote

Conversation

@zjy040525

@zjy040525 zjy040525 commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Closes #2687

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a syntax issue in generated TypeScript declaration imports so generated type files compile correctly.
  • Tests
    • Added a unit test validating the generation of TypeScript declaration output, including header, imports, and exported type shapes.

Copilot AI review requested due to automatic review settings April 22, 2026 09:33
@netlify

netlify Bot commented Apr 22, 2026

Copy link
Copy Markdown

Deploy Preview for vue-router canceled.

Name Link
🔨 Latest commit 6948641
🔍 Latest deploy log https://app.netlify.com/projects/vue-router/deploys/69e89f91bdd21000080f1560

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes a malformed import emitted by the DTS code generator that could break builds when a generated *.d.ts file is present (per #2687).

Changes:

  • Fix the missing closing quote in the generated import type { ... } from 'vue-router/experimental' statement.
  • Update the committed playground-generated routes.d.ts to reflect the corrected output.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/router/src/unplugin/codegen/generateDTS.ts Fixes the template output so the generated experimental import path is properly quoted.
packages/playground-file-based/src/routes.d.ts Updates the generated DTS artifact to match the corrected generator output.

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

Comment on lines 48 to +50
import type {
_ExtractParamParserType,
} from 'vue-router/experimental
} from 'vue-router/experimental'
@coderabbitai

coderabbitai Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Two malformed type-only import statements referencing 'vue-router/experimental' are fixed (closing quote added) and a new Vitest spec validating the DTS generator output is added. No public API or exported type declarations were changed.

Changes

Cohort / File(s) Summary
Import syntax fixes
packages/playground-file-based/src/routes.d.ts, packages/router/src/unplugin/codegen/generateDTS.ts
Fixed unterminated type-only import by adding the missing closing quote in the 'vue-router/experimental' module specifier.
Test added
packages/router/src/unplugin/codegen/generateDTS.spec.ts
Added a Vitest spec that constructs inputs for generateDTS and asserts the generated DTS string matches an inline snapshot.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through lines both short and sweet,
Found a quote that missed its seat.
I nudged it home, then wrote a test,
Now generated DTS can rest. ✨

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely summarizes the main fix: a missing closing quote in a generated import statement that caused build failures.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issue #2687: fixing the missing closing quote in the generated import statement and adding a snapshot test to prevent future regressions.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the closing quote bug: correcting the import in two locations and adding a test to prevent regression. No unrelated changes detected.

✏️ 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.

Covers the full DTS output so template-string regressions like the missing
closing quote on the `from 'vue-router/experimental'` import fail the snapshot.

@posva posva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! I will add a regression test and publish fast

@pkg-pr-new

pkg-pr-new Bot commented Apr 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 6948641

@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.

🧹 Nitpick comments (1)
packages/router/src/unplugin/codegen/generateDTS.spec.ts (1)

5-75: Consider adding a case with non-empty param parsers.

This snapshot nicely guards against the missing-quote regression on the 'vue-router/experimental' import. As a follow-up, consider an additional it(...) exercising a non-empty paramsTypesDeclaration and customParamsTypeList so the TypesConfig.ParamParsers branch and the "Custom route params parsers" block are also snapshot-protected — right now lines 37-39 show an empty ParamParsers: followed by a blank line, which isn't a very meaningful assertion for that code path.

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

In `@packages/router/src/unplugin/codegen/generateDTS.spec.ts` around lines 5 -
75, The current test only covers the empty params case; add a second it(...) in
generateDTS.spec.ts that calls generateDTS with a non-empty
paramsTypesDeclaration and a non-empty customParamsTypeList so the
TypesConfig.ParamParsers branch and the "Custom route params parsers" block are
exercised; specifically, call generateDTS with paramsTypesDeclaration set to a
small type declaration string and customParamsTypeList containing at least one
entry, then snapshot the output to ensure the generated TypesConfig.ParamParsers
and the custom parsers section are present and correctly formatted (this targets
the generateDTS function and its handling of paramsTypesDeclaration and
customParamsTypeList).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/router/src/unplugin/codegen/generateDTS.spec.ts`:
- Around line 5-75: The current test only covers the empty params case; add a
second it(...) in generateDTS.spec.ts that calls generateDTS with a non-empty
paramsTypesDeclaration and a non-empty customParamsTypeList so the
TypesConfig.ParamParsers branch and the "Custom route params parsers" block are
exercised; specifically, call generateDTS with paramsTypesDeclaration set to a
small type declaration string and customParamsTypeList containing at least one
entry, then snapshot the output to ensure the generated TypesConfig.ParamParsers
and the custom parsers section are present and correctly formatted (this targets
the generateDTS function and its handling of paramsTypesDeclaration and
customParamsTypeList).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9b505b06-5061-4a05-8e60-219a3de32c5b

📥 Commits

Reviewing files that changed from the base of the PR and between fda46b3 and 6948641.

📒 Files selected for processing (1)
  • packages/router/src/unplugin/codegen/generateDTS.spec.ts

@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.91%. Comparing base (7a41931) to head (6948641).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2688      +/-   ##
==========================================
+ Coverage   85.65%   85.91%   +0.26%     
==========================================
  Files          88       88              
  Lines       10071    10071              
  Branches     2307     2311       +4     
==========================================
+ Hits         8626     8653      +27     
+ Misses       1433     1407      -26     
+ Partials       12       11       -1     

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

@posva posva merged commit 32f78c7 into vuejs:main Apr 22, 2026
10 checks passed
@zjy040525 zjy040525 deleted the fix/missing-closing-quote branch April 23, 2026 01:50
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.

Build fails in version 5.0.5

3 participants