Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
674 views
in Technique[技术] by (71.8m points)

typescript - ESLint with allowSyntheticDefaultImports

How to configure ESLint to accept types when using allowSyntheticDefaultImports?

In my code I have block of code like this:

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

and the VSCode accept this, without any extra import.

But, when I run eslint I got:

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

And when I build the project I got:

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.
question from:https://stackoverflow.com/questions/65921266/eslint-with-allowsyntheticdefaultimports

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...