Effect CommunityEC
Effect Community16mo ago
18 replies
Gibbs

Creating an Opaque Type from a Schema in TypeScript

Shouldn't it be as simple as that to create an opaque type out of a schema ? The following does not compile:
class MyId extends Schema.UUID {}

const id: MyId = Schema.decodeSync(MyId)('ff'); // Type 'string' is not assignable to type 'MyId'

I guess I'm missing something ?
Was this page helpful?