Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
Problems with circular imports using index.js?

Given the following file structure:

myFiles
├── index.js
├── getTrue.js
└── dependentGetFalse.js

And the following code

// index.js
export { getTrue } from './getTrue'
export { dependentGetFalse } from './dependentGetFalse'
// getTrue.js
export const getTrue = () => true
// dependentGetFalse.js
import { getTrue } from '.'
export const dependentGetFalse = () => !getTrue()

Where there's (what I assume to be) a circular import between dependentGetFalse.js and index.js.

What problems will arise from this? Or is it ok to have?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

If your codes run flawless and you are comfortable with them, It is ok to have this circular situation

about 4 years ago · Juan Pablo Isaza Relatório

0

It's best to avoid using '.' imports.

Try this:

// dependentGetFalse.js
import { getTrue } from './getTrue'
export const dependentGetFalse = () => !getTrue()

index.js is useful when you try to import something from outside of this folder.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda