Extracting Literals from a Branded Union in TypeScript

Is there a way to put a brand on a union of literals and then get the literals from the result?

const RoleBrand = Symbol.for("Role")
const RoleBrandSchema = Schema.Literal("admin", "customer").pipe(Schema.brand(RoleBrand))
const roleBrand = Schema.decodeUnknownSync(RoleBrandSchema)("customer")
const roleBrands = RoleBrand.literals
Was this page helpful?