Signalr: typescript signalR is not a module

Created on 7 May 2017  路  2Comments  路  Source: SignalR/SignalR

i want to use SignalR with typescript
this typescript library not export any thing
@types/[email protected]

Most helpful comment

Try adding import 'signalr'. Then the types should be available under the SignalR namespace.

All 2 comments

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;
}

Was this page helpful?
0 / 5 - 0 ratings