打字稿选项。具有嵌套目录的BaseUrl设置

时间:2018-06-12 08:22:45

标签: angular typescript webpack

使用' baseUrl'物业与“路径”相结合财产如此:

"baseUrl": "./src",
"paths": {
  "app-component": [ "app/app.component"],
  "test-component": [ "app/test/test.component" ]
}

一切都很好,但改为:

"baseUrl": "./src/app",
"paths": {
  "app-component": [ "app.component"],
  "test-component": [ "test/test.component" ]
}

编译器抱怨它无法找到引用的模块。

文档或搜索逻辑实现中是否缺少某些内容?

编辑1

模块引用为:

import { AppComponent } from 'app-component';
import { TestComponent } from 'test-component';

1 个答案:

答案 0 :(得分:0)

检查纯tsc编译(没有产生任何错误)并使用ng eject弹出webpack.config.js后,发现模块属性看起来像:

"modules": [
  "./src",
  "./node_modules"
]

所以提供的错误与typescript无关,而是与无法找到引用文件的webpack有关。

相关问题