Content-Length: 303324 | pFad | http://github.com/angular/angular/pull/60626/files

B2 fix(core): fix ng generate @angular/core:output-migration by aparzi · Pull Request #60626 · angular/angular · GitHub
Skip to content

fix(core): fix ng generate @angular/core:output-migration #60626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ describe('outputs', () => {
});
});

it('should keep type without initializer', async () => {
await verifyDeclaration({
before: '@Output() eventMovement: EventEmitter<IResponse> = new EventEmitter();',
after: 'readonly eventMovement = output<IResponse>();',
});
});

it('should keep type with initializer', async () => {
await verifyDeclaration({
before: '@Output() eventMovement: EventEmitter = new EventEmitter<IResponse>();',
after: 'readonly eventMovement = output<IResponse>();',
});
});

it('should keep type without initializer and with alias', async () => {
await verifyDeclaration({
before:
"@Output('customEvent') eventMovement: EventEmitter<IResponse> = new EventEmitter();",
after: "readonly eventMovement = output<IResponse>({ alias: 'customEvent' });",
});
});

it('should migrate declaration without type hint', async () => {
await verifyDeclaration({
before: '@Output() readonly someChange = new EventEmitter();',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ export function calculateDeclarationReplacement(
aliasParam?: string,
): Replacement {
const sf = node.getSourceFile();
const payloadTypes =
node.initializer !== undefined && ts.isNewExpression(node.initializer)
? node.initializer?.typeArguments
: undefined;

let payloadTypes: ts.NodeArray<ts.TypeNode> | undefined;

if (node.initializer && ts.isNewExpression(node.initializer) && node.initializer.typeArguments) {
payloadTypes = node.initializer.typeArguments;
} else if (node.type && ts.isTypeReferenceNode(node.type) && node.type.typeArguments) {
payloadTypes = ts.factory.createNodeArray(node.type.typeArguments);
}

const outputCall = ts.factory.createCallExpression(
ts.factory.createIdentifier('output'),
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/angular/angular/pull/60626/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy