Skip to content

fix: adjust StaticImport to correctly mark imports as optional#350

Open
kyleMessnerLillyContractor wants to merge 1 commit into
unjs:mainfrom
kyleMessnerLillyContractor:main
Open

fix: adjust StaticImport to correctly mark imports as optional#350
kyleMessnerLillyContractor wants to merge 1 commit into
unjs:mainfrom
kyleMessnerLillyContractor:main

Conversation

@kyleMessnerLillyContractor

@kyleMessnerLillyContractor kyleMessnerLillyContractor commented May 21, 2026

Copy link
Copy Markdown

resolves #349

Summary by CodeRabbit

  • Refactor
    • Made imports optional in import-handling functions and related interfaces to improve flexibility in handling edge cases where imports may not be explicitly provided.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ce541196-2e44-4141-8760-a0c67a89e513

📥 Commits

Reviewing files that changed from the base of the PR and between beece9b and 0be05c8.

📒 Files selected for processing (2)
  • src/_utils.ts
  • src/analyze.ts

📝 Walkthrough

Walkthrough

The PR makes the imports field optional in the StaticImport interface and updates the clearImports utility function signature to accept an optional imports parameter, allowing side-effect imports (like import "styles.css") to correctly type as having an undefined imports property.

Changes

Optional imports field

Layer / File(s) Summary
Optional imports field
src/analyze.ts, src/_utils.ts
StaticImport.imports changes from required string to optional imports?: string, and clearImports function parameter becomes optional to handle side-effect imports without an imports property.

🎯 1 (Trivial) | ⏱️ ~2 minutes

🐰 A rabbit hops through types with glee,
Side-effects need no imports to be,
Optional fields now ring so true,
The schema and utils both see it through!

🚥 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 accurately describes the main change: making the imports property optional in StaticImport to match actual runtime behavior.
Linked Issues check ✅ Passed The changes directly address issue #349 by marking the imports property as optional in both StaticImport interface and clearImports function signature.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the type mismatch for optional imports; no unrelated modifications are present.

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

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.

The StaticImport['imports'] type is incorrect

1 participant