Skip to content

feat(type): support type only default and namespace import/export - #139

Open
Gehbt wants to merge 1 commit into
unjs:mainfrom
Gehbt:feat-1
Open

Gehbt wants to merge 1 commit into
unjs:mainfrom
Gehbt:feat-1

Conversation

@Gehbt

@Gehbt Gehbt commented May 12, 2026

Copy link
Copy Markdown

relate #65

This PR only change parameter type definition and add test suites.

Summary by CodeRabbit

  • New Features

    • Expanded type import and export capabilities to support wildcard imports with optional aliasing for greater flexibility.
  • Tests

    • Added comprehensive test coverage for wildcard import and export scenarios.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Type signatures for genTypeImport and genTypeExport are broadened to accept wildcard forms ("*") and simplified object structures alongside the existing ESMImport[], enabling direct string type names and wildcard import/export patterns. Tests validate the new input types.

Changes

ESM Wildcard Import/Export Forms

Layer / File(s) Summary
Type signature updates for wildcard support
src/esm.ts, src/typescript.ts
genTypeImport and genTypeExport parameter types are widened to accept string, { name: "*"; as?: string }, and related object forms in addition to the existing ESMImport[].
Test coverage for wildcard import/export forms
test/typescript.test.ts
Test suites expanded with cases validating import type and export type generation for wildcard forms, direct string types, and aliased wildcard imports.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A wildcard's dance, both wide and free,
import * and export * in harmony,
Type signatures stretched with gentle care,
Tests confirm the aliases play fair!
🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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: expanding genTypeImport and genTypeExport to support type-only default and namespace imports/exports by broadening their imports parameter types.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/esm.ts (1)

78-78: 💤 Low value

Consider simplifying the type union to reduce redundancy.

The type union includes string and { name: string }, which overlap with ESMImport (defined as string | { name: string; as?: string }). While this works correctly, it could be simplified to:

imports: ESMImport | { name: "*"; as: string } | ESMImport[]

This would capture all the intended input forms while reducing type overlap.

🤖 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/esm.ts` at line 78, The parameter type for imports is overly redundant;
replace the union "imports: string | { name: '*'; as: string } | { name: string
} | ESMImport[]" with a simplified union that uses the existing ESMImport type
plus the special-star-case, i.e., "imports: ESMImport | { name: '*'; as: string
} | ESMImport[]", so references to ESMImport (and the special `{ name: '*' }`
case) cover the duplicate `string` and `{ name: string }` entries; update the
type annotation where `imports` is declared (the `imports` parameter/field in
src/esm.ts) accordingly.
🤖 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.

Nitpick comments:
In `@src/esm.ts`:
- Line 78: The parameter type for imports is overly redundant; replace the union
"imports: string | { name: '*'; as: string } | { name: string } | ESMImport[]"
with a simplified union that uses the existing ESMImport type plus the
special-star-case, i.e., "imports: ESMImport | { name: '*'; as: string } |
ESMImport[]", so references to ESMImport (and the special `{ name: '*' }` case)
cover the duplicate `string` and `{ name: string }` entries; update the type
annotation where `imports` is declared (the `imports` parameter/field in
src/esm.ts) accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 039eab6f-267f-41ba-b593-3e2e1bf67fae

📥 Commits

Reviewing files that changed from the base of the PR and between a95f4d4 and eb0c03d.

📒 Files selected for processing (3)
  • src/esm.ts
  • src/typescript.ts
  • test/typescript.test.ts

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.

1 participant