Import two exported classes with the same name

AngularTypescriptIonic2

Angular Problem Overview


In typescript, using Angular 2, I need to import two classes with the same name, but lying in different paths.

The project is quite too big that I find it hard to change the exported class names.

Is there any way to alias the imported classes,

import {Class1} from '../location1/class1'
import {Class1} from '../location2/class1'

Angular Solutions


Solution 1 - Angular

You can use as like this:

import {Class1} from '../location1/class1'
import {Class1 as Alias} from '../location2/class1'

You can find more about the ES6 import statement here.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRizan ZakyView Question on Stackoverflow
Solution 1 - AngulartoskvView Answer on Stackoverflow