Skip to content

Commit 52c335f

Browse files
committed
ts
1 parent a73f100 commit 52c335f

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

examples/io/tcp/mqttclient/mqttclient.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class MQTTClient {
7575
id: options.id ?? "",
7676
clean: options.clean ?? true,
7777
keepalive: options.keepAlive ?? options.keepalive ?? 0, // for compatibilty. should eventually be removed
78+
/** @type {any[] & {timer?: Timer}} */
7879
pending: []
7980
};
8081

@@ -270,11 +271,13 @@ class MQTTClient {
270271
return (this.#writable > Overhead) ? (this.#writable - Overhead) : 0;
271272
}
272273
read(count = this.#payload) {
274+
/** @type {BufferLike} */
273275
let buffer;
274276
if ("object" === typeof count) {
275277
buffer = count;
276278
count = buffer.byteLength;
277279

280+
// @ts-expect-error when BYTES_PER_ELEMENT is undefined, this check works as intended
278281
if (buffer.BYTES_PER_ELEMENT > 1) // allows ArrayBuffer, SharedArrayBuffer, Uint8Array, Int8Array, DataView. disallows multi-byte element arrays.
279282
throw new Error("invalid buffer");
280283
}

modules/io/socket/zephyr/listener.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2025 Moddable Tech, Inc.
2+
* Copyright (c) 2019-2026 Moddable Tech, Inc.
33
*
44
* This file is part of the Moddable SDK Runtime.
55
*
@@ -24,6 +24,7 @@ class Listener extends Native("xs_listener_destructor_") {
2424
constructor(options) { super(); native("xs_listener_constructor").call(this, options); };
2525
close() { return native("xs_listener_close_").call(this); }
2626
read() {
27+
// @ts-expect-error no arguments is internal-only use of TCP constructor
2728
return native("xs_listener_read").call(this, new TCP);
2829
}
2930

tools/mcdevicetree.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,16 @@ device.spi = {};
333333
export default device;
334334
`;
335335

336-
if (state.tsDeviceIO || state.tsDeviceNetwork) {
336+
if (state.tsDeviceIO || state.tsDeviceNetworkInterface) {
337337
state.tsCode += `declare module "embedded:provider/builtin" {\n`;
338338
state.tsCode += `\tinterface Device {\n`;
339339
if (state.tsDeviceIO)
340340
state.tsCode += `\t\tio: DeviceIO;\n`;
341-
if (state.tsDeviceNetwork)
342-
state.tsCode += `\t\tnetwork: DeviceNetwork;\n`;
341+
if (state.tsDeviceNetworkInterface) {
342+
state.tsCode += `\t\tnetwork: {\n`;
343+
state.tsCode += `\t\t\tinterface: DeviceNetworkInterface;\n`;
344+
state.tsCode += `\t\t}\n`;
345+
}
343346
state.tsCode += `\t}\n`;
344347
state.tsCode += `}\n`;
345348
}
@@ -914,15 +917,13 @@ declare module "embedded:provider/builtin" {
914917
import ${nic.name} from "${nic.import}";
915918
import type {PortSpecifier} from "embedded:io/_common";
916919
917-
interface DeviceNetwork {
918-
interface: {
919-
${nic.label}: {io: typeof ${nic.name}, kind: string, port: PortSpecifier};
920-
}
920+
interface DeviceNetworkInterface {
921+
${nic.label}: {io: typeof ${nic.name}, kind: string, port: PortSpecifier};
921922
}
922923
}
923924
`;
924925
});
925-
state.tsDeviceNetwork = true;
926+
state.tsDeviceNetworkInterface = true;
926927
}
927928

928929

typings/dns/serializer.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ declare module "dns/serializer" {
2525
opcode?: (typeof DNS.OPCODE)[keyof (typeof DNS.OPCODE)],
2626
query?: boolean,
2727
authoritative?: boolean,
28-
id?: number
28+
id?: number,
29+
recursionDesired?: boolean,
2930
});
3031
add(
3132
section: (typeof DNS.SECTION)[keyof (typeof DNS.SECTION)],
3233
name: string,
3334
type: (typeof DNS.RR)[keyof (typeof DNS.RR)],
3435
classType: (typeof DNS.CLASS)[keyof (typeof DNS.CLASS)],
35-
ttl: number,
36+
ttl?: number,
3637
data?: ArrayBuffer
3738
): void;
3839
build(): ArrayBuffer;

typings/embedded_network/mqtt/client.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ declare module "embedded:network/mqtt/client" {
5353
export default class MQTTClient {
5454
constructor(options: Options)
5555
read(count: number): ArrayBuffer
56-
write(data: Buffer, options: WriteOptions): number
56+
read(buffer: BufferLike): number
57+
write(data: BufferLike, options: WriteOptions): number
5758
close(): void
5859

5960
static CONNECT: 1

0 commit comments

Comments
 (0)