SignalR integration in my Ionic/Angular 2 application has been a challenge.
I'm creating a basic Hub setup as follows:
const accessToken = authManager.getRawAccessToken();
let hubUrl = environment.baseUrl + 'messages';
if (accessToken) {
hubUrl += '?authToken=' + accessToken;
}
this._hubConnection = new HubConnectionBuilder()
.withUrl(hubUrl)
.build();
An error I keep encountering is:
'Cannot find name 'XMLHttpRequestResponseType'.
This issue is due to SignalR requiring a higher version of TypeScript which is not currently supported by Ionic. Refer to this link.
I realized that SignalR comes default with JavaScript. Is it possible to modify the Import statement like this?
import { HubConnection, HubConnectionBuilder } from '@aspnet/signalr';
So that I can import JavaScript into a TypeScript file without any issues?
Edit I also attempted:
import * as SignalR from '@aspnet/signalr';
However, it seems to still utilize the typings file.