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