MCPcopy Create free account
hub / github.com/Effect-TS/effect / getCandidateTypes

Function getCandidateTypes

packages/effect/src/SchemaAST.ts:2535–2581  ·  view source on GitHub ↗
(ast: AST)

Source from the content-addressed store, hash-verified

2533})
2534
2535function getCandidateTypes(ast: AST): ReadonlyArray<Type> {
2536 switch (ast._tag) {
2537 case "Null":
2538 return ["null"]
2539 case "Undefined":
2540 return ["undefined"]
2541 case "String":
2542 case "TemplateLiteral":
2543 return ["string"]
2544 case "Number":
2545 return ["number"]
2546 case "Boolean":
2547 return ["boolean"]
2548 case "Symbol":
2549 case "UniqueSymbol":
2550 return ["symbol"]
2551 case "BigInt":
2552 return ["bigint"]
2553 case "Arrays":
2554 return ["array"]
2555 case "ObjectKeyword":
2556 return ["object", "array", "function"]
2557 case "Objects":
2558 return ast.propertySignatures.length || ast.indexSignatures.length
2559 ? ["object"]
2560 : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"]
2561 case "Enum":
2562 return Array.from(new Set(ast.enums.map(([, v]) => typeof v)))
2563 case "Literal":
2564 return [typeof ast.literal]
2565 case "Union":
2566 return Array.from(new Set(ast.types.flatMap(getCandidateTypes)))
2567 default:
2568 return [
2569 "null",
2570 "undefined",
2571 "string",
2572 "number",
2573 "boolean",
2574 "symbol",
2575 "bigint",
2576 "object",
2577 "array",
2578 "function"
2579 ]
2580 }
2581}
2582
2583/** @internal */
2584export function collectSentinels(ast: AST): ReadonlyArray<Sentinel> {

Callers 1

getIndexFunction · 0.85

Calls 1

mapMethod · 0.45

Tested by

no test coverage detected