i want to use SignalR with typescript
this typescript library not export any thing
@types/[email protected]
Try adding import 'signalr'. Then the types should be available under the SignalR namespace.
worked with me with the following code
import { SignalRModule, SignalRConfiguration,SignalR } from 'ng2-signalr';
import { ModuleWithProviders, NgZone } from '@angular/core';
import {createConfig} from './CustomSignalRModule'
@NgModule({
declarations: [...],
imports: [
SignalRModule.forRoot(createConfig)
],
here the CustomSignalRModule.ts file
import { SignalRConfiguration } from 'ng2-signalr';
import { Constants }from '../models/constant'
// SignalR config
// changing SignalR to v2 will need to change angular to ^2.3.1 because SignalR v2 foRoot is function not object
// v2
export function createConfig(): SignalRConfiguration {
const c:SignalRConfiguration = new SignalRConfiguration();
c.hubName = 'OtoHub';
// c.qs = { user: 'donald' };
c.url = Constants.API_URL ;
c.logging = true;
return c;
}
Most helpful comment
Try adding
import 'signalr'. Then the types should be available under theSignalRnamespace.