Skip to content

preserveSymlinks breaks useQuery return type #7632

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
dylan-chong opened this issue Jun 26, 2024 · 1 comment
Closed

preserveSymlinks breaks useQuery return type #7632

dylan-chong opened this issue Jun 26, 2024 · 1 comment

Comments

@dylan-chong
Copy link

Describe the bug

// package.json
{
  "dependencies": {
    "@tanstack/react-query": "5.48.0"
  },
  "devDependencies": {
    "typescript": "5.5.2"
  }

// tsconfig.json
{
	"compilerOptions": {
		"lib": ["dom", "esnext"],
		"preserveSymlinks": true
	}
}

// index.js
import { useQuery } from '@tanstack/react-query';
const { data } = useQuery({ queryFn: () => Promise.resolve(3), queryKey: ['alskdjf'] })
data; // hover this in IDE

with preserveSymlinks true, hovering in IDE shows "const data: QueryObserverResult<TData, TError>". bad type inference
with preserveSymlinks false, hovering in IDE shows "const data: number" which is (almost) correct. it should be "number | undefined"

2 problems here, but the first one is the main one

Your minimal, reproducible example

see above

Steps to reproduce

see above

Expected behavior

see above

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

  • WSL2, Ubuntu 22.04.3

Tanstack Query adapter

None

TanStack Query version

5.48.0

TypeScript version

5.5.2

Additional context

No response

@TkDodo
Copy link
Collaborator

TkDodo commented Jun 27, 2024

works on my machine (same TS version, flag on):
Screenshot 2024-06-27 at 14 44 42

could also be an issue with TS 5.5.2

but in any case, I don't think there's any action we can take.

@TkDodo TkDodo closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2024
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