我已经开始学习如何在我的应用程序中实现 TypeScript 装饰器。所以我从setTimeout. 它是一个方法装饰器,它在一段时间后执行方法。
例如:
@Decorators.timeout()
public someMethod () {}
Run Code Online (Sandbox Code Playgroud)
这是我的实现:
export class Decorators {
public static timeout (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): any {
let originalMethod = descriptor.value;
let decArguments = arguments;
descriptor.value = function Timeout () {
setTimeout(() => {
originalMethod.apply(this, decArguments);
}, 2000);
};
return descriptor;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
提供的参数与调用目标的任何签名都不匹配
可能是什么问题呢?
我正在尝试使用“搜索”方法在 ldapjs 中进行搜索,但它对我不起作用。
这是来自终端的回应:
> Result is: SearchResponse {
messageID: 2,
protocolOp: 101,
controls: [],
log:
Logger {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
_isSimpleChild: true,
_level: 30,
streams: [ [Object] ],
serializers:
{ req: [Function: req],
res: [Function: res],
err: [Function: err] },
src: false,
fields:
{ name: 'ldapjs',
component: 'client',
hostname: 'nichita-Lenovo-ideapad-500-15ISK',
pid: 29307,
clazz: 'Client' } },
status: 0,
matchedDN: '',
errorMessage: '',
referrals: [],
connection:
TLSSocket {
_tlsOptions:
{ pipe: undefined,
secureContext: [Object],
isServer: …Run Code Online (Sandbox Code Playgroud)