TypeScript Type Checking Issue in HttpServer Code
I can not for the life of me get this middleware to typecheck. Can anyone point out what I am doing wrong?
pipe(
HttpServer.router.empty,
HttpServer.router.mountApp('/api/', API.FsaApi),
// typescript [2345]: Argument of type 'Effect<unknown, unknown, unknown>' is not assignable to parameter of type '(a: Tag<ServerRequest, ServerRequest>) => Default<any, any>'.
// Type 'Effect<unknown, unknown, unknown>' provides no match for the signature '(a: Tag<ServerRequest, ServerRequest>): Default<any, any>'.
HttpServer.middleware.make((app) =>
pipe(
HttpServer.request.ServerRequest,
// typescript [2345]: Argument of type '(request: ServerRequest) => Default<E, R> | Effect<ServerResponse, RouteNotFound, Platform>' is not assignable to parameter of type '(a: ServerRequest) => Effect<ServerResponse, E, ServerRequest | R>'.
// Type 'Default<E, R> | Effect<ServerResponse, RouteNotFound, Platform>' is not assignable to type 'Effect<ServerResponse, E, ServerRequest | R>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
// Type 'Effect<ServerResponse, RouteNotFound, Platform>' is not assignable to type 'Effect<ServerResponse, E, ServerRequest | R>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
// Type 'RouteNotFound' is not assignable to type 'E'.
// 'E' could be instantiated with an arbitrary type which could be unrelated to 'RouteNotFound'.
Effect.flatMap((request) => {
return request.url.startsWith("/api")
? app
: pipe(
resolvePath(request.url),
path => HttpServer.response.file(path, { status: 200 }),
Effect.orElse(() => new HttpServer.error.RouteNotFound({ request })),
)
}),
))pipe(
HttpServer.router.empty,
HttpServer.router.mountApp('/api/', API.FsaApi),
// typescript [2345]: Argument of type 'Effect<unknown, unknown, unknown>' is not assignable to parameter of type '(a: Tag<ServerRequest, ServerRequest>) => Default<any, any>'.
// Type 'Effect<unknown, unknown, unknown>' provides no match for the signature '(a: Tag<ServerRequest, ServerRequest>): Default<any, any>'.
HttpServer.middleware.make((app) =>
pipe(
HttpServer.request.ServerRequest,
// typescript [2345]: Argument of type '(request: ServerRequest) => Default<E, R> | Effect<ServerResponse, RouteNotFound, Platform>' is not assignable to parameter of type '(a: ServerRequest) => Effect<ServerResponse, E, ServerRequest | R>'.
// Type 'Default<E, R> | Effect<ServerResponse, RouteNotFound, Platform>' is not assignable to type 'Effect<ServerResponse, E, ServerRequest | R>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
// Type 'Effect<ServerResponse, RouteNotFound, Platform>' is not assignable to type 'Effect<ServerResponse, E, ServerRequest | R>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
// Type 'RouteNotFound' is not assignable to type 'E'.
// 'E' could be instantiated with an arbitrary type which could be unrelated to 'RouteNotFound'.
Effect.flatMap((request) => {
return request.url.startsWith("/api")
? app
: pipe(
resolvePath(request.url),
path => HttpServer.response.file(path, { status: 200 }),
Effect.orElse(() => new HttpServer.error.RouteNotFound({ request })),
)
}),
))