If you want "this" to be a different value than your view model, then define your computed using an anonymous function to prevent the "this" to "_this" translation from occurring and pass what you want "this" to be as your second parameter.
-Brian
/// <reference path="knockout.d.ts" />
class viewmodel
{
public foo: KnockoutObservable<string> = ko.observable();
public bar: KnockoutObservable<string> = ko.observable();
public baz: KnockoutComputed<string> = ko.computed(() =>
{
return this.foo() + " " + this.bar();
});
constructor(foo: string, bar: string)
{
this.foo(foo);
this.bar(bar);
}
}
'this' cannot be referenced in initializers in a class body.