mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
fix(core): do not insert todo when migrating void @Output
Some checks failed
DevInfra / assistant_to_the_branch_manager (push) Has been cancelled
CI (push) / lint (push) Has been cancelled
CI (push) / devtools (push) Has been cancelled
CI (push) / integration-tests (push) Has been cancelled
CI (push) / adev (push) Has been cancelled
CI (push) / publish-snapshots (push) Has been cancelled
Update ADEV Cross Repo Docs / Update Cross Repo ADEV Docs (push) Has been cancelled
CI (push) / test (push) Has been cancelled
CI (push) / vscode-ng-language-service (push) Has been cancelled
CI (push) / zone-js (push) Has been cancelled
CI (push) / adev-deploy (push) Has been cancelled
Some checks failed
DevInfra / assistant_to_the_branch_manager (push) Has been cancelled
CI (push) / lint (push) Has been cancelled
CI (push) / devtools (push) Has been cancelled
CI (push) / integration-tests (push) Has been cancelled
CI (push) / adev (push) Has been cancelled
CI (push) / publish-snapshots (push) Has been cancelled
Update ADEV Cross Repo Docs / Update Cross Repo ADEV Docs (push) Has been cancelled
CI (push) / test (push) Has been cancelled
CI (push) / vscode-ng-language-service (push) Has been cancelled
CI (push) / zone-js (push) Has been cancelled
CI (push) / adev-deploy (push) Has been cancelled
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:
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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue