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

fix: correct and improve return types for single and multi select prompts #197

Merged
merged 5 commits into from
Jun 26, 2023

Conversation

DamianGlowala
Copy link
Contributor

No description provided.

@DamianGlowala DamianGlowala changed the title fix: correct return type for single-select prompt fix: correct return types for single and multi select prompts Jun 11, 2023
@DamianGlowala DamianGlowala changed the title fix: correct return types for single and multi select prompts fix: correct and improve return types for single and multi select prompts Jun 11, 2023
@codecov
Copy link

codecov bot commented Jun 18, 2023

Codecov Report

Merging #197 (ce769fa) into main (dabb705) will decrease coverage by 0.08%.
The diff coverage is 0.00%.

❗ Current head ce769fa differs from pull request most recent head 705ff8e. Consider uploading reports for the commit 705ff8e to get more accurate results

@@            Coverage Diff             @@
##             main     #197      +/-   ##
==========================================
- Coverage   62.24%   62.16%   -0.08%     
==========================================
  Files           9        9              
  Lines         792      793       +1     
  Branches       50       50              
==========================================
  Hits          493      493              
- Misses        299      300       +1     
Impacted Files Coverage Δ
src/consola.ts 62.98% <0.00%> (-0.16%) ⬇️

@DamianGlowala
Copy link
Contributor Author

DamianGlowala commented Jun 18, 2023

It would be great to be able to pass an optional generic for select and multiselect prompts to narrow down what type the options might be, e.g.:

type PackageManager = 'npm' | 'pnpm' | 'yarn'

await consola.prompt<PackageManager>(...)

giving us a more precise return type: Promise<PackageManager> (select) or Promise<PackageManager[]> (multiselect)

@pi0
Copy link
Member

pi0 commented Jun 26, 2023

It would be great to be able to pass an optional generic for select and multiselect prompts to narrow down what type the options might be, e.g.:

This is why we have two reserved positional generics. PR welcome to add 👍🏼

@pi0 pi0 merged commit 0d03d70 into unjs:main Jun 26, 2023
@DamianGlowala DamianGlowala deleted the fix/single-select-return-type branch June 28, 2023 11:00
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.

2 participants