S
S
sunny_puppy2017-11-16 06:07:25
typescript
sunny_puppy, 2017-11-16 06:07:25

Function data type?

What does "Function" mean after "target: " ? There seems to be no such data type in ts, and when using this decorator, an object is passed as the first argument, not a function.

function log(target: Function, key: string, value: any) {
    return {
        value: function (...args: any[]) {
            var a = args.map(a => JSON.stringify(a)).join();
            var result = value.value.apply(this, args);
            var r = JSON.stringify(result);
            console.log(`Call: ${key}(${a}) => ${r}`);
            return result;
        }
    };
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Taratin, 2017-11-16
@Taraflex

https://developer.mozilla.org/en/docs/Web/JavaScript...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question