@internal
(getExpected: (ast: AST) => string)
| 2919 | } |
| 2920 | /** @internal */ |
| 2921 | getExpected(getExpected: (ast: AST) => string): string { |
| 2922 | const expected = this.annotations?.expected |
| 2923 | if (typeof expected === "string") return expected |
| 2924 | |
| 2925 | if (this.types.length === 0) return "never" |
| 2926 | |
| 2927 | const types = this.types.map((type) => { |
| 2928 | const encoded = toEncoded(type) |
| 2929 | switch (encoded._tag) { |
| 2930 | case "Arrays": { |
| 2931 | const literals = encoded.elements.filter(isLiteral) |
| 2932 | if (literals.length > 0) { |
| 2933 | return `${formatIsMutable(encoded.isMutable)}[ ${ |
| 2934 | literals.map((e) => getExpected(e) + formatIsOptional(e.context?.isOptional)).join(", ") |
| 2935 | }, ... ]` |
| 2936 | } |
| 2937 | break |
| 2938 | } |
| 2939 | case "Objects": { |
| 2940 | const literals = encoded.propertySignatures.filter((ps) => isLiteral(ps.type)) |
| 2941 | if (literals.length > 0) { |
| 2942 | return `{ ${ |
| 2943 | literals.map((ps) => |
| 2944 | `${formatIsMutable(ps.type.context?.isMutable)}${formatPropertyKey(ps.name)}${ |
| 2945 | formatIsOptional(ps.type.context?.isOptional) |
| 2946 | }: ${getExpected(ps.type)}` |
| 2947 | ).join(", ") |
| 2948 | }, ... }` |
| 2949 | } |
| 2950 | break |
| 2951 | } |
| 2952 | } |
| 2953 | return getExpected(encoded) |
| 2954 | }) |
| 2955 | return Array.from(new Set(types)).join(" | ") |
| 2956 | } |
| 2957 | } |
| 2958 | |
| 2959 | function failSingleUnionCandidate( |
nothing calls this directly
no test coverage detected