Skip to content

Commit 0ddf668

Browse files
committed
more type fixes
1 parent 7efb5ec commit 0ddf668

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class SenderOptions {
180180
* - 'agent' is a custom http/https agent used by the <a href="Sender.html">Sender</a> when http/https transport is used. <br>
181181
* A <i>http.Agent</i> or <i>https.Agent</i> object is expected.
182182
*/
183-
constructor(configurationString: string, extraOptions: ExtraOptions = undefined) {
183+
constructor(configurationString: string, extraOptions?: ExtraOptions) {
184184
parseConfigurationString(this, configurationString);
185185

186186
if (extraOptions) {
@@ -231,7 +231,7 @@ class SenderOptions {
231231
*
232232
* @return {SenderOptions} A Sender configuration object initialized from the provided configuration string.
233233
*/
234-
static fromConfig(configurationString: string, extraOptions: ExtraOptions = undefined): SenderOptions {
234+
static fromConfig(configurationString: string, extraOptions?: ExtraOptions): SenderOptions {
235235
return new SenderOptions(configurationString, extraOptions);
236236
}
237237

@@ -246,7 +246,7 @@ class SenderOptions {
246246
*
247247
* @return {SenderOptions} A Sender configuration object initialized from the <b>QDB_CLIENT_CONF</b> environment variable.
248248
*/
249-
static fromEnv(extraOptions: ExtraOptions = undefined): SenderOptions {
249+
static fromEnv(extraOptions?: ExtraOptions): SenderOptions {
250250
return SenderOptions.fromConfig(process.env.QDB_CLIENT_CONF, extraOptions);
251251
}
252252
}

src/sender.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class Sender {
128128
*
129129
* @return {Sender} A Sender object initialized from the provided configuration string.
130130
*/
131-
static fromConfig(configurationString: string, extraOptions: ExtraOptions = undefined): Sender {
131+
static fromConfig(configurationString: string, extraOptions?: ExtraOptions): Sender {
132132
return new Sender(
133133
SenderOptions.fromConfig(configurationString, extraOptions),
134134
);
@@ -145,7 +145,7 @@ class Sender {
145145
*
146146
* @return {Sender} A Sender object initialized from the <b>QDB_CLIENT_CONF</b> environment variable.
147147
*/
148-
static fromEnv(extraOptions: ExtraOptions = undefined): Sender {
148+
static fromEnv(extraOptions?: ExtraOptions): Sender {
149149
return new Sender(
150150
SenderOptions.fromConfig(process.env.QDB_CLIENT_CONF, extraOptions),
151151
);
@@ -488,12 +488,12 @@ class Sender {
488488
name: string,
489489
value: unknown,
490490
writeValue: () => void,
491-
valueType?: string | null,
491+
valueType?: string
492492
) {
493493
if (typeof name !== "string") {
494494
throw new Error(`Column name must be a string, received ${typeof name}`);
495495
}
496-
if (valueType != null && typeof value !== valueType) {
496+
if (valueType && typeof value !== valueType) {
497497
throw new Error(
498498
`Column value must be of type ${valueType}, received ${typeof value}`,
499499
);

test/sender.integration.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22
import { describe, it, expect, beforeAll, afterAll } from "vitest";
3-
import { GenericContainer } from "testcontainers";
3+
import { GenericContainer, StartedTestContainer } from "testcontainers";
44
import http from "http";
55

66
import { Sender } from "../src";
@@ -15,9 +15,9 @@ async function sleep(ms: number) {
1515
}
1616

1717
describe("Sender tests with containerized QuestDB instance", () => {
18-
let container: any;
18+
let container: StartedTestContainer;
1919

20-
async function query(container: any, query: string) {
20+
async function query(container: StartedTestContainer, query: string) {
2121
const options: http.RequestOptions = {
2222
hostname: container.getHost(),
2323
port: container.getMappedPort(QUESTDB_HTTP_PORT),
@@ -46,7 +46,7 @@ describe("Sender tests with containerized QuestDB instance", () => {
4646
});
4747
}
4848

49-
async function runSelect(container: any, select: string, expectedCount: number, timeout = 60000) {
49+
async function runSelect(container: StartedTestContainer, select: string, expectedCount: number, timeout = 60000) {
5050
const interval = 500;
5151
const num = timeout / interval;
5252
let selectResult: any;
@@ -62,7 +62,7 @@ describe("Sender tests with containerized QuestDB instance", () => {
6262
);
6363
}
6464

65-
async function waitForTable(container: any, tableName: string, timeout = 30000) {
65+
async function waitForTable(container: StartedTestContainer, tableName: string, timeout = 30000) {
6666
await runSelect(container, `tables() where table_name='${tableName}'`, 1, timeout);
6767
}
6868

test/util/proxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Proxy {
2222
console.info("remote connection closed");
2323
});
2424

25-
this.remote.on("error", (err: unknown) => {
25+
this.remote.on("error", (err: Error) => {
2626
console.error(`remote connection: ${err}`);
2727
});
2828
}

0 commit comments

Comments
 (0)