NodeJS next.js 13使用openai 4.0包时私有标识符的构建错误

bbuxkriu  于 2023-10-17  发布在  Node.js
关注(0)|答案(1)|浏览(163)

我在我的next.js应用程序中添加了新的4.0 openai包,我只在应用程序的服务器中使用它,当构建时,我得到了错误。

- info Linting and checking validity of types .Failed to compile.

./node_modules/openai/src/core.ts:539:3
Type error: Private identifiers are only available when targeting ECMAScript 2015 and higher.

  537 |
  538 | export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
> 539 |   #client: APIClient;
      |   ^
  540 |   protected options: FinalRequestOptions;
  541 |
  542 |   protected response: Response;

我尝试将tsconfig目标更改为es6,es2015,esnext,但似乎不起作用,skipLibCheck已启用,因此我更加困惑为什么会发生这种情况
这是我的tsconfig:

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "$/*": [
        "./src/*"
      ],
      "$app/*": [
        "./src/app/*"
      ],
      "$cmp/*": [
        "./src/components/*"
      ],
      "$types/*": [
        "./src/types/*"
      ],
      "$assets/*": [
        "./src/assets/*"
      ],
      "$lib/*": [
        "./src/lib/*"
      ],
    }
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx",
    ".next/types/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}
e0bqpujr

e0bqpujr1#

我没有设法更改TS目标,但问题是因为我的自动导入从OpenAI模块的SRC文件夹导入,而不是类型声明

相关问题