| 2179 | * @internal |
| 2180 | */ |
| 2181 | export const getUnderlyingSingleOrThrow = <Kind extends ParamKind, A>( |
| 2182 | param: Param<Kind, A> |
| 2183 | ): Single<Kind, A> => { |
| 2184 | const singles = extractSingleParams(param) |
| 2185 | |
| 2186 | if (singles.length === 0) { |
| 2187 | throw new Error("No Single param found in param structure") |
| 2188 | } |
| 2189 | |
| 2190 | if (singles.length > 1) { |
| 2191 | throw new Error( |
| 2192 | `Multiple Single params found: ${singles.map((s) => s.name).join(", ")}` |
| 2193 | ) |
| 2194 | } |
| 2195 | |
| 2196 | return singles[0] as Single<Kind, A> |
| 2197 | } |
| 2198 | |
| 2199 | /** |
| 2200 | * Gets param metadata by traversing the structure. |