带有 allowSyntheticDefaultImports 的 ESLint

问题描述

如何配置 ESLint 在使用 allowSyntheticDefaultImports 时接受类型?

在我的代码中,我有这样的代码块:

type PromiseType = Promise<void> | Promise<FirebaseFirestore.WriteResult[]>

并且 VSCode 接受这一点,无需任何额外的导入。

但是,当我运行 eslint 时,我得到了:

35:46  error  'FirebaseFirestore' is not defined  no-undef

当我构建项目时,我得到了:

src/index.ts:83:22 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type 'PromiseType[]' is not assignable to parameter of type 'Iterable<void | PromiseLike<void>>'.
      The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
        Type 'IteratorResult<PromiseType,any>' is not assignable to type 'IteratorResult<void | PromiseLike<void>,any>'.
          Type 'IteratorYieldResult<PromiseType>' is not assignable to type 'IteratorResult<void | PromiseLike<void>,any>'.
            Type 'IteratorYieldResult<PromiseType>' is not assignable to type 'IteratorYieldResult<void | PromiseLike<void>>'.
              Type 'PromiseType' is not assignable to type 'void | PromiseLike<void>'.
                Type 'Promise<WriteResult[]>' is not assignable to type 'void | PromiseLike<void>'.
                  Type 'Promise<WriteResult[]>' is not assignable to type 'PromiseLike<void>'.
                    Types of property 'then' are incompatible.
                      Type '<TResult1 = WriteResult[],TResult2 = never>(onfulfilled?: ((value: WriteResult[]) => TResult1 | PromiseLike<TResult1>) | null | undefined,onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ... 1 more ... | undefined) => Promise<...>' is not assignable to type '<TResult1 = void,TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null | undefined,onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => PromiseLike<...>'.
                        Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
                          Types of parameters 'value' and 'value' are incompatible.
                            Type 'WriteResult[]' is not assignable to type 'void'.

83   return Promise.all(promises)
                        ~~~~~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:226:5
    226     all<T>(values: Iterable<T | PromiseLike<T>>): Promise<T[]>;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The last overload is declared here.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...