Oldrich Svec
Oldrich Svec

Reputation: 4231

Function type using typescript

Why do I have to cast function into Function type to be able to access apply and other members?

var a: Function = () => {};
a.apply(); // works

var a = () => {};
a.apply(); // does not work

How should I do it with these functions?:

function a(){}
a.apply(); // does not work

Upvotes: 1

Views: 773

Answers (1)

Fenton
Fenton

Reputation: 251222

If you pass the "this" argument to the apply function, it seems to work either way:

var a = () => {};
a.apply(null);

var b: Function = () => {};
b.apply(null);

Upvotes: 1

Related Questions