Visitar URL original
fix(core): createConfigItem allows cb as 2nd arg by JLHwung 路 Pull Request #18254 路 babel/babel 路 GitHub
Skip to content

fix(core): createConfigItem allows cb as 2nd arg - #18254

Merged
JLHwung merged 3 commits into
babel:mainfrom
JLHwung:fix-create-config-item-callback
Sep 29, 2026
Merged

JLHwung merged 3 commits into
babel:mainfrom
JLHwung:fix-create-config-item-callback

Conversation

@JLHwung

@JLHwung JLHwung commented Sep 27, 2026

Copy link
Copy Markdown
Contributor
Q 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 A
Fixed Issues? Fixes #18249 (comment)
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This issue is reported by Copilot code review. Currently, createConfigItem(plugin, cb) will throw

Error: Asynchronous function called without callback

The current behaviour was introduced since day 1 of the createConfigItem function (#12852). No one has reported since then but I believe this is still a bug and the new behaviour aligns to expectations of other Babel/core APIs.

@JLHwung JLHwung added PR: Bug Fix 馃悰 A type of pull request used for our changelog categories pkg: core labels Sep 27, 2026
@JLHwung
JLHwung requested a balanced review from Copilot September 27, 2026 14:35
@babel-bot

babel-bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/62193

Copilot AI 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.

Copilot review overview

馃煛 Changes recommended

The exported TypeScript signature still rejects the newly supported callback-only form.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes the callback-only overload of createConfigItem.

Changes:

  • Passes the second argument as the callback.
  • Adds regression coverage for this invocation form.
File Description
packages/鈥媌abel-core/鈥媠rc/鈥媍onfig/鈥媔ndex.ts Corrects callback forwarding.
packages/鈥媌abel-core/鈥媡est/鈥媍onfig-loading.js Tests the callback-only form.

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/babel-core/src/config/index.ts Outdated
@pkg-pr-new

pkg-pr-new Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

commit: 27b697e

Copilot AI 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.

Copilot review overview

馃煛 Changes recommended

The callback type excludes the undefined success sentinel observed at runtime.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread packages/babel-core/src/config/index.ts

Copilot AI 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.

Copilot review overview

馃煛 Changes recommended

The callback declaration contradicts its runtime success arguments, making the public API type unsound.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread packages/babel-core/src/config/index.ts Outdated
@JLHwung
JLHwung force-pushed the fix-create-config-item-callback branch from 1e371b9 to 92ea7f0 Compare September 27, 2026 18:39
@JLHwung
JLHwung requested a balanced review from Copilot September 27, 2026 18:39

Copilot AI 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.

Copilot review overview

馃煝 Approval recommended

The implementation correctly fixes the reported overload bug with adequate runtime and type coverage.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@JLHwung
JLHwung force-pushed the fix-create-config-item-callback branch from 92ea7f0 to 27b697e Compare September 28, 2026 18:40
@JLHwung
JLHwung merged commit d23b2fd into babel:main Sep 29, 2026
102 of 104 checks passed
@JLHwung
JLHwung deleted the fix-create-config-item-callback branch September 29, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: core PR: Bug Fix 馃悰 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants