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
将minapp-generator的tsconfig.json的target调整为es2017会提示done函数找不到 #43
Comments
我不能复现你的问题, done 都是存在的。我觉得也不应该,async 文档上是说那样用的,一般不可能不同的 node 版本出现两种不同的调用方式吧 |
确定没出现吗?我用的node8,tsconfig.json的target修改成es2017,vscode debug然后调用确实变了,修改前后两次不一样,执行的async库没有将done传过去,而是先执行,根据结果判断再调用done |
// async.js L2498-L2509
function reduce(coll, memo, iteratee, callback) {
callback = once(callback || noop);
var _iteratee = wrapAsync(iteratee);
eachOfSeries(coll, function(x, i, callback) {
_iteratee(memo, x, function(err, v) {
memo = v;
callback(err);
});
}, function(err) {
callback(err, memo);
});
} // async.js L225-233
var supportsSymbol = typeof Symbol === 'function';
function isAsync(fn) {
return supportsSymbol && fn[Symbol.toStringTag] === 'AsyncFunction';
}
function wrapAsync(asyncFn) {
return isAsync(asyncFn) ? asyncify(asyncFn) : asyncFn;
} 又debug了一下流程,生成出来的js reduce后会走wrapAsync封装一次,然后走了asyncify才会出现的 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
本来想调试简单一些,直接使用node的async、await,就将target调整为es2017,不用typescript的tslib,结果报done不存在了。
如果调整target为es2017的话async库的调用方式不一样,会走asyncify不传递callback
我将代码调整了一下,大佬要不要参考一下
The text was updated successfully, but these errors were encountered: