()
| 69 | override readonly optional = true; |
| 70 | |
| 71 | override execute(): TcbExpr { |
| 72 | const id = new TcbExpr(this.tcb.allocateId()); |
| 73 | let initializer: TcbExpr = |
| 74 | this.target instanceof Template || this.target instanceof Element |
| 75 | ? this.scope.resolve(this.target) |
| 76 | : this.scope.resolve(this.host, this.target); |
| 77 | |
| 78 | // The reference is either to an element, an <ng-template> node, or to a directive on an |
| 79 | // element or template. |
| 80 | if ( |
| 81 | (this.target instanceof Element && !this.tcb.env.config.checkTypeOfDomReferences) || |
| 82 | !this.tcb.env.config.checkTypeOfNonDomReferences |
| 83 | ) { |
| 84 | // References to DOM nodes are pinned to 'any' when `checkTypeOfDomReferences` is `false`. |
| 85 | // References to `TemplateRef`s and directives are pinned to 'any' when |
| 86 | // `checkTypeOfNonDomReferences` is `false`. |
| 87 | initializer = new TcbExpr(`${initializer.print()} as any`); |
| 88 | } else if (this.target instanceof Template) { |
| 89 | // Direct references to an <ng-template> node simply require a value of type |
| 90 | // `TemplateRef<any>`. To get this, an expression of the form |
| 91 | // `(_t1 as any as TemplateRef<any>)` is constructed. |
| 92 | const templateRef = this.tcb.env.referenceExternalSymbol('@angular/core', 'TemplateRef'); |
| 93 | initializer = new TcbExpr(`(${initializer.print()} as any as ${templateRef.print()}<any>)`); |
| 94 | } |
| 95 | initializer.addParseSpanInfo(this.node.sourceSpan); |
| 96 | id.addParseSpanInfo(this.node.keySpan); |
| 97 | |
| 98 | this.scope.addStatement(new TcbExpr(`var ${id.print()} = ${initializer.print()}`)); |
| 99 | return id; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /** |
nothing calls this directly
no test coverage detected