( Inherited: Inherited, identifier: string, struct: S, annotations: Annotations.Declaration<Self, readonly [S]> | undefined, proto: ((identifier: string) => object) | undefined )
| 14065 | const payloadToken = {} |
| 14066 | |
| 14067 | function makeClass< |
| 14068 | Self, |
| 14069 | S extends Struct<Struct.Fields>, |
| 14070 | Inherited extends new(...args: ReadonlyArray<any>) => any |
| 14071 | >( |
| 14072 | Inherited: Inherited, |
| 14073 | identifier: string, |
| 14074 | struct: S, |
| 14075 | annotations: Annotations.Declaration<Self, readonly [S]> | undefined, |
| 14076 | proto: ((identifier: string) => object) | undefined |
| 14077 | ): any { |
| 14078 | const getClassSchema = getClassSchemaFactory(struct, identifier, annotations) |
| 14079 | const ClassTypeId = getClassTypeId(identifier) // HMR support |
| 14080 | |
| 14081 | const out = class extends Inherited { |
| 14082 | constructor(...[input, options]: ReadonlyArray<any>) { |
| 14083 | const internalOptions = options as MakeOptions | undefined |
| 14084 | const payload = internalOptions?.["~payload"] |
| 14085 | const value = payload?.token === payloadToken |
| 14086 | ? payload.value |
| 14087 | : struct.make(input ?? {}, options) |
| 14088 | super(value, { ...options, disableChecks: true, "~payload": { token: payloadToken, value } }) |
| 14089 | } |
| 14090 | |
| 14091 | static readonly [TypeId] = TypeId |
| 14092 | |
| 14093 | get [ClassTypeId]() { |
| 14094 | return ClassTypeId |
| 14095 | } |
| 14096 | |
| 14097 | static readonly [immerable] = true |
| 14098 | |
| 14099 | static readonly identifier = identifier |
| 14100 | static readonly fields = struct.fields |
| 14101 | |
| 14102 | static get ast(): SchemaAST.Declaration { |
| 14103 | return getClassSchema(this).ast |
| 14104 | } |
| 14105 | static pipe() { |
| 14106 | return Pipeable.pipeArguments(this, arguments) |
| 14107 | } |
| 14108 | static rebuild(ast: SchemaAST.Declaration) { |
| 14109 | return getClassSchema(this).rebuild(ast) |
| 14110 | } |
| 14111 | static make(input: S["~type.make.in"], options?: MakeOptions): Self { |
| 14112 | return new this(input, options) |
| 14113 | } |
| 14114 | static makeOption(input: S["~type.make.in"], options?: MakeOptions): Option_.Option<Self> { |
| 14115 | return SchemaParser.makeOption(getClassSchema(this) as any)(input ?? {}, options) as any |
| 14116 | } |
| 14117 | static makeEffect(input: S["~type.make.in"], options?: MakeOptions): Effect.Effect<Self, SchemaIssue.Issue> { |
| 14118 | return (getClassSchema(this) as any).makeEffect(input ?? {}, options) |
| 14119 | } |
| 14120 | static annotate(annotations: Annotations.Declaration<Self, readonly [S]>) { |
| 14121 | return this.rebuild(SchemaAST.annotate(this.ast, annotations)) |
| 14122 | } |
| 14123 | static annotateKey(annotations: Annotations.Key<Self>) { |
| 14124 | return this.rebuild(SchemaAST.annotateKey(this.ast, annotations)) |
no test coverage detected