Skip to content

Commit

Permalink
Upgrade to TypeScript 5.x (#1343)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
relu91 authored Jan 22, 2025
1 parent d534535 commit 2b1e766
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 226 deletions.
258 changes: 49 additions & 209 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@types/chai-as-promised": "^7.1.4",
"@types/chai-spies": "^1.0.4",
"@types/mocha": "^9.0.0",
"@types/node": "16.18.35",
"@types/node": "^18.19.71",
"@types/readable-stream": "^4.0.15",
"@types/sinon": "10.0.2",
"@typescript-eslint/eslint-plugin": "^6.7.3",
Expand All @@ -77,7 +77,7 @@
"source-map-support": "^0.5.20",
"ts-node": "^10.9.1",
"tslint": "5.12.1",
"typescript": "4.7.4",
"typescript": "^5.7.3",
"typescript-standard": "^0.3.36",
"wot-typescript-definitions": "0.8.0-SNAPSHOT.29"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/binding-coap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"types": "dist/coap.d.ts",
"dependencies": {
"@node-wot/core": "0.8.17",
"coap": "^1.4.0",
"coap": "^1.4.1",
"dns-packet": "^5.2.2",
"multicast-dns": "^7.2.5",
"node-coap-client": "1.0.8",
Expand Down
4 changes: 2 additions & 2 deletions packages/binding-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"@sinonjs/fake-timers": "^11.2.2",
"@types/accept-language-parser": "^1.5.2",
"@types/basic-auth": "1.1.3",
"@types/eventsource": "^1.1.10",
"@types/eventsource": "^1.1.15",
"@types/express": "^4.17.3",
"@types/node-fetch": "^2.5.10",
"@types/node-fetch": "^2.6.12",
"body-parser": "^1.20.3",
"express": "^4.20.0",
"serve-static": "^1.16.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/binding-http/src/subscription-protocols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { HttpClient, HttpForm } from "./http";
import EventSource from "eventsource";
import { Content, ContentSerdes, ProtocolHelpers, createLoggers } from "@node-wot/core";
import { Readable } from "stream";
import { AbortSignal } from "node-fetch/externals";

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

Expand Down Expand Up @@ -47,7 +48,7 @@ export class LongPollingSubscription implements InternalSubscription {
if (handshake) {
const headRequest = await this.client["generateFetchRequest"](this.form, "HEAD", {
timeout: 1000,
signal: this.abortController.signal,
signal: this.abortController.signal as AbortSignal,
});
const result = await this.client["fetch"](headRequest);
if (result.ok) resolve();
Expand All @@ -56,7 +57,7 @@ export class LongPollingSubscription implements InternalSubscription {
// long timeout for long polling
const request = await this.client["generateFetchRequest"](this.form, "GET", {
timeout: 60 * 60 * 1000,
signal: this.abortController.signal,
signal: this.abortController.signal as AbortSignal,
});
debug(`HttpClient (subscribeResource) sending ${request.method} to ${request.url}`);

Expand Down
7 changes: 4 additions & 3 deletions packages/binding-http/test/http-server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class HttpServerTest {
actions: {},
});

let test: DataSchemaValue;
const test: DataSchemaValue = "ok";
testThing.setPropertyReadHandler("testMiddleware", () => Promise.resolve(test));
testThing.setPropertyReadHandler("testPassthrough", () => Promise.resolve(test));

Expand All @@ -96,6 +96,7 @@ class HttpServerTest {

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

return httpServer.stop();
}
Expand Down Expand Up @@ -586,7 +587,7 @@ class HttpServerTest {
},
},
});
let test: DataSchemaValue;
const test: DataSchemaValue = null;
testThing.setPropertyReadHandler("test", async (options) => {
expect(options?.uriVariables).to.deep.equal({ id: "testId", globalVarTest: "test1" });
return test;
Expand All @@ -602,7 +603,7 @@ class HttpServerTest {
const resp = await (
await fetch(uri + "properties/test?id=testId&globalVarTest=test1", { method: "GET" })
).text();
expect(resp).to.equal("");
expect(resp).to.equal("null");

return httpServer.stop();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/binding-mbus/src/mbus-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class MBusConnection {
client: any; // MBusClient.IMBusRTU
connecting: boolean;
connected: boolean;
timer?: NodeJS.Timer; // connection idle timer
timer?: NodeJS.Timeout; // connection idle timer
currentTransaction?: MBusTransaction; // transaction currently in progress or undefined
queue: Array<MBusTransaction>; // queue of further transactions
config: {
Expand Down
2 changes: 1 addition & 1 deletion packages/binding-modbus/src/modbus-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class ModbusConnection {
client: ModbusRTU;
connecting: boolean;
connected: boolean;
timer: NodeJS.Timer | null; // connection idle timer
timer: NodeJS.Timeout | null; // connection idle timer
currentTransaction: ModbusTransaction | null; // transaction currently in progress or null
queue: Array<ModbusTransaction>; // queue of further transactions
config: {
Expand Down
1 change: 0 additions & 1 deletion packages/binding-opcua/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"node-opcua-nodeid": "2.113.0",
"node-opcua-numeric-range": "2.113.0",
"node-opcua-pseudo-session": "2.113.0",
"node-opcua-pubsub-client": "0.19.1",
"node-opcua-service-browse": "2.113.0",
"node-opcua-service-translate-browse-path": "2.113.0",
"node-opcua-status-code": "2.110.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@thingweb/thing-model": "^1.0.1",
"ajv": "^8.11.0",
"commander": "^9.1.0",
"dotenv": "^8.6.0",
"dotenv": "^16.4.7",
"lodash": "^4.17.21",
"vm2": "3.9.18"
},
Expand Down
1 change: 1 addition & 0 deletions packages/examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"module": "commonjs",
"rootDir": "src",
"target": "ES2021",
"sourceMap": false,
Expand Down
4 changes: 1 addition & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"compilerOptions": {
"target": "ES2021",
"lib": ["dom"],
"skipLibCheck": false,
"module": "commonjs",
"module": "Node16",
"outDir": "dist",
"strict": true,
"composite": true,
Expand All @@ -16,7 +15,6 @@
"experimentalDecorators": true,
"declaration": true,
"esModuleInterop": true,
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"resolveJsonModule": false,
"skipDefaultLibCheck": false,
"allowJs": false,
Expand Down

0 comments on commit 2b1e766

Please sign in to comment.