Skip to content

fix: accept explicit undefined as default in number, confirm, editor#2182

Open
greymoth-jp wants to merge 1 commit into
SBoudrias:mainfrom
greymoth-jp:fix/default-undefined-prompts
Open

fix: accept explicit undefined as default in number, confirm, editor#2182
greymoth-jp wants to merge 1 commit into
SBoudrias:mainfrom
greymoth-jp:fix/default-undefined-prompts

Conversation

@greymoth-jp

Copy link
Copy Markdown

Summary

#2111 widened InputConfig['default'] to string | undefined so the option accepts an explicitly-undefined value under exactOptionalPropertyTypes: true (the inconsistency reported in #2110). The other prompts that expose a scalar default still declare it as a bare optional, so they reject an explicit undefined the way @inquirer/input did before #2111:

  • @inquirer/number: default?: number
  • @inquirer/confirm: default?: boolean
  • @inquirer/editor: default?: string

This applies the same widening to those three, so default: value type-checks when value is T | undefined. Each gets a test mirroring the one added in #2111.

The choice-based prompts (select, rawlist, search, expand) have the same gap on their default option. I kept this PR to the scalar-default prompts that match @inquirer/input, and am happy to follow up on the rest.

Test plan

  • yarn tsc
  • yarn vitest --run packages/number packages/confirm packages/editor
  • yarn oxlint / yarn eslint

Mirror of SBoudrias#2111 (input) for the remaining scalar-default prompts so the `default` option accepts an explicit `undefined` under exactOptionalPropertyTypes. Refs SBoudrias#2110.
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@c209ddc). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2182   +/-   ##
=======================================
  Coverage        ?   89.16%           
=======================================
  Files           ?       48           
  Lines           ?     2225           
  Branches        ?      586           
=======================================
  Hits            ?     1984           
  Misses          ?      232           
  Partials        ?        9           

☔ View full report in Codecov by Harness.
📢 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.

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