From 1bc5f7683e6b0f2b6440d8bb6fdfab8a8de8f350 Mon Sep 17 00:00:00 2001 From: kittydev <108918571+11suixing11@users.noreply.github.com> Date: Mon, 27 Jul 2026 06:16:30 +0800 Subject: [PATCH] test: type-check README quickstart example Add a compile-only quickstart example that mirrors the README client setup without sending a request. Run TypeScript checking from the existing test script so the example stays covered by the normal test gate. Signed-off-by: kittydev <108918571+11suixing11@users.noreply.github.com> --- examples/readme-quickstart.ts | 16 ++++++++++++++++ scripts/test | 2 ++ 2 files changed, 18 insertions(+) create mode 100644 examples/readme-quickstart.ts diff --git a/examples/readme-quickstart.ts b/examples/readme-quickstart.ts new file mode 100644 index 0000000..1af05bc --- /dev/null +++ b/examples/readme-quickstart.ts @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: 2026 Xquik contributors +// +// SPDX-License-Identifier: Apache-2.0 + +import XTwitterScraper from 'x-twitter-scraper'; + +// Compile-only mirror of the README quickstart. It intentionally constructs +// the client and request params without sending a network request. +const client = new XTwitterScraper({ + apiKey: process.env['X_TWITTER_SCRAPER_API_KEY'], +}); + +const searchParams: XTwitterScraper.X.TweetSearchParams = { q: 'from:elonmusk', limit: 10 }; + +void client; +void searchParams; diff --git a/scripts/test b/scripts/test index 4981e8a..ffc8aad 100755 --- a/scripts/test +++ b/scripts/test @@ -8,6 +8,8 @@ set -e cd "$(dirname "$0")/.." +echo "==> Checking types" +./node_modules/typescript/bin/tsc --project tsconfig.json --noEmit echo "==> Running tests"