I'm trying to use SignalR in my Angular 5 application.
I installed these strong typed from DefinitelyTyped:
npm install --save @types/jquery
npm install --save @types/signalr
Typescript in my packages.json
shows version 2.5.3.
Now I'm trying to use it like this:
import { Injectable } from '@angular/core';
@Injectable()
export class SignalRService {
constructor() {}
public ConnectTo(url: string): void {
var hubConnection = $.hubConnection();
var hubProxy = hubConnection.createHubProxy('DashboardHub');
hubProxy.on('Example', (e: any) => {
console.log('worked');
});
hubConnection.start();
}
}
The compiler complains with the following:
error TS2304: Cannot find name '$'.
...even though intellisense can find $.hub
:
If I try adding declare var $ :any;
to my file, it compiles but I get another error in browser's console: $.hubConnection is not a function
.
Am I missing something?