8000 fix(upgrade): handle output emitters when downgrading a component (#6… · angular/angular@9e1a103 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9e1a103

Browse files
crisbetopkozlowski-opensource
authored andcommitted
fix(upgrade): handle output emitters when downgrading a component (#60369)
The `DowngradeComponentAdapter` adapter was assuming that all outputs are observables, but they can also be `OutputEmitterRef`. Fixes #60366. PR Close #60369
1 parent 3856629 commit 9e1a103

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/upgrade/src/common/src/downgrade_component_adapter.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import {
1111
ChangeDetectorRef,
1212
ComponentFactory,
1313
ComponentRef,
14-
EventEmitter,
14+
type EventEmitter,
1515
Injector,
1616
OnChanges,
1717
SimpleChange,
1818
SimpleChanges,
1919
StaticProvider,
2020
Testability,
2121
TestabilityRegistry,
22+
type OutputEmitterRef,
2223
type ɵInputSignalNode as InputSignalNode,
2324
ɵSIGNAL as SIGNAL,
2425
} from '@angular/core';
@@ -258,13 +259,13 @@ export class DowngradeComponentAdapter {
258259
if (isAssignment && !setter) {
259260
throw new Error(`Expression '${expr}' is not assignable!`);
260261
}
261-
const emitter = componentRef.instance[output.prop] as EventEmitter<any>;
262+
const emitter = componentRef.instance[output.prop] as EventEmitter<any> | OutputEmitterRef<any>;
262263
if (emitter) {
263-
const subscription = emitter.subscribe({
264-
next: isAssignment
264+
const subscription = emitter.subscribe(
265+
isAssignment
265266
? (v: any) => setter!(this.scope, v)
266267
: (v: any) => getter(this.scope, {'$event': v}),
267-
});
268+
);
268269
componentRef.onDestroy(() => subscription.unsubscribe());
269270
} else {
270271
throw new Error(

0 commit comments

Comments
 (0)
0