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

问题描述 投票:0回答:1

将'baseUrl'属性与'paths'属性结合使用时,如下所示:

"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';
angular typescript webpack
1个回答
0
投票

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

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

所以提供的错误与typescript无关,但与webpack无关,因为它无法找到引用的文件。

© www.soinside.com 2019 - 2024. All rights reserved.