lib.es2015.promise.d.ts(33, 34):未提供“值”的参数

Pun*_*ddy 2 promise typescript nuxt.js

                                  22:16:16:25
Run Code Online (Sandbox Code Playgroud)

TS2556:预期有 1 个参数,但得到 0 个或更多。

           config.promise.then((...args: any[]) => {
                if (this._isCancelled) return;
                this._isCompleted = true;
                resolve(...args);
                        ^^^^^^^
            }, (error)=>{
                if (this._isCancelled) return;
                this._isCompleted = false;
                reject(error);
            });
Run Code Online (Sandbox Code Playgroud)

tsconfig.json

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "lib": [
      "ESNext",
      "ESNext.AsyncIterable",
      "DOM"
    ],
    "esModuleInterop": true,
    "paths": {
      "~/*": [
        "./*"
      ],
      "@/*": [
        "./*"
      ]
    },
    "types": [
      "@types/node",
      "@nuxtjs/axios",
      "@nuxt/types",
      "types-lib/*"
    ]
  },
  "exclude": [
    "node_modules"
  ]
}
Run Code Online (Sandbox Code Playgroud)

代码运行得更好,但文件中出现错误

resolve(...args)更改为resolve(args)后

我收到此错误:

类型“any[]”的参数不可分配给类型“T |”的参数 承诺喜欢'。类型“any[]”不可分配给类型“T”。'T' 可以用与 'any[]' 无关的任意类型实例化

还将目标更改为 es6、es5、es2016、es2015 等,但不起作用

Ahm*_*tah 7

我通过使用以下方法解决了这个问题:

`resolve(null);`
Run Code Online (Sandbox Code Playgroud)

代替:

'resolve();`
Run Code Online (Sandbox Code Playgroud)