Skip to content

Typescript compilation fails with v2 beta.5 #220

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

Closed
msokk opened this issue Jul 25, 2022 · 3 comments
Closed

Typescript compilation fails with v2 beta.5 #220

msokk opened this issue Jul 25, 2022 · 3 comments

Comments

@msokk
Copy link

msokk commented Jul 25, 2022

A few direct imports from @tanstack/query-core/src source code cause strict mode Typescript compilations to fail:

../../node_modules/@tanstack/query-core/src/focusManager.ts:16:18 - error TS7030: Not all code paths return a value.
16     this.setup = (onFocus) => {
                    ~~~~~~~~~~~~~~

../../node_modules/@tanstack/query-core/src/infiniteQueryBehavior.ts:187:4 - error TS7030: Not all code paths return a value.
187 ): boolean | undefined {
       ~~~~~~~~~~~~~~~~~~~

../../node_modules/@tanstack/query-core/src/infiniteQueryBehavior.ts:205:4 - error TS7030: Not all code paths return a value.
205 ): boolean | undefined {
       ~~~~~~~~~~~~~~~~~~~

../../node_modules/@tanstack/query-core/src/onlineManager.ts:16:18 - error TS7030: Not all code paths return a value.
16     this.setup = (onOnline) => {
                    ~~~~~~~~~~~~~~~

../../node_modules/@tanstack/query-core/src/retryer.ts:184:17 - error TS7030: Not all code paths return a value.
184           .then(() => {
                    ~~~~~~~

../../node_modules/@tanstack/query-core/src/utils.ts:417:39 - error TS7030: Not all code paths return a value.
417 export function getAbortController(): AbortController | undefined {
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 6 errors in 5 files.

tsc --noEmit --noImplicitReturns --skipLibCheck

In this case the skipLibCheck does not help as vue-query declaration files are accessed directly and query-core references are not declaration files. For some reason @tanstack/query repo has only the offending strict mode flag turned off

Looks like QueryState and Updater need to be exposed upstream, otherwise correct type imports look ugly like this:

import type { QueryState } from "@tanstack/query-core/build/types/packages/query-core/src/query";
import type { Updater } from "@tanstack/query-core/build/types/packages/query-core/src/utils";
@DamianOsipiuk
Copy link
Owner

Will be fixed here: TanStack/query#3892

@DamianOsipiuk
Copy link
Owner

@msokk
Copy link
Author

msokk commented Sep 10, 2022

Confirmed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants