我可以为 angular/typescript 中的导入库指定别名吗?

Can I give an alias to an imported library in angular/typescript?

我遇到以下问题。我已经使用一个名为 Location 的模型工作了一段时间,但现在我发现 angular 也有这样一个模型,所以我在一个需要两者的组件中发生以下碰撞:

import { Location } from 'src/app/core/models/location.model';
import { Location }  from '@angular/common';

是否有任何解决方法,例如为库指定别名?

当前问题:

Duplicate identifier 'Location'.ts(2300)

您可以使用 as 关键字为导入别名以避免名称冲突。

import { Location as LocationModel } from 'src/app/core/models/location.model';
import { Location }  from '@angular/common';