<S extends Top>(schema: S): S & { new (_: never): {} }Transforms a schema into a class that can be extended with extends. The
resulting class inherits the full schema API (e.g. annotate) and can define
static methods that reference this.
Example (Wrapping a primitive schema)
import { Schema } from "effect"
class MyString extends Schema.asClass(Schema.String) {
static readonly decodeUnknownSync = Schema.decodeUnknownSync(this)
}
console.log(MyString.decodeUnknownSync("a"))
// "a"constructors
Source effect/Schema.ts:22485 lines
export function function asClass<S extends Top>(
schema: S
): S & { new (_: never): {} }
Transforms a schema into a class that can be extended with extends. The
resulting class inherits the full schema API (e.g. annotate) and can define
static methods that reference this.
Example (Wrapping a primitive schema)
import { Schema } from "effect"
class MyString extends Schema.asClass(Schema.String) {
static readonly decodeUnknownSync = Schema.decodeUnknownSync(this)
}
console.log(MyString.decodeUnknownSync("a"))
// "a"
asClass<function (type parameter) S in asClass<S extends Top>(schema: S): S & {
new (_: never): {};
}
S extends Top>(schema: S extends Topschema: function (type parameter) S in asClass<S extends Top>(schema: S): S & {
new (_: never): {};
}
S): function (type parameter) S in asClass<S extends Top>(schema: S): S & {
new (_: never): {};
}
S & { new(_: never_: never): {} } {
// oxlint-disable-next-line @typescript-eslint/no-extraneous-class
class class ClassClass {}
return var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.setPrototypeOf(o: any, proto: object | null): anySets the prototype of a specified object o to object proto or null. Returns the object o.
setPrototypeOf(class ClassClass, schema: S extends Topschema)
}