Reputation: 6832
WebStorm is reporting an unresolved function when I use Durandal's Events.includeIn()
mixin method on a TypeScript class:
class Foo {
bar() {
...
this.trigger('myEvent', payload); // trigger is unresolved function
...
}
}
Events.includeIn(Foo);
Is there a way to resolve this without using WebStorm to suppress each unresolved call?
Upvotes: 3
Views: 861
Reputation: 12814
In order to call the trigger
method on the Foo
class, you will need to inform the TypeScript compiler about the trigger
method. You can do this by declaring the methods that will exist after the includeIn
call in the class definition:
class Foo {
// I'm not sure of the exact parameter/return types
trigger: (eventName: string, payload: any) => void;
bar() {
...
this.trigger('myEvent', payload); // now this function exists
...
}
}
Events.includeIn(Foo);
Upvotes: 1