Effect CommunityEC
Effect Community7mo ago
1 reply
Near

Plans to Improve Type-Safety for `setPath` Method in Effect Typescript Library

Are the any plans to improve type-safety for the setPath method ensuring the listed path params are actually covered by the supplied schema?
HttpApiEndpoint.post('doTheThing', '/:thingId')
    .setPath(Schema.Struct({ anotherId: Schema.String }))
                        // ^ enforce this to be { thingId }

As it stands right now the only way is to use HttpApiSchema.param('thingId', Schema.String) and inline that as a template literal such as this which is less ergonomic but at least guaranteed to be type-safe:
const THING_ID = HttpApiSchema.param('thingId', Schema.String)
HttpApiEndpoint.post('doTheThing')`/${THING_ID}`
Was this page helpful?