Skip to content

Commit fc71a4b

Browse files
fix: prevent ReferenceError, update compatibility to ES2020 and Node 18+ (#356)
1 parent 3799863 commit fc71a4b

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ TypeScript >= 4.5 is supported.
313313

314314
The following runtimes are supported:
315315

316-
- Node.js 16 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
316+
- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
317317
- Deno v1.28.0 or higher, using `import OpenAI from "npm:openai"`.
318318
- Bun 1.0 or later.
319319
- Cloudflare Workers.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1",
8383
"format": "prettier --write --cache --cache-strategy metadata . !dist",
8484
"tsn": "ts-node -r tsconfig-paths/register",
85+
"lint": "eslint --ext ts,js .",
8586
"fix": "eslint --fix --ext ts,js ."
8687
},
8788
"dependencies": {

src/_shims/node-runtime.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ async function getMultipartRequestOptions<T extends {} = Record<string, unknown>
5959
export function getRuntime(): Shims {
6060
// Polyfill global object if needed.
6161
if (typeof AbortController === 'undefined') {
62-
// @ts-ignore
63-
AbortController = AbortControllerPolyfill;
62+
// @ts-expect-error (the types are subtly different, but compatible in practice)
63+
globalThis.AbortController = AbortControllerPolyfill;
6464
}
6565
return {
6666
kind: 'node',

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"include": ["src", "tests", "examples"],
33
"exclude": ["src/_shims/**/*-deno.ts"],
44
"compilerOptions": {
5-
"target": "es2019",
5+
"target": "es2020",
66
"lib": ["es2020"],
77
"module": "commonjs",
88
"moduleResolution": "node",

0 commit comments

Comments
 (0)