W
W
Wasya UK2018-06-30 16:22:24
Node.js
Wasya UK, 2018-06-30 16:22:24

Why does the module not want to be declared?

1 module is declared fine, but when I try to do the same with koa-connect-flash, I get the error " Circular definition of import alias 'connectFlash' ", what could be the problem?

declare module 'koa-connect-flash' {
  import connectFlash from 'koa-connect-flash';
  export default connectFlash;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-06-30
@dmc1989

Cyclic dependency. You declare that your module uses itself. You can't do that. Only third-party modules can be imported into the declaration if they are used by the library.
The simplest option, in your case:

declare module 'koa-connect-flash' {
  const def: any;
  export default def;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question