3

I want something like this:

import {get, set} as moduleName from 'module-name'

moduleName.get()

The reason is because sometimes methods of different modules can have the same name, and I don't want to import the whole module because of it

1
  • You can do import {get as g, set as s} from "module-name" but import {get, set} as moduleName from 'module-name' is not valid. Commented Jul 15, 2022 at 10:37

2 Answers 2

2

There is no such thing as:

import {get, set} as moduleName from 'module-name'

You can either do it like this:

import * as moduleName from 'module-name';
moduleName.get();  //all the exported items will be accessible.

Or this:

import {get as moduleNameGet, set as moduleNameSet} from 'module-name';
moduleNameGet();

Please check this out

Sign up to request clarification or add additional context in comments.

Comments

0

You can use below syntax

import * as module from "module-name";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.