Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MatsDK committed Aug 23, 2023
1 parent 2157173 commit fa35e20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ struct ApiImpl {
impl Api for ApiImpl {
async fn with_state(self) {
// ...
// self.state.lock()
// let state = self.state.lock().await;
// ...
}

Expand Down
18 changes: 12 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,29 @@ type SplitKeyNested<
: never
}

type SplitKey<TRouter extends NestedRoutes, T extends keyof TRouter> = T extends
`${infer A}.${infer B}` ? { [K in A]: SplitKeyNested<TRouter, T, B> }
type RouterPathsToNestedObject<
TRouter extends NestedRoutes,
TPath extends keyof TRouter,
> = TPath extends `${infer A}.${infer B}`
? { [K in A]: SplitKeyNested<TRouter, TPath, B> }
: {
[K in T]: TRouter[T] extends RoutesLayer ? InvokeLayer<TRouter[T]> : never
[K in TPath]: TRouter[TPath] extends RoutesLayer
? InvokeLayer<TRouter[TPath]>
: never
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends
((k: infer I) => void) ? I : never

type Convert<TRouter extends NestedRoutes> = UnionToIntersection<
SplitKey<TRouter, keyof TRouter>
type ConvertToNestedObject<TRouter extends NestedRoutes> = UnionToIntersection<
RouterPathsToNestedObject<TRouter, keyof TRouter>
>

type TauRpcProxy<TRouter extends Router> =
& (TRouter[''] extends RoutesLayer ? InvokeLayer<TRouter['']>
: object)
& Convert<Omit<TRouter, ''>>
& ConvertToNestedObject<Omit<TRouter, ''>>

type Payload = {
event_name: string
Expand Down

0 comments on commit fa35e20

Please sign in to comment.