I've been successful by creating a small app using AspNetCore 2.2, SignalR, and a TypeScript front-end. The bundle is created via WebPack.
What I would like to try is to enable the MessagePack protocol plugin. However, the docs about how to install it seems not accurate enough. Although the command-line compilation (npm run build) goes apparently fine, when I start the application to debug it won't compile because something in the TypeScript code is missing:
Error TS2688 Build:Cannot find type definition file for 'node'. C:\ ... \node_modules@aspnet\signalr-protocol-msgpack\dist\esm\MessagePackHubProtocol.d.ts 1
Error TS2580 Build:Cannot find name 'Buffer'. Do you need to install type definitions for node? Try
npm i @types/node
and then addnode
to the types field in your tsconfig. C:\ ... \node_modules@aspnet\signalr-protocol-msgpack\dist\esm\MessagePackHubProtocol.d.ts 16
By the way, if I follow that hint, things will go even worse due the "setTimeout" presence in my code. Basically, it seems that the "node" setTimeout overrides the "window"'s one, and their signatures don't match.
Here is the package.json (without the hinted patch):
{
"version": "1.0.0",
"name": "asp.net",
"private": true,
"devDependencies": {
"del": "2.2.0",
"@types/jquery": "^3.3.29",
"ts-loader": "^5.3.3",
"typescript": "^3.2.2",
"webpack": "^4.28.3",
"webpack-cli": "^3.2.1",
"webpack-merge-and-include-globally": "^2.1.14",
"clean-webpack-plugin": "^1.0.0"
},
"dependencies": {
"@aspnet/signalr": "^1.1.0",
"@aspnet/signalr-protocol-msgpack": "^1.1.0",
"axios": "^0.18.0",
"bootstrap": "^4.2.1",
"jquery": "^3.3.1"
},
"scripts": {
"build": "webpack --mode=development",
"watch": "webpack --mode=development --watch",
"release": "webpack --mode=production",
"test": "echo \"Error: no test specified\" && exit 1"
}
}
Finally, here is the tsconfig.json:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"lib": [ "es6", "dom" ]
},
"exclude": [
"node_modules",
"wwwroot"
]
}
Is it me, or maybe a bug somewhere?