0

Some times while importing why do we need to use “*” For example :

import axios from 'axios'
import * as proxy from 'proxy-agent'
Phil
  • 157,677
  • 23
  • 242
  • 245
sravan ganji
  • 4,774
  • 3
  • 25
  • 37
  • 1
    Because those modules have no default export – Phil Feb 22 '19 at 00:43
  • If there is no default , can’t we import like import {someModlue} from ‘test’ – sravan ganji Feb 22 '19 at 00:48
  • 1
    @sravankumarganji Sure, but it depends on how you want to refer to the object later on. – jhpratt Feb 22 '19 at 00:52
  • It's muddied by the fact that `import * as foo` in TS was a hack to allow importing CommonJS modules using ES6 syntax, though the two are not strictly compatible, whereas Babel would let you just use default `import foo`. Later `esModuleInterop` was added to TS to allow you to use `import foo` in the same way as Babel. – Aaron Beall Feb 22 '19 at 02:56

0 Answers0