Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed Oct 11, 2023
1 parent 7a4add3 commit db0a7e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
34 changes: 20 additions & 14 deletions packages/remix-server-runtime/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,27 @@ export type SerializeFrom<T> =
;

// note: cannot be inlined as logic requires union distribution
type Serialize<Output> = Output extends TypedDeferredData<infer U>
? // top-level promises
{
[K in keyof U as K extends symbol
? never
: Promise<any> extends U[K]
? K
: never]: DeferValue<U[K]>; // use generic to distribute over union
} & Jsonify<{
// non-promises
[K in keyof U as Promise<any> extends U[K] ? never : K]: U[K];
// prettier-ignore
type Serialize<Output> =
Output extends TypedDeferredData<infer U> ?
// top-level promises
& {
[K in keyof U as
K extends symbol ? never :
Promise<any> extends U[K] ? K :
never
]: DeferValue<U[K]>; // use generic to distribute over union
}
// non-promises
& Jsonify<{
[K in keyof U as
Promise<any> extends U[K] ? never :
K
]: U[K];
}>
: Output extends TypedResponse<infer U>
? Jsonify<U>
: Jsonify<Output>;
:
Output extends TypedResponse<infer U> ? Jsonify<U> :
Jsonify<Output>;

// prettier-ignore
type DeferValue<T> =
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-server-runtime/typecheck.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// typecheck that expression is assignable to type

export function expectType<T>(_expression: T) {}

// prettier-ignore
// adapted from https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.ts
export type Equal<X, Y> =
Expand Down

0 comments on commit db0a7e0

Please sign in to comment.