-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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(async): doWhilst, doUntil definitions and tests #20765
fix(async): doWhilst, doUntil definitions and tests #20765
Conversation
types/async/index.d.ts to authors (@borisyankov @Kern0 @Penryn @fenying @pascalmartin). Could you review this PR? |
@rlindgren Please fix the failures indicated in the Travis CI log. |
As far as I can tell, the failure is unrelated to the code changes. It appears to have been caused by a compilation/lint failure of |
Please pull this in! |
Emmm, don't you think that the argument export function doUntil<T, E>(
fn: AsyncFunction<T, E>,
test: (result?: T) => boolean,
callback: ErrorCallback<E>
): void; Besides, according to the document, there is not only one argument could be passed to the export interface AsyncFunctionEx<T, E> {
(callback: (err?: E, ...args: T[]) => void): void;
}
/**
* Put the T behind E so that there is no compatibilities problem.
*/
export function doUntil<E, T = any>(
fn: AsyncFunctionEx<T, E>,
test: (...args: T[]) => boolean,
callback: ErrorCallback<E>
): void; and use it like import * as libAsync from "async";
libAsync.doUntil<Error, number>(function(callback) {
console.log("123");
setTimeout(function() {
callback(undefined, 123, 321);
}, 1000);
}, function(...args: number[]): boolean {
console.log(args[1]);
return args[0] !== 123;
}, function(e: Error) {
}); |
@fenying You're right. Although, I think that putting type parameter |
Fine, I think that's okay. I would vote 👍. |
Approved by a listed owner. PR ready to merge pending express review by a maintainer. |
npm run lint package-name
(ortsc
if notslint.json
is present).Select one of these and delete the others:
If changing an existing definition:
tslint.json
containing{ "extends": "dtslint/dt.json" }
.Breaking changes in version 2.0.0 explain that the test function for
doWhilst
anddoUntil
may take a non-Error argument passed from the iteratee callback, and that onlywhile
anduntil
pass no arguments.Additionally, though not in this PR due to a failure to define the API implementation with Typescript, the documentation for doDuring says that test function for
doDuring
can take any number of non-Error values passed from the iteratee callback followed by the test function callback ie.testFunction(...args, callback)
. Resulting in Typescript error:A rest parameter must be last in a parameter list
.Relevant Section from Breaking Changes