Import two exported classes with the same name

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'

Answers


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.


Need Your Help

Replace a character at a specific index in a string?

java string replace indexing character

I'm trying to replace a character at a specific index in a string.

Adding Unit Tests to an already existing project?

iphone ios xcode unit-testing xcode4

When you create an XCode 4 project, it asks you if you want to include unit testing. But how do you add it to a project that's been created without them?