1

I have two functions that can each call one another. While I could put them in the same file I will come across naming conflicts (this is all generated code) so I'd like to keep them separate. Unfortunately I get a circular dependency error.

import { myFuncTwo } from './my-func-two';

export function myFuncOne(){
    ...
    myFuncTwo(...);
    ...
}
import { myFuncOne } from './my-func-one';

export function myFuncTwo(){
    ...
    myFuncOne(...);
    ...
}

So my question is, is there anything I can do to say ignore this? Something else I can try? While I can have them generated into a single file like this:

export function myFuncOne(){
    ...
    myFuncTwo(...);
    ...
}
export function myFuncTwo(){
    ...
    myFuncOne(...);
    ...
}

I'd rather not make that change as having them separated is ideal. I have 1000's of these and modifying the generated code will potentially introduce other errors.

I don't want to turn off the WARNING in Circular dependency detected: as it's likely still useful but I'm uncertain how to handle this case.

I can have interfaces that do this sort of thing and don't present warnings but not with functions it would seem.

Mathew Berg
  • 28,625
  • 11
  • 69
  • 90

0 Answers0