Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit fd53f84

Browse files
BrennanConroynatemcmaster
authored andcommitted
TypeScript improvements and tslib dep (#2808)
Resolves "Module not found: Can't resolve 'tslib' in '...@aspnet\signalr\dist\esm'"
1 parent 46dd1c9 commit fd53f84

29 files changed

Lines changed: 8919 additions & 9203 deletions

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"version": "0.2.0",
33
"configurations": [
4+
45
{
56
"type": "node",
67
"request": "launch",
@@ -17,6 +18,18 @@
1718
"address": "localhost",
1819
"port": 5858,
1920
"outFiles": []
21+
},
22+
{
23+
"type": "node",
24+
"request": "launch",
25+
"name": "Jest - Current File",
26+
"program": "${workspaceFolder}/clients/ts/common/node_modules/jest/bin/jest",
27+
"cwd": "${workspaceFolder}/clients/ts",
28+
"args": [
29+
"${relativeFile}"
30+
],
31+
"console": "integratedTerminal",
32+
"internalConsoleOptions": "neverOpen"
2033
}
2134
]
2235
}

build/repo.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</PropertyGroup>
1616
<Target Name="RestoreNpm" Condition="'$(PreflightRestore)' != 'True'">
1717
<Message Text="Restoring NPM modules" Importance="high" />
18-
<Exec Command="npm install --no-optional" WorkingDirectory="$(RepositoryRoot)clients/ts" />
18+
<Exec Command="npm install --no-optional" WorkingDirectory="$(RepositoryRoot)clients/ts/common" />
1919
<Exec Command="npm install --no-optional" WorkingDirectory="$(RepositoryRoot)clients/ts/FunctionalTests" />
2020
<Exec Command="npm install --no-optional" WorkingDirectory="$(RepositoryRoot)clients/ts/signalr" />
2121
<Exec Command="npm install --no-optional" WorkingDirectory="$(RepositoryRoot)clients/ts/signalr-protocol-msgpack" />

clients/ts/FunctionalTests/package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/ts/FunctionalTests/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
"jasmine": "^3.1.0",
1818
"tap-parser": "^7.0.0",
1919
"tee": "^0.2.0",
20-
"ts-node": "^4.1.0"
20+
"ts-node": "^4.1.0",
21+
"typescript": "^3.0.1"
2122
},
2223
"scripts": {
23-
"clean": "node ../node_modules/rimraf/bin.js ./wwwroot/dist ./obj/js",
24+
"clean": "node ../common/node_modules/rimraf/bin.js ./wwwroot/dist ./obj/js",
2425
"build": "npm run clean && npm run build:lint && npm run build:webpack",
25-
"build:lint": "node ../node_modules/tslint/bin/tslint -c ../tslint.json -p ./tsconfig.json",
26-
"build:webpack": "node ../node_modules/webpack-cli/bin/cli.js",
26+
"build:lint": "node ../common/node_modules/tslint/bin/tslint -c ../tslint.json -p ./tsconfig.json",
27+
"build:webpack": "node ../common/node_modules/webpack-cli/bin/cli.js",
2728
"pretest": "npm run build",
2829
"test": "dotnet build && npm run test-only",
2930
"test-only": "ts-node --project ./selenium/tsconfig-selenium.json ./selenium/run-tests.ts",

clients/ts/FunctionalTests/ts/ConnectionTests.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
import { HttpTransportType, IHttpConnectionOptions, LogLevel, TransferFormat } from "@aspnet/signalr";
4+
// This code uses a lot of `.then` instead of `await` and TSLint doesn't like it.
5+
// tslint:disable:no-floating-promises
6+
7+
import { HttpTransportType, IHttpConnectionOptions, TransferFormat } from "@aspnet/signalr";
58
import { eachTransport, ECHOENDPOINT_URL } from "./Common";
69
import { TestLogger } from "./TestLogger";
710

@@ -23,15 +26,13 @@ describe("connection", () => {
2326
...commonOptions,
2427
});
2528

26-
let received = "";
27-
connection.onreceive = (data) => {
28-
received += data;
29+
connection.onreceive = async (data: any) => {
2930
if (data === message) {
3031
connection.stop();
3132
}
3233
};
3334

34-
connection.onclose = (error) => {
35+
connection.onclose = (error: any) => {
3536
expect(error).toBeUndefined();
3637
done();
3738
};
@@ -55,22 +56,20 @@ describe("connection", () => {
5556
transport: transportType,
5657
});
5758

58-
let received = "";
59-
connection.onreceive = (data) => {
60-
received += data;
59+
connection.onreceive = (data: any) => {
6160
if (data === message) {
6261
connection.stop();
6362
}
6463
};
6564

66-
connection.onclose = (error) => {
65+
connection.onclose = (error: any) => {
6766
expect(error).toBeUndefined();
6867
done();
6968
};
7069

7170
connection.start(TransferFormat.Text).then(() => {
7271
connection.send(message);
73-
}).catch((e) => {
72+
}).catch((e: any) => {
7473
fail(e);
7574
done();
7675
});
@@ -85,15 +84,17 @@ describe("connection", () => {
8584
transport: transportType,
8685
});
8786

88-
connection.onreceive = (data) => {
87+
connection.onreceive = (data: any) => {
8988
if (data === message) {
9089
connection.stop();
9190
}
9291
};
9392

93+
// @ts-ignore: We don't use the error parameter intentionally.
9494
connection.onclose = (error) => {
9595
// Search the logs for the message content
9696
expect(TestLogger.instance.currentLog.messages.length).toBeGreaterThan(0);
97+
// @ts-ignore: We don't use the _ or __ parameters intentionally.
9798
for (const [_, __, logMessage] of TestLogger.instance.currentLog.messages) {
9899
expect(logMessage).not.toContain(message);
99100
}
@@ -118,16 +119,18 @@ describe("connection", () => {
118119
transport: transportType,
119120
});
120121

121-
connection.onreceive = (data) => {
122+
connection.onreceive = (data: any) => {
122123
if (data === message) {
123124
connection.stop();
124125
}
125126
};
126127

128+
// @ts-ignore: We don't use the error parameter intentionally.
127129
connection.onclose = (error) => {
128130
// Search the logs for the message content
129131
let matches = 0;
130132
expect(TestLogger.instance.currentLog.messages.length).toBeGreaterThan(0);
133+
// @ts-ignore: We don't use the _ or __ parameters intentionally.
131134
for (const [_, __, logMessage] of TestLogger.instance.currentLog.messages) {
132135
if (logMessage.indexOf(message) !== -1) {
133136
matches += 1;
@@ -141,7 +144,7 @@ describe("connection", () => {
141144

142145
connection.start(TransferFormat.Text).then(() => {
143146
connection.send(message);
144-
}).catch((e) => {
147+
}).catch((e: any) => {
145148
fail(e);
146149
done();
147150
});

clients/ts/FunctionalTests/ts/HubConnectionTests.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
import { DefaultHttpClient, HttpClient, HttpRequest, HttpResponse, HttpTransportType, HubConnection, HubConnectionBuilder, IHttpConnectionOptions, IStreamSubscriber, JsonHubProtocol, LogLevel } from "@aspnet/signalr";
4+
// This code uses a lot of `.then` instead of `await` and TSLint doesn't like it.
5+
// tslint:disable:no-floating-promises
6+
7+
import { DefaultHttpClient, HttpClient, HttpRequest, HttpResponse, HttpTransportType, HubConnectionBuilder, IHttpConnectionOptions, JsonHubProtocol } from "@aspnet/signalr";
58
import { MessagePackHubProtocol } from "@aspnet/signalr-protocol-msgpack";
69

710
import { eachTransport, eachTransportAndProtocol } from "./Common";
@@ -221,7 +224,7 @@ describe("hubConnection", () => {
221224
hubConnection.stop();
222225
done();
223226
},
224-
next(item) {
227+
next() {
225228
hubConnection.stop();
226229
fail();
227230
},
@@ -248,7 +251,7 @@ describe("hubConnection", () => {
248251
hubConnection.stop();
249252
done();
250253
},
251-
next(item) {
254+
next() {
252255
hubConnection.stop();
253256
fail();
254257
},

clients/ts/FunctionalTests/ts/WebDriverReporter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class WebDriverReporter implements jasmine.CustomReporter {
3939
this.taplog(`1..${suiteInfo.totalSpecsDefined}`);
4040
}
4141

42+
// @ts-ignore: We don't use the result parameter
4243
public specStarted(result: jasmine.CustomReporterResult): void {
4344
this.concurrentSpecCount += 1;
4445
if (this.concurrentSpecCount > 1) {
@@ -90,6 +91,7 @@ class WebDriverReporter implements jasmine.CustomReporter {
9091
this.specCounter += 1;
9192
}
9293

94+
// @ts-ignore: We don't use the result parameter
9395
public jasmineDone(runDetails: jasmine.RunDetails): void {
9496
this.element.setAttribute("data-done", "1");
9597
}

clients/ts/FunctionalTests/webpack.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
const path = require("path");
5-
const webpack = require("webpack");
5+
const webpack = require("../common/node_modules/webpack");
66

77
module.exports = {
88
entry: path.resolve(__dirname, "ts", "index.ts"),
@@ -24,6 +24,10 @@ module.exports = {
2424
}
2525
]
2626
},
27+
resolveLoader: {
28+
// Special resolution rules for loaders (which are in the 'common' directory)
29+
modules: [ path.resolve(__dirname, "..", "common", "node_modules") ],
30+
},
2731
resolve: {
2832
extensions: [".ts", ".js"]
2933
},

0 commit comments

Comments
 (0)