У меня возникает проблема, когда я хочу скомпилировать свой текущий проект в AOT со следующей версией пакета:
- @ ngtools / webpack @ 6.0.3
- @ angular @ latest (6.0.2)
- Webpack@4.0.0
мой webpack и конфигурацию tsconfig.json можно найти здесь
У меня есть облицовканекоторые проблемы, связанные с областью действия private
/ protected
, используемой в шаблоне, и некоторые параметры извлечения, передаваемые некоторым функциям, которые в действительности не нуждаются в этом (например, $ event, которые не используются в EventBinding).
Теперь яу меня есть следующий список, где я не могу найти, где моя проблема:
/ path / to / app / header / main-header / main-header.component.html (85,7):: Директива TableOfContentComponent, Ожидается 0 аргументов, но получено 1. (1,1):: Директива TableOfContentComponent, Ожидается 0 аргументов, но получено 1.
мой main-header.component.html
файл содержит: // main-header.component.html
// main-header.component.ts
@ViewChildren('headerItems') public headerItems: QueryList<HeaderItemAbstract>;
mainMenuStates = {
hamburger: false,
bookmarks: false,
search: false,
toc: false,
medias: false,
article: false,
language: false
};
И мой TableOfContentComponent
не содержит никакого свойства @Input
.
@Component({
selector: 'ps-table-of-content-template',
templateUrl: './table-of-content.component.html',
animations: [slideUpAndDownAnimation]
})
export class TableOfContentComponent extends HeaderItemAbstract implements OnInit {
toc: TableOfContentModel[];
devices: DevicesModel;
tocContentHeight: number;
tocContentMargin: number;
menuHeight: string;
constructor(private tableOfContentService: TableOfContentService,
private deviceService: DeviceService,
private elemRef: ElementRef) {
super();
this.toc = this.tableOfContentService.tableOfContent;
}
}
/ path / to / app / header / main-header / hamburger-menu / hamburger-menu.component.html (125,5):: директива SliderComponent, ожидалось 0 аргументов, но получено 1. (1,1):: Директива SliderComponent, ожидал 0 аргументов, но получил 1.
my hamburger-menu.component.html
близко к представленному выше коду:
<ps-slider-component [template]="slidable" [countItems]="associatedDocuments.length">
<ng-template #slidable>
<ul class="clearfix">
<li class="ps-hmt-associated-item-wrapper pull-left slider-item"
*ngFor="let document of associatedDocuments">
<a href="{{ document.link }}" target="_blank" class="btn-nostyle">
<div class="ps-hmt-image">
<img src="{{ document.images.thumbnail }}" alt="">
</div>
<p class="ps-hmt-title slider-text"
[matTooltip]="isArticleView ? null : document.title"
[matTooltipPosition]="'above'"
[matTooltipClass]="['ps-mat-tooltip', 'ps-mat-tooltip-doc']"
>
{{ document.title }}
</p>
</a>
</li>
</ul>
</ng-template>
</ps-slider-component>
// On ts side
associatedDocuments: Array<AssociatedDocumentModel>;
@ViewChild('slidable') slidable: ElementRef;
И мой SliderComponent
выглядит так:
export class SliderComponent extends UnsubscribeHelper implements OnInit, OnChanges {
@Input() template: ElementRef;
@Input() countItems: number;
@Input() resetSlide ?: null;
@Input() fixedHeight?: null;
@Input() isVariableWidth?: null;
@Input() isBookmarks?: null;
@Input() hasSkeleton?: boolean = false;
/ path / to / app / header / main-header / medias / dialogs / image-dialog.component.html (34,5):: директива CarouselComponent, ожидается 0 аргументов, нополучил 1. (1,1) :: Директива CarouselComponent, ожидал 0 аргументов, но получил 1.
Действительно близко к предыдущему, я думаю, что проблема та же.
/ path / to / app / document / page / page.component.html (7,9):: директива InfinityPageScrollComponent, ожидается 0 аргументов, но получено 1. (1,1):: директива InfinityPageScrollComponent, ожидается 0 аргументов, нополучил 1.
Здесь мы не имеем никакого ввода для InfinityPageScrollComponent
, и тег называется call <ps-infinity-page-scroll></ps-infinity-page-scroll>
Я уточняю, когда я отключаюEOT на моем веб-пакете все работает как шарм.
Я пытался найти решение по AoT, что нужно и чего не нужно безрезультатно.
Я также заметил, что если я отключу fullTemplateTypeCheck
, мне грозит около 18000 ошибок с некоторыми неявными любыми типами и более странным неопределенным свойством для моей службы, объявленным в конструкторе.
--- EDIT 1: Предоставить код для класса Abstract: UnsubscribeHelper
---
export abstract class HeaderItemAbstract extends UnsubscribeHelper implements AfterViewInit {
public toggleItem: string = 'out';
public ANIMATION_DURATION = slideUpAndDownAnimationDuration;
constructor() {
super();
}
// [Some other method]
/**
* Self animate after loading on DOM
*/
ngAfterViewInit()
{
// Wait next to to avoid error :
// ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked
setTimeout(() => {
this.toggleAnimation();
},100);
}
}
Код для абстрактного класса UnsubscribeHelper
:
export abstract class UnsubscribeHelper implements OnDestroy {
subscriptions: Subscription[] = [];
ngOnDestroy() {
this.subscriptions.forEach(sub => sub.unsubscribe());
}
addSubscription(subscription: Subscription) {
this.subscriptions.push(subscription);
}
}