From cada6efd4ef821743897b699b002a26a88d835c1 Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:27:25 -0400 Subject: [PATCH] fix: prevent ReferenceError, update compatibility to ES2020 and Node 18+ (#169) --- README.md | 2 +- package.json | 1 + src/_shims/node-runtime.ts | 4 ++-- tsconfig.json | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fff3970..83cf134 100644 --- a/README.md +++ b/README.md @@ -336,7 +336,7 @@ TypeScript >= 4.5 is supported. The following runtimes are supported: -- Node.js 16 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions. +- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions. - Deno v1.28.0 or higher, using `import Anthropic from "npm:@anthropic-ai/sdk"`. - Bun 1.0 or later. - Cloudflare Workers. diff --git a/package.json b/package.json index 6b3561d..81bfb31 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1", "format": "prettier --write --cache --cache-strategy metadata . !dist", "tsn": "ts-node -r tsconfig-paths/register", + "lint": "eslint --ext ts,js .", "fix": "eslint --fix --ext ts,js ." }, "dependencies": { diff --git a/src/_shims/node-runtime.ts b/src/_shims/node-runtime.ts index 2e5ab56..e2398e2 100644 --- a/src/_shims/node-runtime.ts +++ b/src/_shims/node-runtime.ts @@ -59,8 +59,8 @@ async function getMultipartRequestOptions export function getRuntime(): Shims { // Polyfill global object if needed. if (typeof AbortController === 'undefined') { - // @ts-ignore - AbortController = AbortControllerPolyfill; + // @ts-expect-error (the types are subtly different, but compatible in practice) + globalThis.AbortController = AbortControllerPolyfill; } return { kind: 'node', diff --git a/tsconfig.json b/tsconfig.json index 7235f91..7a0ad05 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "include": ["src", "tests", "examples"], "exclude": ["src/_shims/**/*-deno.ts"], "compilerOptions": { - "target": "es2019", + "target": "es2020", "lib": ["es2020"], "module": "commonjs", "moduleResolution": "node",