( fields: Fields, records: Records, ast: AST.AST = getDefaultTypeLiteralAST(fields, records) )
| 2864 | } |
| 2865 | |
| 2866 | function makeTypeLiteralClass<Fields extends Struct.Fields, const Records extends IndexSignature.Records>( |
| 2867 | fields: Fields, |
| 2868 | records: Records, |
| 2869 | ast: AST.AST = getDefaultTypeLiteralAST(fields, records) |
| 2870 | ): TypeLiteral<Fields, Records> { |
| 2871 | return class TypeLiteralClass extends make< |
| 2872 | Simplify<TypeLiteral.Type<Fields, Records>>, |
| 2873 | Simplify<TypeLiteral.Encoded<Fields, Records>>, |
| 2874 | | Struct.Context<Fields> |
| 2875 | | IndexSignature.Context<Records> |
| 2876 | >(ast) { |
| 2877 | static override annotations( |
| 2878 | annotations: Annotations.Schema<Simplify<TypeLiteral.Type<Fields, Records>>> |
| 2879 | ): TypeLiteral<Fields, Records> { |
| 2880 | return makeTypeLiteralClass(this.fields, this.records, mergeSchemaAnnotations(this.ast, annotations)) |
| 2881 | } |
| 2882 | |
| 2883 | static fields = { ...fields } |
| 2884 | |
| 2885 | static records = [...records] as Records |
| 2886 | |
| 2887 | static make = ( |
| 2888 | props: Simplify<TypeLiteral.Constructor<Fields, Records>>, |
| 2889 | options?: MakeOptions |
| 2890 | ): Simplify<TypeLiteral.Type<Fields, Records>> => { |
| 2891 | const propsWithDefaults: any = lazilyMergeDefaults(fields, { ...props as any }) |
| 2892 | return getDisableValidationMakeOption(options) |
| 2893 | ? propsWithDefaults |
| 2894 | : ParseResult.validateSync(this)(propsWithDefaults) |
| 2895 | } |
| 2896 | |
| 2897 | static pick(...keys: Array<keyof Fields>): Struct<Simplify<Pick<Fields, typeof keys[number]>>> { |
| 2898 | return Struct(struct_.pick(fields, ...keys) as any) |
| 2899 | } |
| 2900 | |
| 2901 | static omit(...keys: Array<keyof Fields>): Struct<Simplify<Omit<Fields, typeof keys[number]>>> { |
| 2902 | return Struct(struct_.omit(fields, ...keys) as any) |
| 2903 | } |
| 2904 | } |
| 2905 | } |
| 2906 | |
| 2907 | /** |
| 2908 | * @category api interface |
no test coverage detected