Skip to content

Commit

Permalink
chore: fix type-check issues
Browse files Browse the repository at this point in the history
  • Loading branch information
TylorS committed May 28, 2024
1 parent 7103937 commit fcc72da
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"build-all": "tsc -b tsconfig.build.json",
"build-watch": "tsc -b tsconfig.build.json --watch",
"circular": "madge --ts-config ./tsconfig.madge.json --circular --no-color --no-spinner --warning packages/*/build/esm -x '(fx|template)/build/esm/(Computed|Filtered|vitest).js'",
"test": "pnpm ultra -r test",
"test": "vitest --run",
"test-watch": "vitest",
"autofix": "ultra -r autofix",
"docs": "ultra -r docs && pnpm docs-cp",
"docs-cp": "node scripts/docs-cp.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/router/src/MatchInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export namespace MatchInput {
/**
* @since 1.0.0
*/
export type Path<T> = Route.Route.Path<Route<T>>
export type Path<T> = _Path.PathJoin<[Route.Route.Path<Route<T>>]>

/**
* @since 1.0.0
Expand Down Expand Up @@ -278,5 +278,5 @@ export function getQuerySchema<I extends MatchInput.Any>(input: I): MatchInput.Q
* @since 1.0.0
*/
export function getPath<I extends MatchInput.Any>(input: I): MatchInput.Path<I> {
return asRouteGuard<I>(input).route.path
return asRouteGuard<I>(input).route.path as MatchInput.Path<I>
}
2 changes: 1 addition & 1 deletion packages/router/src/RouteGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const concat: {
RouteGuard.Error<L> | RouteGuard.Error<R>,
RouteGuard.Context<L> | RouteGuard.Context<R>
>(
Route.concat(self.route, other.route) as Route.Route.Concat<RouteGuard.Route<L>, RouteGuard.Route<R>>,
Route.concat(self.route, other.route) as any,
(input) =>
Effect.Do.pipe(
Effect.bind("a", () => self.guard(input)),
Expand Down
7 changes: 4 additions & 3 deletions packages/server/src/ApiEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

import type { Method } from "@effect/platform/Http/Method"
import type { PathInput } from "@effect/platform/Http/Router"
import { getPropertySignatures } from "@effect/schema/AST"
import type { Schema } from "@effect/schema/Schema"
import type { MatchInput } from "@typed/router"
Expand Down Expand Up @@ -79,7 +80,7 @@ export function setRequestRoute<I extends MatchInput.Any>(
): <
Id extends string,
B,
_,
P,
Q,
H,
R1,
Expand All @@ -88,7 +89,7 @@ export function setRequestRoute<I extends MatchInput.Any>(
>(
endpoint: ApiEndpoint.ApiEndpoint<
Id,
ApiRequest.ApiRequest<B, _, Q, H, R1>,
ApiRequest.ApiRequest<B, P, Q, H, R1>,
Response,
S
>
Expand Down Expand Up @@ -154,7 +155,7 @@ export function make<
ApiResponse.ApiResponse.Default,
Security.Security<void, never, never>
> {
const path = getPath(route)
const path = getPath(route) as PathInput
const endpoint = ApiEndpoint.make(method, id, path, options) as any
return setRequestRoute(route)(endpoint)
}
Expand Down
5 changes: 4 additions & 1 deletion packages/server/src/RouteHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ export function toPlatformRoute<I extends RouteHandler.Any>(
): <E, R>(
self: PlatformRouter.Router<E, R>
) => PlatformRouter.Router<E | RouteHandler.Error<I>, R | RouteHandler.Context<I>> {
return PlatformRouter.route(handler.method)(Router.getPath(handler.route), toHttpApp(handler))
return PlatformRouter.route(handler.method)(
Router.getPath<I["route"]>(handler.route) as PlatformRouter.PathInput,
toHttpApp(handler)
)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export const toPlatformRouter = <E, R>(
platformRouter = PlatformRouter.mountApp(
platformRouter,
// TODO: Maybe we should do a best-effort to convert the path to a platform compatible path
MatchInput.getPath(mount.prefix),
MatchInput.getPath(mount.prefix) as any,
Effect.gen(function*() {
const ctx = yield* setupRouteContext
const response = yield* runRouteMatcher<E, R>(
Expand Down

0 comments on commit fcc72da

Please sign in to comment.