(node)
| 73 | * @returns {GuardFormula} formula node |
| 74 | */ |
| 75 | const build = (node) => { |
| 76 | if (node.type === "UnaryExpression" && node.operator === "!") { |
| 77 | return ["!", build(/** @type {Expression} */ (node.argument))]; |
| 78 | } |
| 79 | if ( |
| 80 | node.type === "LogicalExpression" && |
| 81 | (node.operator === "&&" || |
| 82 | node.operator === "||" || |
| 83 | node.operator === "??") |
| 84 | ) { |
| 85 | return [ |
| 86 | node.operator, |
| 87 | build(/** @type {Expression} */ (node.left)), |
| 88 | build(/** @type {Expression} */ (node.right)) |
| 89 | ]; |
| 90 | } |
| 91 | const dep = |
| 92 | node.range && depByRangeStart.get(/** @type {number} */ (node.range[0])); |
| 93 | return dep ? ["v", dep] : ["?"]; |
| 94 | }; |
| 95 | |
| 96 | const formula = build(test); |
| 97 | return hasAtom(formula) ? formula : null; |
no test coverage detected