I've encountered some issues while trying to implement signalR in my Angular2-Typescript application. Previously, I had no trouble using it in an Angular 1 app. The problem seems to lie in the importing process.
While I do have intellisense working, the strong typing doesn't seem to align properly with the original JavaScript file.
Within the node_modules folder, I have these two abbreviated directory structures:
├───jquery
│ │ jquery.d.ts
│ │ LICENSE.txt
│ │ package.json
│ │ README.md
│ │
│ ├───dist
│ │ core.js
│ │ jquery.js
│
└───signalr
jquery.signalR.js
jquery.signalR.min.js
package.json
signalr.d.ts
The content of jquery.d.ts can be found here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/jquery/jquery.d.ts
The signalr.d.ts file can be accessed here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/signalr/signalr.d.ts
Important: I had to modify the signalr.d.ts file by adding the following lines at the end in order to make it importable:
declare var sr : JQueryStatic;
declare module 'signalr'{
export = sr;
}
In my systemjs.config.js, I use the following to import signalr:
map: {
'signalr': 'npm:signalr/jquery.signalR.js'
}
Then, in my component, I use the following import statement:
import * as $ from 'signalr'
Subsequently, I am able to use intellisense, such as demonstrated here:
https://i.sstatic.net/apzo0.png
However, there are lingering issues. When I execute:
console.log($.hubConnection);
The output is undefined.
I would greatly appreciate any assistance with resolving this matter.