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

592
Visualizações
Order of Imports Matters When Using Default Export?

I was refactoring some code, namely organizing the imports (sorting, removing unused, etc.)

I had three files:

  1. Controller
  2. OverrideService (uses default export)
  3. RunService
  • Controller depends on both OverrideService & RunService.
  • RunService depends on OverrideService

I came across this issue:

In Controller.ts, originally the order of imports was like this:

import { RunService } from '../services/RunService';
import OverrideService from '../services/OverrideService';

When imports were sorted alphabetically the code stopped working properly:

import OverrideService from '../services/OverrideService';
import { RunService } from '../services/RunService';

Giving an error:

TypeError: OverrideService_1.default.overrideDependencyValidator is not a function

When I changed the default export to a named export in OverrideService, and updated the imports to be like this, the issue is no longer there.

import { OverrideService } from '../services/OverrideService';
import { RunService } from '../services/RunService';

I did some research but couldn't find any information on default vs named exports aside from tree-shaking and other irrelevant differences.

What would be the reason a default export cause an issue when reordering imports?

about 4 years ago · Juan Pablo Isaza
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