What are some use cases for using named imports with the import keyword (to import a default export)?

Question

What are some use cases for using named imports with the import keyword (to import a default export)?

Answer

We can combine named imports with the import statement (to import a default export) for the same reasons we would combine named exports and default exports.

Generally, this includes importing the expected export of a module, the default export, importing any utility exports that may not be necessary but could come in handy, the named exports, and/or importing pieces of a module that are the internals of a private variable without exposing the entire private variable (again these would be named exports).

5 Likes

Sounds easier and cleaner to put export before any thing we want to, like:

export let flightRequirements = { requiredStaff: 4, requiredSpeedRange: 700 };

And just using at the beginning:
import {flightRequirements, etc} from './airplane'

or even for tiny files import * from ‘./airplane.js’

2 Likes