bombshell-dev / clack

Effortlessly build beautiful command-line apps
https://clack.cc
5.25k stars 88 forks source link

fix(@clack/core,@clack/prompts): add non empty opts type interface #145

Open kevduc opened 10 months ago

kevduc commented 10 months ago

This PR addresses this issue https://github.com/natemoo-re/clack/issues/144.

The current implementation is erroring out at runtime, the implementation in this PR shows a type error in the IDE/tsc instead.

changeset-bot[bot] commented 10 months ago

⚠️ No Changeset found

Latest commit: f663d0f7e2a37ba7a088ac08f92c9e13a72dffe7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

kevduc commented 10 months ago

Example of what the type error could look like in VSCode:

Example

cpreston321 commented 10 months ago

Hey @kevduc ! Thanks for this PR! 🙏🏼

I recently merged a PR to simplify types on @clack/prompts if you want to resolve issues -- I can then be able to merge this!

I could also see this being used also on https://github.com/natemoo-re/clack/blob/7c7fde8dcdfa1edc3feb131331290affbaa6d934/packages/prompts/src/index.ts#L307 & https://github.com/natemoo-re/clack/blob/7c7fde8dcdfa1edc3feb131331290affbaa6d934/packages/prompts/src/index.ts#L423

kevduc commented 10 months ago

@cpreston321 Thanks for the suggestions!
The fix for MultiSelectOptions is pretty much the same as for select (https://github.com/natemoo-re/clack/pull/145/commits/20cde30e5e48fbe2b15a8d5dba2ae8f9845a4489). I also had a look at GroupMultiSelectPrompt: