Skip to content

[Bug] SelectPrompt throws a TypeError when given an empty options array #144

Open
@kevduc

Description

@kevduc

Environment

  • OS: Windows
  • Node Version: v16.16.0
  • Package: @clack/core (depended on by @sentry/wizard@3.9.2)
  • Package Version: v0.3.2

Describe the bug
SelectPrompt throws a TypeError when given an empty options array.
Encountered when using @sentry/wizard@3.9.2, see the related issue: getsentry/sentry-wizard#400

Example:

TypeError: Cannot read properties of undefined (reading 'value')
    at SelectPrompt.changeValue (C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@clack\core\dist\index.cjs:14:3567)
    at new SelectPrompt (C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@clack\core\dist\index.cjs:14:3235)

To Reproduce
https://stackblitz.com/edit/node-kyd3oq?file=index.ts

Pass an empty array for options when creating a new SelectPrompt

Expected behavior
SelectPrompt (and select from @clack/prompts) should require at least 1 element in the array (it doesn't make sense to have no options to select from)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions