diff --git a/Build/build-apple-cdn.ts b/Build/build-apple-cdn.ts index 77cc11cd..fc349405 100644 --- a/Build/build-apple-cdn.ts +++ b/Build/build-apple-cdn.ts @@ -19,10 +19,7 @@ export const getAppleCdnDomainsPromise = createMemoizedPromise(() => fsFetchCach export const buildAppleCdn = task(import.meta.path, async (span) => { const promise = getAppleCdnDomainsPromise(); - const peeked = Bun.peek(promise); - const res: string[] = peeked === promise - ? await span.traceChildPromise('get apple cdn domains', promise) - : (peeked as string[]); + const res: string[] = await span.traceChildPromise('get apple cdn domains', promise); const description = [ ...SHARED_DESCRIPTION, diff --git a/Build/build-chn-cidr.ts b/Build/build-chn-cidr.ts index bbc1c098..1e2ad46f 100644 --- a/Build/build-chn-cidr.ts +++ b/Build/build-chn-cidr.ts @@ -14,11 +14,7 @@ export const getChnCidrPromise = createMemoizedPromise(async () => { }); export const buildChnCidr = task(import.meta.path, async (span) => { - const cidrPromise = getChnCidrPromise(); - const peeked = Bun.peek(cidrPromise); - const filteredCidr: string[] = peeked === cidrPromise - ? await span.traceChildPromise('download chnroutes2', cidrPromise) - : (peeked as string[]); + const filteredCidr = await span.traceChildAsync('download chnroutes2', getChnCidrPromise); // Can not use SHARED_DESCRIPTION here as different license const description = [ diff --git a/Build/build-speedtest-domainset.ts b/Build/build-speedtest-domainset.ts index 84f4885f..e4a01ac7 100644 --- a/Build/build-speedtest-domainset.ts +++ b/Build/build-speedtest-domainset.ts @@ -21,7 +21,7 @@ const s = new Sema(2); const latestTopUserAgentsPromise = fsFetchCache.apply( 'https://cdn.jsdelivr.net/npm/top-user-agents@latest/src/desktop.json', () => fetchWithRetry('https://cdn.jsdelivr.net/npm/top-user-agents@latest/src/desktop.json') - .then(res => res.json()) + .then(res => res.json() as any) .then((userAgents: string[]) => userAgents.filter(ua => ua.startsWith('Mozilla/5.0 '))), { serializer: serializeArray, @@ -61,7 +61,7 @@ const querySpeedtestApi = async (keyword: string): Promise> retry: { retries: 2 } - })).then(r => r.json()).then((data: Array<{ url: string }>) => data.reduce( + })).then(r => r.json() as any).then((data: Array<{ url: string }>) => data.reduce( (prev, cur) => { const hn = getHostname(cur.url, { detectIp: false }); if (hn) { diff --git a/Build/build-telegram-cidr.ts b/Build/build-telegram-cidr.ts index b166403d..d55162e4 100644 --- a/Build/build-telegram-cidr.ts +++ b/Build/build-telegram-cidr.ts @@ -33,11 +33,7 @@ export const getTelegramCIDRPromise = createMemoizedPromise(async () => { }); export const buildTelegramCIDR = task(import.meta.path, async (span) => { - const promise = getTelegramCIDRPromise(); - const peeked = Bun.peek(promise); - const { date, results } = peeked === promise - ? await span.traceChildPromise('get telegram cidr', promise) - : (peeked as { date: Date, results: string[] }); + const { date, results } = await span.traceChildAsync('get telegram cidr', getTelegramCIDRPromise); if (results.length === 0) { throw new Error('Failed to fetch data!'); diff --git a/Build/download-previous-build.ts b/Build/download-previous-build.ts index ffa3fe2c..5b7a6419 100644 --- a/Build/download-previous-build.ts +++ b/Build/download-previous-build.ts @@ -65,10 +65,7 @@ export const downloadPreviousBuild = task(import.meta.path, async (span) => { const extract = tarStream.extract(); pipeline( - Readable.fromWeb( - // @ts-expect-error -- DOM type is incompatible with Node type - resp.body - ), + Readable.fromWeb(resp.body), gunzip, extract ); diff --git a/Build/lib/fetch-text-by-line.ts b/Build/lib/fetch-text-by-line.ts index 8ce2dcd8..cfa0e965 100644 --- a/Build/lib/fetch-text-by-line.ts +++ b/Build/lib/fetch-text-by-line.ts @@ -44,7 +44,6 @@ const getBunBlob = (file: string | URL | BunFile) => { return file; }; -// @ts-expect-error -- ReadableStream should be AsyncIterable export const readFileByLine: ((file: string | URL | BunFile) => AsyncIterable) = enableTextLineStream ? (file: string | URL | BunFile) => getBunBlob(file).stream().pipeThrough(new PolyfillTextDecoderStream()).pipeThrough(new TextLineStream()) : (file: string | URL | BunFile) => createTextLineAsyncIterableFromStreamSource(getBunBlob(file).stream()); @@ -59,7 +58,6 @@ const ensureResponseBody = (resp: Response) => { return resp.body; }; -// @ts-expect-error -- ReadableStream should be AsyncIterable export const createReadlineInterfaceFromResponse: ((resp: Response) => AsyncIterable) = enableTextLineStream ? (resp) => ensureResponseBody(resp).pipeThrough(new PolyfillTextDecoderStream()).pipeThrough(new TextLineStream()) : (resp) => createTextLineAsyncIterableFromStreamSource(ensureResponseBody(resp)); diff --git a/Build/lib/trie.ts b/Build/lib/trie.ts index 298648d4..a2247af4 100644 --- a/Build/lib/trie.ts +++ b/Build/lib/trie.ts @@ -7,7 +7,7 @@ const SENTINEL = Symbol('SENTINEL'); const PARENT = Symbol('Parent Node'); -const noop: VoidFunction = () => { /** noop */ }; +const noop = () => { /** noop */ }; type TrieNode = { [SENTINEL]: boolean, diff --git a/tsconfig.json b/tsconfig.json index d095f647..e5367f72 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "esnext", - "lib": ["DOM", "DOM.Iterable"], + "lib": ["ESNext"], "moduleDetection": "force", "module": "esnext", "moduleResolution": "bundler",