From c0f52272ed337d4776bd4178cbbdc7f32037500f Mon Sep 17 00:00:00 2001 From: tmpln Date: Mon, 18 May 2026 13:41:09 +0000 Subject: [PATCH] fix(core): do not insert todo when migrating void @Output The following: `@Output() someChange = new EventEmitter();` is correctly migrated to: `readonly someChange = output();` However, a TODO is incorrectly inserted for subsequent emissions from `someChange`, stating that an argument is expected. (cherry picked from commit 16fe27bfefa6011bc15af28def2e2197a0de6e32) --- .../output-migration/output-migration.spec.ts | 29 +++++++++++++++++++ .../output-migration/output-migration.ts | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/core/schematics/migrations/output-migration/output-migration.spec.ts b/packages/core/schematics/migrations/output-migration/output-migration.spec.ts index 905d85e4194..cd27b3dab6d 100644 --- a/packages/core/schematics/migrations/output-migration/output-migration.spec.ts +++ b/packages/core/schematics/migrations/output-migration/output-migration.spec.ts @@ -198,6 +198,35 @@ describe('outputs', () => { }); }); + it('should not insert a TODO comment for emit function with void type', async () => { + await verify({ + before: ` + import {Directive, Output, EventEmitter} from '@angular/core'; + + @Directive() + export class TestDir { + @Output() someChange = new EventEmitter(); + + someMethod(): void { + this.someChange.emit(); + } + } + `, + after: ` + import {Directive, output} from '@angular/core'; + + @Directive() + export class TestDir { + readonly someChange = output(); + + someMethod(): void { + this.someChange.emit(); + } + } + `, + }); + }); + it('should insert a TODO comment for emit function with type', async () => { await verify({ before: ` diff --git a/packages/core/schematics/migrations/output-migration/output-migration.ts b/packages/core/schematics/migrations/output-migration/output-migration.ts index ecee9bc66ac..ae3e7bca304 100644 --- a/packages/core/schematics/migrations/output-migration/output-migration.ts +++ b/packages/core/schematics/migrations/output-migration/output-migration.ts @@ -477,7 +477,7 @@ function addCommentForEmptyEmit( if (!propertyDeclaration) return; const eventEmitterType = getEventEmitterArgumentType(propertyDeclaration); - if (!eventEmitterType) return; + if (!eventEmitterType || eventEmitterType === 'void') return; const id = getUniqueIdForProperty(info, propertyDeclaration); const file = projectFile(node.getSourceFile(), info);