( ast: SchemaAST.AST, input: unknown, options: Schema.MakeOptions | undefined, construct: (fields: object) => T )
| 1160 | * @internal |
| 1161 | */ |
| 1162 | export function makeClassSync<T>( |
| 1163 | ast: SchemaAST.AST, |
| 1164 | input: unknown, |
| 1165 | options: Schema.MakeOptions | undefined, |
| 1166 | construct: (fields: object) => T |
| 1167 | ): T { |
| 1168 | const entry = CompilerRegistry.resolve(ast) |
| 1169 | const descriptor = SchemaAST.getConstructorDescriptor(ast) |
| 1170 | if (descriptor === undefined || entry.make !== undefined || entry.compiledMakeEffect !== undefined) { |
| 1171 | return constructSync(entry, input, options) |
| 1172 | } |
| 1173 | if (descriptor.isConstructed(input)) return input as T |
| 1174 | const fields = constructSync<object>((entry.resolve ?? CompilerRegistry.resolve)(descriptor.link.to), input, options) |
| 1175 | try { |
| 1176 | return construct(fields) |
| 1177 | } catch (error) { |
| 1178 | throwConstructorDefect(error) |
| 1179 | } |
| 1180 | } |
| 1181 | |
| 1182 | /** @internal */ |
| 1183 | export interface Parser { |
nothing calls this directly
no test coverage detected