* Gets an expression that extracts the value of a field binding.
(expression: AST, tcb: Context, scope: Scope)
| 439 | * Gets an expression that extracts the value of a field binding. |
| 440 | */ |
| 441 | function extractFieldValue(expression: AST, tcb: Context, scope: Scope): TcbExpr { |
| 442 | // Unwraps the field, e.g. `[field]="f"` turns into `f()`. |
| 443 | const innerCall = new TcbExpr(tcbExpression(expression, tcb, scope).print() + '()'); |
| 444 | |
| 445 | // Note: we ignore diagnostics on this call, because it might not be callable |
| 446 | // (e.g. `undefined` is passed in). Whether the value conforms to `FieldTree` is |
| 447 | // checked using the common inputs op. |
| 448 | innerCall.markIgnoreDiagnostics(); |
| 449 | |
| 450 | // Extract the value from the field, e.g. `f().value()`. |
| 451 | return new TcbExpr(`${innerCall.print()}.value()`); |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Gets an expression that extracts the value signal of a field binding (without calling it). |
no test coverage detected