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 OclifUX.ux.prompt() return type #538
Conversation
Thanks for the contribution! Before we can merge this, we need @NullSoldier to sign the Salesforce.com Contributor License Agreement. |
@@ -92,7 +92,7 @@ export class ActionBase { | |||
task.status = status | |||
} | |||
|
|||
public async pauseAsync(fn: () => Promise<any>, icon?: string) { | |||
public async pauseAsync<T extends any>(fn: () => Promise<T>, icon?: string): Promise<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
*/ | ||
export async function anykey(message?: string): Promise<void> { | ||
export async function anykey(message?: string): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My change has revealed that this code was broken. It was typed as returning void but actually it was returning a string.
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
.