MCPcopy Create free account
hub / github.com/angular/angular / TcbEventHandlerTranslator

Class TcbEventHandlerTranslator

packages/compiler/src/typecheck/ops/events.ts:270–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270class TcbEventHandlerTranslator extends TcbExpressionTranslator {
271 protected override resolve(ast: AST): TcbExpr | null {
272 // Recognize a property read on the implicit receiver corresponding with the event parameter
273 // that is available in event bindings. Since this variable is a parameter of the handler
274 // function that the converted expression becomes a child of, just create a reference to the
275 // parameter by its name.
276 if (
277 ast instanceof PropertyRead &&
278 ast.receiver instanceof ImplicitReceiver &&
279 ast.name === EVENT_PARAMETER
280 ) {
281 return new TcbExpr(EVENT_PARAMETER).addParseSpanInfo(ast.nameSpan);
282 }
283
284 return super.resolve(ast);
285 }
286
287 protected override isValidLetDeclarationAccess(): boolean {
288 // Event listeners are allowed to read `@let` declarations before
289 // they're declared since the callback won't be executed immediately.
290 return true;
291 }
292}
293
294/**
295 * Creates an arrow function to be used as handler function for event bindings. The handler

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected