mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user