T
TanStack3y ago
fair-rose

v5 The inferred type of 'X' cannot be named without a reference to...

The following code is fine for the TS language server with version 4, however, then uprgading react-query to version 5 the following error shows up.
import { useMutation } from '@tanstack/react-query';

export const useLogin = () => useMutation({});
import { useMutation } from '@tanstack/react-query';

export const useLogin = () => useMutation({});
The inferred type of 'useLogin' cannot be named without a reference to '../../../../../node_modules/@tanstack/react-query/build/modern/types'. This is likely not portable. A type annotation is necessary. ts(2742)
The inferred type of 'useLogin' cannot be named without a reference to '../../../../../node_modules/@tanstack/react-query/build/modern/types'. This is likely not portable. A type annotation is necessary. ts(2742)
2 Replies
optimistic-gold
optimistic-gold3y ago
what would you expect to happen with this code? It looks pretty invalid to me
fair-rose
fair-roseOP3y ago
It's invalid indeed, just removed a lot of not-required code to reproduce the issue. However, it seems that there is a bug with typescript that caused it (can't find the GH issue atm). Removing those 2 lines resolved the issue (not sure why i had them in the first place as its a Next app):
"declaration": true,
"declarationMap": true,
"declaration": true,
"declarationMap": true,

Did you find this page helpful?