typescript - Uppgradering till Angular 9 med Ivy, kan inte kombinera @Input-dekoratörer med query-dekoratörer (@ContentChild)


När jag uppgraderade till Angular 9 fick jag följande fel relaterade till ett paket:

Compiling @ngx-package : es2015 as esm2015

ERROR in Failed to compile entry-point @ngx-package (es2015 as esm2015) due to compilation errors:
node_modules/@ngx-package/@ngx-package.js:1325:34 - error NG1006: Cannot combine @Input decorators with query decorators

1325     'actions': [{ type: Input }, { type: ContentChild, args: [Component,] },],

Den ansvariga koden för detta fel är följande:

@Input() @ContentChild(Component) actions: Component;

Svar #1

Problemet är att jag inte kan kombinera @Input() och @ContentChild, så jag ersatte koden som orsakade felet med följande:

get actions(): Component {
  return this._actions;
}

private _actions: Component;

@Input()
set actions(value: Component) {
  this._actions = value;
}

@ContentChildren(Component)
set viewActions(value: Component) {
  if (!this._actions && value) {
    this._actions = value;
  }
}