Working on an asp.net mvc 4.5 project with typescript in the client side, I successfully installed and configured signalR on the server side. To integrate it into my project, I also installed signalr.TypeScript.DefinitelyTyped with jquery.
In my typescript file, I referenced signalr like this at the top: ///
Additionally, I created an interface file for my hub:
interface SignalR {
ForecastHub: {
client: {
DeleteProject(projectId: number)
};
server: {
send(name: string, message: string)
};
};
}
The main implementation code in my typescript file is as follows:
var client = $.connection.ForecastHub;
client.client.DeleteProject = function (projectId) {
alert(projectId);
};
$.connection.hub.start().done(function () {
});
During runtime execution, I encountered an error stating 'Cannot read property 'ForecastHub' of undefined'. This led me to search for a solution on how to correctly import signalr in typescript. If you have any suggestions on how to seamlessly integrate signalR in a typescript project, please provide your insights. Thank you!