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 const a = 1;
export const b = 2;
export const c = 3;
export default const d = 4;
Then this would be true of related imports:
import * as Foo from "./file.js";
Foo.a // -> 1
Foo.b // -> 2
Foo.c // -> 3
Foo.d // -> 4
import Foo from "./file.js";
Foo // -> 4
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:
as) Example - DESIREDimport * from "./file.js";
a // -> 1
b // -> 2
c // -> 3
d // -> 4
Is this possible?