Fix OclifUX.ux.prompt() return type#538
Merged
mdonnalley merged 1 commit intooclif:mainfrom Oct 31, 2022
Merged
Conversation
|
Thanks for the contribution! Before we can merge this, we need @NullSoldier to sign the Salesforce.com Contributor License Agreement. |
ygao76
previously approved these changes
Oct 25, 2022
NullSoldier
commented
Oct 25, 2022
| } | ||
|
|
||
| public async pauseAsync(fn: () => Promise<any>, icon?: string) { | ||
| public async pauseAsync<T extends any>(fn: () => Promise<T>, icon?: string): Promise<T> { |
Contributor
Author
There was a problem hiding this comment.
This will help with backwards compatability, in the case that typescript cannot infer T.
It's been a long standing issue that prompt returns a Promise<any> when it clearly should return Promise<string>. It's because the wrapper methods pauseAsync() don't forward their types along from the wrapped functions.
8245b76 to
068653d
Compare
NullSoldier
commented
Oct 25, 2022
| * @returns Promise<string> | ||
| */ | ||
| export async function anykey(message?: string): Promise<void> { | ||
| export async function anykey(message?: string): Promise<string> { |
Contributor
Author
There was a problem hiding this comment.
My change has revealed that this code was broken. It was typed as returning void but actually it was returning a string.
mdonnalley
approved these changes
Oct 31, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's been a long standing issue that prompt returns a
Promise<any>when it clearly should returnPromise<string>. It's because the wrapper methodspauseAsync()don't forward their types along from the wrapped functions.I tried to sign the CLA but it failed the first time, and every subsequent time now I get
You already signed the CLA on 2022-10-25.