Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

589
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!