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

223
Views
Does typescript automatically bundle all exports as default?

import * as mongodbModule from 'mongodb';

The above code is the standard es6 way to import mongodb in nodejs, doing it like so import mongodbModule from 'mongodb' is supposed to throw an error because the mongodb module has no default export; but it still works. I discovered that the mongodb module is a typescript file hence my question.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Whether or not you can write import mongodbModule from 'mongodb' without getting an error depends on your configuration in .tsconfig. In order to enable this, you use the setting --allowSyntheticDefaultImports. As explained in the docs, it's not really that typescript creates the bundle, it's more that typescript assumes that the bundle exists and allows you to import it, while babel handles the actual creation of it.

This flag does not affect the JavaScript emitted by TypeScript, it only for the type checking. This option brings the behavior of TypeScript in-line with Babel, where extra code is emitted to make using a default export of a module more ergonomic. ... For convenience, transpilers like Babel will automatically create a default if one isn’t created.

over 4 years ago · Santiago Trujillo Report
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!