Skip to content

[Bug]: Type error when using group select w/out initial value #126

Description

@rschristian

Environment

  • OS: Linux
  • Node Version: 16.20
  • Package: @clack/prompts
  • Package Version: v0.6.3

Describe the bug
Just a TS error, nothing is functionally wrong.

When using select within group, and initialValue is not provided, the type for value in the options is mistakenly void.

To Reproduce
Minimal Repro

import { group, select } from '@clack/prompts';

(async function create() {
  const { language } = await group({
    language: () =>
      select({
        message: 'Project langauge:',
        // uncomment following line and the error disappears
        //initialValue: 'js',
        options: [
          { value: 'js', label: 'JavaScript' }  // Type 'string' is not assignable to type 'void'. (tsserver 2322)
        ],
      }),
  });
})();

Steps to reproduce the behavior:

  • Follow link
  • Observe error
  • Uncomment the initialValue line
  • Observe error disappearing

Expected behavior
Shouldn't be a type error, AFAIK initialValue does not need to be present, as Clack works perfectly fine without.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions