-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat(react-dom): add InView, useInView #1184
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: 박찬혁 <69495129+okinawaa@users.noreply.github.com> Co-authored-by: Minsoo Kim <57122180+minsoo-web@users.noreply.github.com>
# v2 <!-- A clear and concise description of what this pr is about. --> ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Minsoo Kim <57122180+minsoo-web@users.noreply.github.com> Co-authored-by: Hyeonjae Lee <71202076+2-NOW@users.noreply.github.com> Co-authored-by: Minsoo Kang <90169703+minchodang@users.noreply.github.com> Co-authored-by: Surim Son <47546413+sonsurim@users.noreply.github.com> Co-authored-by: Chaerim Kim <89721027+chaaerim@users.noreply.github.com> Co-authored-by: Chungil Jung <wer4272@nate.com> Co-authored-by: Gihyeon Lee <wes5510@icloud.com>
…ype (#887) # Overview <!-- A clear and concise description of what this pr is about. --> SuspenseQuery, SuspenseInfiniteQuery's return type should be JSX.Element not just ReactNode ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md) 2. I added documents and tests.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @suspensive/react-query@2.0.1 ### Patch Changes - [#887](#887) [`8330a6b`](8330a6b) Thanks [@manudeli](https://github.com/manudeli)! - fix(react-query): fix SuspenseQuery, SuspenseInfiniteQuery's return type - Updated dependencies \[]: - @suspensive/react@2.0.1 ## @suspensive/react@2.0.1 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
# Overview <!-- A clear and concise description of what this pr is about. --> Same reason with #887 ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md) 2. I added documents and tests.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @suspensive/react@2.0.2 ### Patch Changes - [#891](#891) [`be1b7ee`](be1b7ee) Thanks [@manudeli](https://github.com/manudeli)! - fix(react): change return type of Consumers as JSX.Element ## @suspensive/react-query@2.0.2 ### Patch Changes - Updated dependencies \[[`be1b7ee`](be1b7ee)]: - @suspensive/react@2.0.2 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…runtimely (#893) # Overview <!-- A clear and concise description of what this pr is about. --> We expect version of @tanstack/react-query's as only v4. so we warn it with this change to promote installing correct version ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md) 2. I added documents and tests.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @suspensive/react-query@2.0.3 ### Patch Changes - [#893](#893) [`39b4f1b`](39b4f1b) Thanks [@manudeli](https://github.com/manudeli)! - fix(react-query): easier to know constraint @tanstack/react-query v4 runtimely - Updated dependencies \[]: - @suspensive/react@2.0.3 ## @suspensive/react@2.0.3 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
# Overview <!-- A clear and concise description of what this pr is about. --> same reason with previous PRs ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md) 2. I added documents and tests.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @suspensive/react@2.0.4 ### Patch Changes - [#898](#898) [`8c5844b`](8c5844b) Thanks [@manudeli](https://github.com/manudeli)! - fix(react): return type of Delay should be JSX.Element ## @suspensive/react-query@2.0.4 ### Patch Changes - Updated dependencies \[[`8c5844b`](8c5844b)]: - @suspensive/react@2.0.4 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
![logo_background_star](https://github.com/toss/suspensive/assets/61593290/100ee9b9-222a-4aa1-9396-3568dbde106c) # Suspensive with Toss to next stage 🚀 <!-- A clear and concise description of what this pr is about. --> Suspensive maintainers (@manudeli, @okinawaa, @minsoo-web) have already joined toss now and agreed to move suspensive repo into toss organization and work on this seriously as part of our work. Also, after discussion with @raon0211, the frontend head of toss, he helped us move the repository. I first created Suspensive outside of Toss to find a quick way to modify @toss/error-boundary and @toss/async-boundary, which are part of the slash library in 2022, and to improve @toss/react-query. Additionally, @suspensive/react-query, a part of this library monorepo, has been introduced as a community resource in the official TanStack Query document. As a result, Suspensive has become a library that I use in every project I create. After joining the company, Toss, I learned that more than 10 services at Toss were already using @suspensive/react and @suspensive/react-query, and I would like to support their common use across the company. We also want to support the use of other companies' production-grade services. we wanted to share this open source with more people in order to unify the interfaces related to Suspense and ErrorBoundary and develop the ecosystem, and we needed a way to continuously receive good feedback. That's why we moved suspensive into toss organization. I hope we can make this front-end ecosystem better together. Thanks, early contributors! we've been able to address a lot of issues and make a lot of improvements! @tooooo1 @ssi02014 @2-NOW @sungh0lim @codebutler @sonsurim @SEOKKAMONI @Kanary159357 @lunelson @relsunkaev @sylvainmouquet @pengooseDev @gjlee94 @wes5510 @chaaerim @minchodang @zillako @sukvvon @jinn2u [![contributors](https://contrib.rocks/image?repo=toss/suspensive)](https://github.com/toss/suspensive/graphs/contributors) ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --------- Co-authored-by: Sojin Park <3102175+raon0211@users.noreply.github.com> Co-authored-by: Minsoo Kim <57122180+minsoo-web@users.noreply.github.com> Co-authored-by: 박찬혁 <69495129+okinawaa@users.noreply.github.com>
# Overview fix typos I hope it helps. <!-- A clear and concise description of what this pr is about. --> ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --------- Co-authored-by: Jonghyeon Ko <jonghyeon@toss.im>
…inference in useSuspenseQueries (#911) # Overview fixed: #889 Fixes a bug where the TypeScript engine would hang due to the complex return type of useSuspenseQueries. ## Issue ```ts // build -> dist/useSuspenseQueries.d.ts /** * SuspenseQueriesResults reducer recursively maps type param to results */ type SuspenseQueriesResults<T extends Array<any>, TResult extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<UseSuspenseQueryResult> : T extends [] ? [] : T extends [infer Head] ? [...TResult, GetSuspenseResults<Head>] : T extends [infer Head, ...infer Tail] ? SuspenseQueriesResults<[...Tail], [...TResult, GetSuspenseResults<Head>], [...TDepth, 1]> : T extends Array<UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>> ? Array<UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>> : Array<UseSuspenseQueryResult>; declare function useSuspenseQueries<T extends any[]>({ queries, context, }: { queries: readonly [...SuspenseQueriesOptions<T>]; context?: UseQueryOptions['context']; // return type 🤔 }): T extends [] ? [] : T extends [infer Head] ? [GetSuspenseResults<Head>] : T extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_1 ? T_1 extends […Tail] ? T_1 extends [] ? [] : T_1 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_1 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_2 ? T_2 extends […Tail] ? T_2 extends [] ? [] : T_2 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_2 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_3 ? T_3 extends […Tail] ? T_3 extends [] ? [] : T_3 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_3 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_4 ? T_4 extends […Tail] ? T_4 extends [] ? [] : T_4 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_4 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_5 ? T_5 extends […Tail] ? T_5 extends [] ? [] : T_5 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_5 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_6 ? T_6 extends […Tail] ? T_6 extends [] ? [] : T_6 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_6 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_7 ? T_7 extends […Tail] ? T_7 extends [] ? [] : T_7 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_7 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_8 ? T_8 extends […Tail] ? T_8 extends [] ? [] : T_8 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_8 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_9 ? T_9 extends […Tail] ? T_9 extends [] ? [] : T_9 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_9 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_10 ? T_10 extends […Tail] ? T_10 extends [] ? [] : T_10 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_10 extends [infer Head_1, …infer Tail] ? any : T_10 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_9 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_8 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_7 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_6 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_5 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_4 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_3 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_2 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_1 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[]; export { type SuspenseQueriesOptions, type SuspenseQueriesResults, useSuspenseQueries }; ``` When you check the built type declarations, you'll see that the return type of useSuspenseQueries is determined through very complex type inference. This complexity in the inference process can cause the TypeScript engine to hang. (This issue is also documented in the TypeScript GitHub issues.) - microsoft/TypeScript#38182 ```ts // return type 🤔 T extends [] ? [] : T extends [infer Head] ? [GetSuspenseResults<Head>] : T extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_1 ? T_1 extends […Tail] ? T_1 extends [] ? [] : T_1 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_1 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_2 ? T_2 extends […Tail] ? T_2 extends [] ? [] : T_2 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_2 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_3 ? T_3 extends […Tail] ? T_3 extends [] ? [] : T_3 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_3 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_4 ? T_4 extends […Tail] ? T_4 extends [] ? [] : T_4 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_4 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_5 ? T_5 extends […Tail] ? T_5 extends [] ? [] : T_5 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_5 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_6 ? T_6 extends […Tail] ? T_6 extends [] ? [] : T_6 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_6 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_7 ? T_7 extends […Tail] ? T_7 extends [] ? [] : T_7 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_7 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_8 ? T_8 extends […Tail] ? T_8 extends [] ? [] : T_8 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_8 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_9 ? T_9 extends […Tail] ? T_9 extends [] ? [] : T_9 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_9 extends [infer Head_1, …infer Tail] ? […Tail] extends infer T_10 ? T_10 extends […Tail] ? T_10 extends [] ? [] : T_10 extends [infer Head] ? [GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head_1>, GetSuspenseResults<Head>] : T_10 extends [infer Head_1, …infer Tail] ? any : T_10 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_9 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_8 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_7 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_6 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_5 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_4 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_3 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_2 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T_1 extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[] : never : never : T extends UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>[] ? UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseSuspenseQueryResult<unknown, unknown>[]; ``` Currently, the return type is inferred for complex types. ## Improvement ```ts // useSuspenseQueries.ts export function useSuspenseQueries<T extends any[]>({ queries, context, }: { queries: readonly [...SuspenseQueriesOptions<T>] context?: UseQueryOptions['context'] }): SuspenseQueriesResults<T> { return useQueries({ queries: queries.map((query: typeof queries) => ({ ...query, suspense: true })), context, }) as SuspenseQueriesResults<T> } ``` Specify the return type explicitly to prevent TypeScript’s inference from hanging. ```ts // build -> dist/useSuspenseQueries.d.ts /** * SuspenseQueriesResults reducer recursively maps type param to results */ type SuspenseQueriesResults<T extends Array<any>, TResult extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<UseSuspenseQueryResult> : T extends [] ? [] : T extends [infer Head] ? [...TResult, GetSuspenseResults<Head>] : T extends [infer Head, ...infer Tail] ? SuspenseQueriesResults<[...Tail], [...TResult, GetSuspenseResults<Head>], [...TDepth, 1]> : T extends Array<UseSuspenseQueryOptions<infer TQueryFnData, infer TError, infer TData, any>> ? Array<UseSuspenseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>> : Array<UseSuspenseQueryResult>; declare function useSuspenseQueries<T extends any[]>({ queries, context, }: { queries: readonly [...SuspenseQueriesOptions<T>]; context?: UseQueryOptions['context']; }): SuspenseQueriesResults<T>; export { type SuspenseQueriesOptions, type SuspenseQueriesResults, useSuspenseQueries }; ``` The complex inference process is replaced with `SuspenseQueriesResults`, simplifying it and preventing the TypeScript engine from hanging. ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --------- Co-authored-by: Jonghyeon Ko <jonghyeon@toss.im>
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @suspensive/react@2.0.5 ### Patch Changes - [#912](#912) [`0c86892`](0c86892) Thanks [@manudeli](https://github.com/manudeli)! - chore(\*): suspensive with toss ## @suspensive/react-await@0.0.19 ### Patch Changes - [#912](#912) [`0c86892`](0c86892) Thanks [@manudeli](https://github.com/manudeli)! - chore(\*): suspensive with toss ## @suspensive/react-image@0.0.13 ### Patch Changes - [#912](#912) [`0c86892`](0c86892) Thanks [@manudeli](https://github.com/manudeli)! - chore(\*): suspensive with toss ## @suspensive/react-query@2.0.5 ### Patch Changes - [#911](#911) [`c6c0640`](c6c0640) Thanks [@gwansikk](https://github.com/gwansikk)! - fix(react-query): improved TypeScript engine halt due to return type inference in useSuspenseQueries - [#912](#912) [`0c86892`](0c86892) Thanks [@manudeli](https://github.com/manudeli)! - chore(\*): suspensive with toss - Updated dependencies \[[`0c86892`](0c86892)]: - @suspensive/react@2.0.5 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sojin Park <3102175+raon0211@users.noreply.github.com>
Co-authored-by: Sojin Park <3102175+raon0211@users.noreply.github.com>
…seInfiniteQuery` (#923) # Overview Updates the JSDoc for the `useSuspenseQueries` and `useSuspenseInfiniteQuery` functions. ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --------- Co-authored-by: Jonghyeon Ko <jonghyeon@toss.im>
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @suspensive/react-query@2.0.6 ### Patch Changes - [#923](#923) [`1e7fbbe`](1e7fbbe) Thanks [@gwansikk](https://github.com/gwansikk)! - fix(react-query): update JSDoc for `useSuspenseQueries`, `useSuspenseInfiniteQuery` - Updated dependencies \[]: - @suspensive/react@2.0.6 ## @suspensive/react@2.0.6 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
gwansikk
approved these changes
Sep 4, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool !! 👍👍👍
manudeli
added a commit
that referenced
this pull request
Sep 4, 2024
related with #1071 # Overview <!-- A clear and concise description of what this pr is about. --> ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --------- Co-authored-by: Hyeonjae Lee <71202076+2-NOW@users.noreply.github.com> Co-authored-by: Jun <26808056+juno7803@users.noreply.github.com> Co-authored-by: GwanSik Kim <39869096+gwansikk@users.noreply.github.com> Co-authored-by: 김동희 <31029000+bigsaigon333@users.noreply.github.com> Co-authored-by: Juhyeok Kang <23312485+kangju2000@users.noreply.github.com> Co-authored-by: 김석진(poki) <102217654+SEOKKAMONI@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
related with #1071
Overview
PR Checklist