【发布时间】:2021-08-30 21:46:30
【问题描述】:
我有一个 Angular 库,我刚刚更新到 Angular v12,TypeScript 更新到 4.2.4,现在尝试使用此构建库时出现编译错误。
我发现问题出在其中一个生成的 .d.ts 文件中。
以前,更新前,工作时,有下面一行
readonly headerComponents: QueryList<import("../data-grid-column-header/data-grid-column-header.component").DataGridColumnHeaderComponent>;
但是,现在我构建的时候,它似乎使用了 tsconfi.json compileOptionPaths 中设置的路径之一。,即我有
{
"include": [
"src",
"node_modules/cypress"
],
"exclude": [
"node_modules/cypress"
],
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"downlevelIteration": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"allowSyntheticDefaultImports": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"paths": {
"@angular/*": [
"node_modules/@angular/*"
],
"@mycompany/myapp-ui": [
"projects/myapp-ui/src/public-api.ts"
],
"@mycompany/myapp-ui/*": [
"projects/myapp-ui/src/*"
]
}
}
}
现在在我的 .d.ts 文件中
get headerComponents(): QueryList<import("@mycompany/myapp-ui").DataGridColumnHeaderComponent>;
当你将鼠标悬停在 ths 上时,工具提示是 Cannot find module '@mycompany/myapp-ui' or its corresponding type declarations.ts(2307)
如果我将它替换为它曾经拥有的(即解析的路径),那么一切都很好。
为什么会输出这个,我该如何阻止它?
更新 1
一个组件被导入另一个组件,例如我有
在data-grid-header.component.ts,我有
import { DataGridColumnHeaderComponent } from '../data-grid-column-header/data-grid-column-header.component';
【问题讨论】:
标签: angular typescript