( js: CombinatorCompiler, node: nodeOfKind<"predicate"> )
| 1278 | |
| 1279 | // a callback is read where it's called, as it may be set once this has loaded |
| 1280 | const writePredicate = ( |
| 1281 | js: CombinatorCompiler, |
| 1282 | node: nodeOfKind<"predicate"> |
| 1283 | ): string => { |
| 1284 | const fn = js.ref(node.predicate) |
| 1285 | if (isKeyword(node.predicate)) { |
| 1286 | return writeCall( |
| 1287 | "check", |
| 1288 | '"predicate"', |
| 1289 | JSON.stringify(predicateSiteOf(node)!.description), |
| 1290 | fn |
| 1291 | ) |
| 1292 | } |
| 1293 | return writeCall( |
| 1294 | // passed a ctx of its own, which reports at a site as a check does |
| 1295 | testsOrRejects.has(node.predicate) ? "narrowedRejecting" |
| 1296 | : returnsReports.has(node.predicate) ? "narrowedWithCtx" |
| 1297 | : raisesNothing(node.predicate) ? "narrowedBy" |
| 1298 | : "narrowedInCtx", |
| 1299 | `() => ${fn}`, |
| 1300 | isNamedByItsFunction(node) ? undefined : ( |
| 1301 | JSON.stringify(predicateSiteOf(node)!.description) |
| 1302 | ) |
| 1303 | ) |
| 1304 | } |
| 1305 | |
| 1306 | const caseMember = (node: UnionNode, k: string): BaseRoot | undefined => |
| 1307 | (node.discriminant!.members as Record<string, BaseRoot> | undefined)?.[k] |
no test coverage detected