Effect CommunityEC
Effect Community16mo ago
17 replies
TGTGamer

[Solved] Extending `Schema.TaggedClass` with Custom Abstraction in TypeScript

I'm trying to extend Schema.TaggedClass with my own abstraction class (has respective default functions)

export function Base (
    TableName: string,
    fields: Struct.Fields
) {
    return class Base<
        TableName extends string = typeof TableName
    >
        extends Schema.TaggedClass<Base>()( TableName, {
                id: Schema.String.pipe( Schema.brand( TableName + 'Id' ) ),
                ...fields
            }
        ) {
        public readonly ID: TypeID<TableName> = TypeID.fromString<TableName>( this.id )
        public get UUID () {
            return this.ID.toUUID()
        }
        public get idType () {
            return this.ID.getType()
        }
    }
}


But I am getting:
TS4058: Return type of exported function has or is using name TypeId from external module
TS4058: Return type of exported function has or is using name refineTypeId from external module


Anyone able to assist on how to solve this issue?
Was this page helpful?