如何解决带有 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 举报,一经查实,本站将立刻删除。