From f4089408b224dcfb6b183ed7679d48721d64a861 Mon Sep 17 00:00:00 2001 From: Josef Strzibny Date: Tue, 18 Aug 2026 12:01:24 +0200 Subject: [PATCH 1/2] Fix Deno 2 lint and type compatibility --- deno.json | 7 +++++++ examples/deno/basic_example.ts | 2 +- examples/deno/pagination_example.ts | 2 +- scripts/build_npm.ts | 2 +- src/utils.ts | 2 +- tests/serpapi_test.ts | 14 ++++---------- tests/utils_test.ts | 13 ++++--------- tests/validators_test.ts | 11 ++--------- 8 files changed, 21 insertions(+), 32 deletions(-) diff --git a/deno.json b/deno.json index 4021446..fc2a984 100644 --- a/deno.json +++ b/deno.json @@ -6,6 +6,13 @@ "test:cov": "rm -rf cov_profile && deno task test --coverage=cov_profile && deno coverage cov_profile", "npm": "deno run -A scripts/build_npm.ts" }, + "imports": { + "@deno/dnt": "https://deno.land/x/dnt@0.40.0/mod.ts", + "@std/dotenv": "https://deno.land/std@0.173.0/dotenv/mod.ts", + "@std/testing/asserts": "https://deno.land/std@0.170.0/testing/asserts.ts", + "@std/testing/bdd": "https://deno.land/std@0.170.0/testing/bdd.ts", + "@std/testing/mock": "https://deno.land/std@0.170.0/testing/mock.ts" + }, "fmt": { "exclude": ["npm/", "examples/node", "smoke_tests/"] }, diff --git a/examples/deno/basic_example.ts b/examples/deno/basic_example.ts index 30e6aa3..9ef5f1e 100644 --- a/examples/deno/basic_example.ts +++ b/examples/deno/basic_example.ts @@ -1,4 +1,4 @@ -import { loadSync } from "https://deno.land/std@0.173.0/dotenv/mod.ts"; +import { loadSync } from "@std/dotenv"; import { config, getJson } from "../../mod.ts"; const { API_KEY: apiKey } = loadSync(); diff --git a/examples/deno/pagination_example.ts b/examples/deno/pagination_example.ts index 9c683f9..6999deb 100644 --- a/examples/deno/pagination_example.ts +++ b/examples/deno/pagination_example.ts @@ -1,4 +1,4 @@ -import { loadSync } from "https://deno.land/std@0.173.0/dotenv/mod.ts"; +import { loadSync } from "@std/dotenv"; import { config, getJson } from "../../mod.ts"; const { API_KEY: apiKey } = loadSync(); diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts index 8e817cd..69762b0 100644 --- a/scripts/build_npm.ts +++ b/scripts/build_npm.ts @@ -1,4 +1,4 @@ -import { build, emptyDir } from "https://deno.land/x/dnt@0.40.0/mod.ts"; +import { build, emptyDir } from "@deno/dnt"; import { version } from "../version.ts"; await emptyDir("./npm"); diff --git a/src/utils.ts b/src/utils.ts index 8bb21f9..a490688 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -80,7 +80,7 @@ export function execute( }); return new Promise((resolve, reject) => { - let timer: number; + let timer: ReturnType; const handleResponse = (resp: http.IncomingMessage) => { resp.setEncoding("utf8"); diff --git a/tests/serpapi_test.ts b/tests/serpapi_test.ts index 7daf994..85dceae 100644 --- a/tests/serpapi_test.ts +++ b/tests/serpapi_test.ts @@ -1,11 +1,5 @@ -import { loadSync } from "https://deno.land/std@0.170.0/dotenv/mod.ts"; -import { - afterAll, - afterEach, - beforeAll, - describe, - it, -} from "https://deno.land/std@0.170.0/testing/bdd.ts"; +import { loadSync } from "@std/dotenv"; +import { afterAll, afterEach, beforeAll, describe, it } from "@std/testing/bdd"; import { assert, assertArrayIncludes, @@ -14,14 +8,14 @@ import { assertInstanceOf, assertRejects, assertStringIncludes, -} from "https://deno.land/std@0.170.0/testing/asserts.ts"; +} from "@std/testing/asserts"; import { assertSpyCallArg, assertSpyCalls, spy, Stub, stub, -} from "https://deno.land/std@0.170.0/testing/mock.ts"; +} from "@std/testing/mock"; import { _internals } from "../src/utils.ts"; import { BaseResponse, diff --git a/tests/utils_test.ts b/tests/utils_test.ts index 4ebfa97..46f444d 100644 --- a/tests/utils_test.ts +++ b/tests/utils_test.ts @@ -1,18 +1,13 @@ import http from "node:http"; import qs from "node:querystring"; -import { loadSync } from "https://deno.land/std@0.170.0/dotenv/mod.ts"; -import { - afterAll, - beforeAll, - describe, - it, -} from "https://deno.land/std@0.170.0/testing/bdd.ts"; -import { Stub, stub } from "https://deno.land/std@0.170.0/testing/mock.ts"; +import { loadSync } from "@std/dotenv"; +import { afterAll, beforeAll, describe, it } from "@std/testing/bdd"; +import { Stub, stub } from "@std/testing/mock"; import { assertEquals, assertInstanceOf, assertMatch, -} from "https://deno.land/std@0.170.0/testing/asserts.ts"; +} from "@std/testing/asserts"; import { _internals, buildRequestOptions, diff --git a/tests/validators_test.ts b/tests/validators_test.ts index f401d74..770ebfa 100644 --- a/tests/validators_test.ts +++ b/tests/validators_test.ts @@ -1,12 +1,5 @@ -import { - afterEach, - describe, - it, -} from "https://deno.land/std@0.170.0/testing/bdd.ts"; -import { - assertEquals, - assertThrows, -} from "https://deno.land/std@0.170.0/testing/asserts.ts"; +import { afterEach, describe, it } from "@std/testing/bdd"; +import { assertEquals, assertThrows } from "@std/testing/asserts"; import { validateApiKey, validateTimeout } from "../src/validators.ts"; import { config, InvalidTimeoutError, MissingApiKeyError } from "../mod.ts"; From 45e36bd323a30c04f96411641a24712359c2f270 Mon Sep 17 00:00:00 2001 From: Josef Strzibny Date: Tue, 8 Sep 2026 09:48:18 +0200 Subject: [PATCH 2/2] Update Deno compatibility note --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ac45f9c..ef8d716 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ `serpapi-javascript` is developed using Deno. Refer to https://deno.land/manual/getting_started/installation to install Deno. -Ensure you're running at least Deno v1.28.3. +Ensure you're running at least Deno v1.46.3. ```bash deno --version