fix(core): do not insert todo when migrating void @Output

The following:

`@Output() someChange = new EventEmitter<void>();`

is correctly migrated to:

`readonly someChange = output<void>();`

However, a TODO is incorrectly inserted for subsequent emissions from
`someChange`, stating that an argument is expected.

(cherry picked from commit 16fe27bfef)
This commit is contained in:
tmpln
2026-05-18 13:41:09 +00:00
committed by leonsenft
parent d1736efc32
commit c0f52272ed
2 changed files with 30 additions and 1 deletions
@@ -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<void>();
someMethod(): void {
this.someChange.emit();
}
}
`,
after: `
import {Directive, output} from '@angular/core';
@Directive()
export class TestDir {
readonly someChange = output<void>();
someMethod(): void {
this.someChange.emit();
}
}
`,
});
});
it('should insert a TODO comment for emit function with type', async () => {
await verify({
before: `
@@ -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);