(ast: AST)
| 3397 | }) |
| 3398 | |
| 3399 | function getCandidateTypes(ast: AST): ReadonlyArray<Type> { |
| 3400 | switch (ast._tag) { |
| 3401 | case "Null": |
| 3402 | return ["null"] |
| 3403 | case "Undefined": |
| 3404 | return ["undefined"] |
| 3405 | case "String": |
| 3406 | case "TemplateLiteral": |
| 3407 | return ["string"] |
| 3408 | case "Number": |
| 3409 | return ["number"] |
| 3410 | case "Boolean": |
| 3411 | return ["boolean"] |
| 3412 | case "Symbol": |
| 3413 | case "UniqueSymbol": |
| 3414 | return ["symbol"] |
| 3415 | case "BigInt": |
| 3416 | return ["bigint"] |
| 3417 | case "Arrays": |
| 3418 | return ["array"] |
| 3419 | case "ObjectKeyword": |
| 3420 | return ["object", "array", "function"] |
| 3421 | case "Objects": |
| 3422 | return ast.propertySignatures.length || ast.indexSignatures.length |
| 3423 | ? ["object"] |
| 3424 | : ["string", "number", "boolean", "symbol", "bigint", "object", "array", "function"] |
| 3425 | case "Enum": |
| 3426 | return Array.from(new Set(ast.enums.map(([, v]) => typeof v))) |
| 3427 | case "Literal": |
| 3428 | return [typeof ast.literal] |
| 3429 | case "Union": |
| 3430 | return Array.from(new Set(ast.types.flatMap(getCandidateTypes))) |
| 3431 | default: |
| 3432 | return [ |
| 3433 | "null", |
| 3434 | "undefined", |
| 3435 | "string", |
| 3436 | "number", |
| 3437 | "boolean", |
| 3438 | "symbol", |
| 3439 | "bigint", |
| 3440 | "object", |
| 3441 | "array", |
| 3442 | "function" |
| 3443 | ] |
| 3444 | } |
| 3445 | } |
| 3446 | |
| 3447 | /** @internal */ |
| 3448 | export function collectSentinels(ast: AST): ReadonlyArray<Sentinel> { |
no test coverage detected