Reputation: 21005
I'm trying to use SignalR in an Ionic/Angular 2 application.
I'm building a simple Hub like so:
const accessToken = authManager.getRawAccessToken();
let hubUrl = environment.baseUrl + 'messages';
if (accessToken) {
hubUrl += '?authToken=' + accessToken;
}
this._hubConnection = new HubConnectionBuilder()
.withUrl(hubUrl)
.build();
I keep getting an error:
Cannot find name 'XMLHttpRequestResponseType'.
because SignalR requires a higher version of typescript than what's support currently by Ionic. https://github.com/aspnet/SignalR/issues/1375
I noticed SignalR is shipped by default using Javascript. Is there a way I can change my Import statement
import { HubConnection, HubConnectionBuilder } from '@aspnet/signalr';
So I can import javascript into a Typescript file as Any?
Edit I've also tried:
import * as SignalR from '@aspnet/signalr';
but this still seems to use the typings file.
Upvotes: 1
Views: 234
Reputation: 276057
To use Js instead of Typescript?
Use raw require
:
const { HubConnection, HubConnectionBuilder } = require('@aspnet/signalr');
The types for require
are provided by npm i @types/node
🌹
Upvotes: 1