Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg: Update validation packages #2926

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions examples/github-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/github-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"@types/react": "18.2.47",
"@types/react-dom": "18.2.18",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "6.18.1",
"@typescript-eslint/parser": "6.18.1",
"@typescript-eslint/eslint-plugin": "6.19.0",
"@typescript-eslint/parser": "6.19.0",
"react-refresh": "0.14.0",
"serve": "14.2.1",
"webpack": "5.89.0",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
"@types/jest": "29.5.11",
"@types/node": "20.11.0",
"@types/react": "18.2.47",
"@typescript-eslint/eslint-plugin": "6.18.1",
"@typescript-eslint/parser": "6.18.1",
"@typescript-eslint/eslint-plugin": "6.19.0",
"@typescript-eslint/parser": "6.19.0",
"babel-plugin-module-resolver": "5.0.0",
"benchmark": "^2.1.4",
"conventional-changelog-anansi": "^0.2.0",
Expand All @@ -89,7 +89,7 @@
"nock": "13.3.1",
"node-fetch": "^3.3.0",
"npm-run-all": "^4.1.5",
"prettier": "3.1.1",
"prettier": "3.2.4",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.73.2",
Expand Down
13 changes: 6 additions & 7 deletions packages/endpoint/src/endpointTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,9 @@ type IfTypeScriptLooseNull<Y, N> = 1 | undefined extends 1 ? Y : N;

type OnlyFirst<A extends unknown[]> = A extends [] ? [] : [A[0]];

type RemoveArray<Orig extends any[], Rem extends any[]> = Rem extends (
[any, ...infer RestRem]
) ?
Orig extends [any, ...infer RestOrig] ?
RemoveArray<RestOrig, RestRem>
: never
: Orig;
type RemoveArray<Orig extends any[], Rem extends any[]> =
Rem extends [any, ...infer RestRem] ?
Orig extends [any, ...infer RestOrig] ?
RemoveArray<RestOrig, RestRem>
: never
: Orig;
10 changes: 4 additions & 6 deletions packages/normalizr/src/endpoint/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ export type ResolveType<E extends (...args: any) => any> =
ReturnType<E> extends Promise<infer R> ? R : never;

/** Fallback to schema if fetch function isn't defined */
export type InferReturn<
F extends FetchFunction,
S extends Schema | undefined,
> = S extends undefined ? ReturnType<F>
: ReturnType<F> extends unknown ? Promise<Denormalize<S>>
: ReturnType<F>;
export type InferReturn<F extends FetchFunction, S extends Schema | undefined> =
S extends undefined ? ReturnType<F>
: ReturnType<F> extends unknown ? Promise<Denormalize<S>>
: ReturnType<F>;
19 changes: 10 additions & 9 deletions packages/redux/src/prepareStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ type ReducersMapObject<
S = any,
A extends { type: string } = any,
PreloadedState = S,
> = keyof PreloadedState extends keyof S ?
{
[K in keyof S]: Reducer<
S[K],
A,
K extends keyof PreloadedState ? PreloadedState[K] : never
>;
}
: never;
> =
keyof PreloadedState extends keyof S ?
{
[K in keyof S]: Reducer<
S[K],
A,
K extends keyof PreloadedState ? PreloadedState[K] : never
>;
}
: never;
86 changes: 44 additions & 42 deletions packages/rest/src/OptionsToFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,51 @@ export type OptionsToFunction<
O extends PartialRestGenerics,
E extends { body?: any; path?: string; method?: string },
F extends FetchFunction,
> = 'path' extends keyof O ?
RestFetch<
'searchParams' extends keyof O ?
O['searchParams'] & PathArgs<Exclude<O['path'], undefined>>
: PathArgs<Exclude<O['path'], undefined>>,
OptionsToBodyArgument<
'body' extends keyof O ? O : E,
'method' extends keyof O ? O['method'] : E['method']
>,
O['process'] extends {} ? ReturnType<O['process']> : ResolveType<F>
>
: 'body' extends keyof O ?
RestFetch<
'searchParams' extends keyof O ?
O['searchParams'] & PathArgs<Exclude<E['path'], undefined>>
: PathArgs<Exclude<E['path'], undefined>>,
OptionsToBodyArgument<
O,
'method' extends keyof O ? O['method'] : E['method']
>,
O['process'] extends {} ? ReturnType<O['process']> : ResolveType<F>
>
: 'searchParams' extends keyof O ?
RestFetch<
O['searchParams'] & PathArgs<Exclude<E['path'], undefined>>,
OptionsToBodyArgument<
E,
'method' extends keyof O ? O['method'] : E['method']
>,
O['process'] extends {} ? ReturnType<O['process']> : ResolveType<F>
>
: (
this: ThisParameterType<F>,
...args: Parameters<F>
) => Promise<
O['process'] extends {} ? ReturnType<O['process']> : ResolveType<F>
>;
> =
'path' extends keyof O ?
RestFetch<
'searchParams' extends keyof O ?
O['searchParams'] & PathArgs<Exclude<O['path'], undefined>>
: PathArgs<Exclude<O['path'], undefined>>,
OptionsToBodyArgument<
'body' extends keyof O ? O : E,
'method' extends keyof O ? O['method'] : E['method']
>,
O['process'] extends {} ? ReturnType<O['process']> : ResolveType<F>
>
: 'body' extends keyof O ?
RestFetch<
'searchParams' extends keyof O ?
O['searchParams'] & PathArgs<Exclude<E['path'], undefined>>
: PathArgs<Exclude<E['path'], undefined>>,
OptionsToBodyArgument<
O,
'method' extends keyof O ? O['method'] : E['method']
>,
O['process'] extends {} ? ReturnType<O['process']> : ResolveType<F>
>
: 'searchParams' extends keyof O ?
RestFetch<
O['searchParams'] & PathArgs<Exclude<E['path'], undefined>>,
OptionsToBodyArgument<
E,
'method' extends keyof O ? O['method'] : E['method']
>,
O['process'] extends {} ? ReturnType<O['process']> : ResolveType<F>
>
: (
this: ThisParameterType<F>,
...args: Parameters<F>
) => Promise<
O['process'] extends {} ? ReturnType<O['process']> : ResolveType<F>
>;

export type OptionsToBodyArgument<
O extends { body?: any },
Method extends string | undefined,
> = Method extends 'POST' | 'PUT' | 'PATCH' | 'DELETE' ?
'body' extends keyof O ?
O['body']
: any
: undefined;
> =
Method extends 'POST' | 'PUT' | 'PATCH' | 'DELETE' ?
'body' extends keyof O ?
O['body']
: any
: undefined;
Loading
Loading