I have Typescript working in a JET 7.0.1 app. However, it is causing issues when I try to create a knockout computed.
The code looks something similar to this:
class Test {
firstName: KnockoutObservable<string>
surName: KnockoutObservable<string>
fullName: KnockoutComputed<string>
constructor(firstName: string, surName: string) {
this.firstName = ko.observable(firstName)
this.surName = ko.observable(surName)
this.fullName = ko.computed(() => {
return this.firstName() + this.surName();
})
}
}
I get a run time error on the
this.fullName = ko.computed(() => {...})
The error is:
Property 'fn' is missing in type 'Computed<string>' but required in type 'KnockoutComputed<string>'.
ts(2741)The typescript version we are using in the app is 3.1.3, however, I have created a new JET 7 app with Typescript's latest version(3.5.2) to see if the same applies and it does. Generally, Typescript is working fine in the app with knockout observables so it just seems to complain about the knockout computed observables. Everyone in my team is experiencing the same issue too.
Would anyone have any pointers on what to do here?
Cheers,
Sonj.