8000 fix(compiler-cli): wrong event name for host listener decorators by crisbeto · Pull Request #60460 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content

fix(compiler-cli): wrong event name for host listener decorators #60460

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 @@ -341,7 +341,6 @@ function createNodeFromListenerDecorator(
// manually here. Note that we use a dummy span with -1/-1 as offsets, because it isn't
// used for type checking and constructing it accurately would take some effort.
const span = new ParseSpan(-1, -1);
const [name, phase] = method.name.text.split('.');
const argNodes: AST[] = [];
const methodStart = method.getStart();
const methodReceiver = new ThisReceiver(span, new AbsoluteSourceSpan(methodStart, methodStart));
Expand Down Expand Up @@ -387,17 +386,19 @@ function createNodeFromListenerDecorator(
}

const callNode = new Call(span, nameSpan, receiver, argNodes, span);
const eventNameNode = args[0];
const [eventName, phase] = eventNameNode.text.split('.');

listeners.push(
new TmplAstBoundEvent(
name,
name.startsWith('@') ? ParsedEventType.Animation : ParsedEventType.Regular,
eventName,
eventName.startsWith('@') ? ParsedEventType.Animation : ParsedEventType.Regular,
callNode,
null,
phase,
createSourceSpan(decorator),
createSourceSpan(decorator),
createStaticExpressionSpan(method.name),
createStaticExpressionSpan(eventNameNode),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ runInEachFileSystem(() => {
const diags = env.driveDiagnostics();
expect(diags.length).toBe(1);
expect(diags[0].messageText).toBe(
`Argument of type 'Event' is not assignable to parameter of type 'string'.`,
`Argument of type 'MouseEvent' is not assignable to parameter of type 'string'.`,
);
expect(getDiagnosticSourceCode(diags[0])).toBe('$event');
});
Expand Down
0