Skip to content

Commit 2b1e766

Browse files
authored
Upgrade to TypeScript 5.x (#1343)
* chore: upgrade to TypeScript 5.x fix #1313 * style(binding-http/test/http-server-test): fix eslint warnings * chore(binding-coap): upgrade coap to 1.4.1
1 parent d534535 commit 2b1e766

12 files changed

Lines changed: 66 additions & 226 deletions

File tree

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@types/chai-as-promised": "^7.1.4",
5252
"@types/chai-spies": "^1.0.4",
5353
"@types/mocha": "^9.0.0",
54-
"@types/node": "16.18.35",
54+
"@types/node": "^18.19.71",
5555
"@types/readable-stream": "^4.0.15",
5656
"@types/sinon": "10.0.2",
5757
"@typescript-eslint/eslint-plugin": "^6.7.3",
@@ -77,7 +77,7 @@
7777
"source-map-support": "^0.5.20",
7878
"ts-node": "^10.9.1",
7979
"tslint": "5.12.1",
80-
"typescript": "4.7.4",
80+
"typescript": "^5.7.3",
8181
"typescript-standard": "^0.3.36",
8282
"wot-typescript-definitions": "0.8.0-SNAPSHOT.29"
8383
}

packages/binding-coap/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"types": "dist/coap.d.ts",
1616
"dependencies": {
1717
"@node-wot/core": "0.8.17",
18-
"coap": "^1.4.0",
18+
"coap": "^1.4.1",
1919
"dns-packet": "^5.2.2",
2020
"multicast-dns": "^7.2.5",
2121
"node-coap-client": "1.0.8",

packages/binding-http/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
"@sinonjs/fake-timers": "^11.2.2",
2424
"@types/accept-language-parser": "^1.5.2",
2525
"@types/basic-auth": "1.1.3",
26-
"@types/eventsource": "^1.1.10",
26+
"@types/eventsource": "^1.1.15",
2727
"@types/express": "^4.17.3",
28-
"@types/node-fetch": "^2.5.10",
28+
"@types/node-fetch": "^2.6.12",
2929
"body-parser": "^1.20.3",
3030
"express": "^4.20.0",
3131
"serve-static": "^1.16.0",

packages/binding-http/src/subscription-protocols.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { HttpClient, HttpForm } from "./http";
1717
import EventSource from "eventsource";
1818
import { Content, ContentSerdes, ProtocolHelpers, createLoggers } from "@node-wot/core";
1919
import { Readable } from "stream";
20+
import { AbortSignal } from "node-fetch/externals";
2021

2122
const { debug } = createLoggers("binding-http", "subscription-protocols");
2223

@@ -47,7 +48,7 @@ export class LongPollingSubscription implements InternalSubscription {
4748
if (handshake) {
4849
const headRequest = await this.client["generateFetchRequest"](this.form, "HEAD", {
4950
timeout: 1000,
50-
signal: this.abortController.signal,
51+
signal: this.abortController.signal as AbortSignal,
5152
});
5253
const result = await this.client["fetch"](headRequest);
5354
if (result.ok) resolve();
@@ -56,7 +57,7 @@ export class LongPollingSubscription implements InternalSubscription {
5657
// long timeout for long polling
5758
const request = await this.client["generateFetchRequest"](this.form, "GET", {
5859
timeout: 60 * 60 * 1000,
59-
signal: this.abortController.signal,
60+
signal: this.abortController.signal as AbortSignal,
6061
});
6162
debug(`HttpClient (subscribeResource) sending ${request.method} to ${request.url}`);
6263

packages/binding-http/test/http-server-test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class HttpServerTest {
8080
actions: {},
8181
});
8282

83-
let test: DataSchemaValue;
83+
const test: DataSchemaValue = "ok";
8484
testThing.setPropertyReadHandler("testMiddleware", () => Promise.resolve(test));
8585
testThing.setPropertyReadHandler("testPassthrough", () => Promise.resolve(test));
8686

@@ -96,6 +96,7 @@ class HttpServerTest {
9696

9797
resp = await fetch(uri + "properties/testPassthrough");
9898
expect(resp.status).to.equal(200);
99+
expect(await resp.text()).to.equal('"ok"');
99100

100101
return httpServer.stop();
101102
}
@@ -586,7 +587,7 @@ class HttpServerTest {
586587
},
587588
},
588589
});
589-
let test: DataSchemaValue;
590+
const test: DataSchemaValue = null;
590591
testThing.setPropertyReadHandler("test", async (options) => {
591592
expect(options?.uriVariables).to.deep.equal({ id: "testId", globalVarTest: "test1" });
592593
return test;
@@ -602,7 +603,7 @@ class HttpServerTest {
602603
const resp = await (
603604
await fetch(uri + "properties/test?id=testId&globalVarTest=test1", { method: "GET" })
604605
).text();
605-
expect(resp).to.equal("");
606+
expect(resp).to.equal("null");
606607

607608
return httpServer.stop();
608609
}

packages/binding-mbus/src/mbus-connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class MBusConnection {
6161
client: any; // MBusClient.IMBusRTU
6262
connecting: boolean;
6363
connected: boolean;
64-
timer?: NodeJS.Timer; // connection idle timer
64+
timer?: NodeJS.Timeout; // connection idle timer
6565
currentTransaction?: MBusTransaction; // transaction currently in progress or undefined
6666
queue: Array<MBusTransaction>; // queue of further transactions
6767
config: {

packages/binding-modbus/src/modbus-connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class ModbusConnection {
142142
client: ModbusRTU;
143143
connecting: boolean;
144144
connected: boolean;
145-
timer: NodeJS.Timer | null; // connection idle timer
145+
timer: NodeJS.Timeout | null; // connection idle timer
146146
currentTransaction: ModbusTransaction | null; // transaction currently in progress or null
147147
queue: Array<ModbusTransaction>; // queue of further transactions
148148
config: {

packages/binding-opcua/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"node-opcua-nodeid": "2.113.0",
3939
"node-opcua-numeric-range": "2.113.0",
4040
"node-opcua-pseudo-session": "2.113.0",
41-
"node-opcua-pubsub-client": "0.19.1",
4241
"node-opcua-service-browse": "2.113.0",
4342
"node-opcua-service-translate-browse-path": "2.113.0",
4443
"node-opcua-status-code": "2.110.0",

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@thingweb/thing-model": "^1.0.1",
3030
"ajv": "^8.11.0",
3131
"commander": "^9.1.0",
32-
"dotenv": "^8.6.0",
32+
"dotenv": "^16.4.7",
3333
"lodash": "^4.17.21",
3434
"vm2": "3.9.18"
3535
},

0 commit comments

Comments
 (0)