I'm brand new to typescript - having an issue with variables and scope.
I have 2 public methods, one requires a string. The first method calls the second, from within a jQuery click function (which means I can't use this.methodName anymore). I tried fixing the scope in a logical method but TS complains that:
Supplied Paramaters do not match any signature of call target. Could not select overload for 'call' expression.
public test1() {
//fix scope
var scopeFix = () => this.test2;
$("#test").click(function () {
//this.test2("blah");
//^^^ This doesn't work because "this." is used by jquery
scopeFix("blah");
});
}
public test2(testString:string) {
alert(testString);
}
I'm sure it's something silly (like me mixing JS and TS too much) - any ideas?
thisscope you need, jsfiddle.net/9DjGpscopeFixfunction is a paramterless function that returns a function, so your call site is wrong, it should be more likefixScope()('blah');