Question presented to candidate:
"Angular 17.3 added output(). Our components use @Output() saved = new EventEmitter<Item>(). What is different about output(), is it actually a signal, and should we migrate?"
What a strong answer should cover:
output()returns anOutputEmitterRef<T>withemit()andsubscribe(); the template side,(saved)="...", is unchanged.- It is not a signal (it holds no value) and not an RxJS Subject: no
pipe, nonext, nocomplete. Convert withoutputToObservable()if you need operators. - Lifecycle: listeners are dropped when the component is destroyed; a late
emit()only warns (NG0953) and a latesubscribe()throws. A leftoverEventEmittersubscription keeps firing. - Must be created in an injection context (field initializer), like
input(). - Aliases are an option:
output<number>({ alias: "remove" }). - Stable since v19;
@Outputstill supported;ng generate @angular/core:output-migrationrewrites it.
Clarifying questions expected:
- "Does any code call
.pipe()or.subscribe()on these emitters directly, or are they only used from templates?"
Code / implementation expected: Yes — the same child with output() and with @Output() + EventEmitter.