* Compiles the given schema in a fresh compilation context. This clears the cached results of any * previous compilations.
(schema: SchemaImpl | SchemaOrSchemaFn<any> | undefined)
| 83 | * previous compilations. |
| 84 | */ |
| 85 | static rootCompile(schema: SchemaImpl | SchemaOrSchemaFn<any> | undefined): FieldPathNode { |
| 86 | try { |
| 87 | compiledSchemas.clear(); |
| 88 | if (schema === undefined) { |
| 89 | return FieldPathNode.newRoot(); |
| 90 | } |
| 91 | if (schema instanceof SchemaImpl) { |
| 92 | return schema.compile(); |
| 93 | } |
| 94 | return new SchemaImpl(schema as SchemaFn<unknown>).compile(); |
| 95 | } finally { |
| 96 | // Use a try/finally to ensure we properly reset the compilation context upon completion, |
| 97 | // even if there are errors while compiling the schema. |
| 98 | compiledSchemas.clear(); |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /** Checks if the given value is a schema or schema function. */ |
no test coverage detected