我在Windows计算机上有一个角度项目,现在我想使用GitHub Actions构建我的应用程序。在我的Windows计算机上,也可以在重新克隆存储库时,该构建工作正常。在使用GitHub动作进行构建时,Angular编译器将引发错误。我测试过要在自己的ubuntu VM中构建代码,并且还会引发错误。
错误:
src/app/components/overview.component.ts:4:23 - error TS2307: Cannot find module 'src/app/translated' or its corresponding type declarations.
4 import { Translated } from 'src/app/translated';
~~~~~~~~~~
几乎所有我的组件都使用翻译服务及其更改侦听器。因此,我为我的组件创建了一个抽象基类,名为“翻译”:
import { Subscription } from 'rxjs';
import { TranslationService } from './services/translation.service';
import { Translation } from './i18n/utils';
export class Translated {
subscriptions: Subscription[] = [];
translation: Translation;
constructor(protected translationService: TranslationService) {
this.translation = this.translationService.translation;
this.subscriptions = [
this.translationService.change.subscribe(translation => this.translation = translation)
];
}
value(multilanguageField: any) {
const value = multilanguageField.translations[this.translationService.getCurrentLanguageCode().toUpperCase()];
return value ? value : multilanguageField.defaultValue;
}
}
这似乎在我要扩展类的概述组件中引发了错误:
import { Component } from '@angular/core';
import { Translated } from 'src/app/translated';
import { TranslationService } from 'src/app/services/translation.service';
@Component({
selector: 'app-overview',
templateUrl: './overview.component.html',
styleUrls: ['./overview.component.scss']
})
export class OverviewComponent extends Translated {
constructor(translationService: TranslationService) {
super(translationService);
}
get title(): string {
return this.translation.overview;
}
}