SBoudrias/Inquirer.js

Removed type causing breaking change in non-major update.

yhaskell opened this issue · 1 comments

Hi and thanks for the amazing project ;)

I have found, that in this commit 3a9adcf
there was a change to hide the type that was previously available.

It was a nice type to use in functions, that also causes quite a lot of inconvenience:

// fix for the type being hidden
type Choice<T> = Exclude<Parameters<typeof select<T>>[0]["choices"][number], Separator>;

And, as it was updated without raising the major version, auto-update caused the breaking change.

Can you please share, why the type was hidden?
And possibly re-export it again?

Hi @yhaskell, this project being widely use, I want to keep the interface minimal to prevent issues such as that one you just ran into. In my experience, I found underlying types implementation to change often to account for accrued inference or reactivity to the types being passed in. In other words, while the interface of a prompt will not often have breaking changes, reviewing how the Choice type is defined is much more likely.

Because of this, I strongly prefer to not expose them in order to not accrue the amount of major version/breaking changes going out. Those make migration harder and we leaves folks behind on old version too easily.

Prefer reaching out to the underlying type with type accessors; like Parameters<typeof prompt>[0]['choices'][number] (pseudo-coding, but you'll get the idea.)