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

272
Visualizações
Wildcard imports with `as` in JavaScript

I am primarily a JavaScript developer, but with some recent exposure to Java, I rather enjoy how Java handles wildcard imports. Without using any as statements, the import takes all named imports and imports them directly into the current namespace/scope as variables/classes without any need for there to be one variable they are properties of.

Is this possible in JavaScript. For example, if I make this export:

Export Example

export const a = 1;
export const b = 2;
export const c = 3;
export default const d = 4;

Then this would be true of related imports:

Wildcard Imports Example

import * as Foo from "./file.js";

Foo.a // -> 1
Foo.b // -> 2
Foo.c // -> 3
Foo.d // -> 4

Default Import Example

import Foo from "./file.js";

Foo // -> 4

Specific/Named Imports Example

import { a, b } from "./file.js";

a // -> 1
b // -> 2
c // -> undefined
d // -> undefined

What I am looking for, which it appears Java supports, is the ability to do something like the current JavaScript wildcard import, but without the as statement, like the below example, where all named exports are imported as fully accessible variables within the current namespace/scope:

Wildcard Imports (without as) Example - DESIRED

import * from "./file.js";

a // -> 1
b // -> 2
c // -> 3
d // -> 4

Is this possible?

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