首页 > 解决方案 > Angular - 重构相对导入

问题描述

不久前,我开始在 Angular 7 中进行编码,并即时学习它。最近我认识到,相对进口不是很理想。这就是为什么我将它添加到我的tsconfig.json

  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@application/*": [
        "src/app/application/*"
      ]
    }
  }

现在我想重构我的导入:

import { ApplicationLogService } from './../../../service/application-log.service';
import { ApplicationLogTableComponent } from './../../tables/application-log-table/application-log-table.component';

对此:

import { ApplicationLogService } from '@application/service/application-log.service';
import { ApplicationLogTableComponent } from '@application/components/tables/application-log-table/application-log-table.component';

由于我有很多相对导入,我正在寻找一种自动重构这些的方法。你知道有什么办法吗?

标签: angulartypescripttslint

解决方案


推荐阅读