Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] types of properties in group are inferred as unknown if results parameter is used #234

Open
brc-dd opened this issue Feb 16, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@brc-dd
Copy link

brc-dd commented Feb 16, 2025

Environment

  • OS: webcontainers
  • Node Version: 18.20.3
  • Package: @clack/prompts
  • Package Version: v0.10.0

Describe the bug

const options = await p.group(
  {
    injectNpmScripts: async () => {
      return p.confirm({
        message: 'Add VitePress npm scripts to package.json?',
      });
    },

    addNpmScriptsPrefix: async ({ results }) => {
      if (!results.injectNpmScripts) return false;

      return p.confirm({
        message: 'Add a prefix for VitePress npm scripts?',
      });
    },
  },

  {
    onCancel: () => {
      p.cancel('Cancelled.');
      process.exit(0);
    },
  }
);

options here is inferred as:

const options: {
    injectNpmScripts: boolean;
    addNpmScriptsPrefix: unknown;
}

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

Expected behavior
Return correct types:

const options: {
    injectNpmScripts: boolean;
    addNpmScriptsPrefix: boolean;
}

Additional Information
It works fine if we make it ({ results }: any). The generic parameter of group function doesn't work because the functions return cancel symbol too.

@brc-dd brc-dd added the bug Something isn't working label Feb 16, 2025
@github-project-automation github-project-automation bot moved this to Needs triage in Triage Board Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Needs triage
Development

No branches or pull requests

1 participant