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

Unable to use library when using "moduleResolution: 'bundler'" in tsconfig.json? #401

Closed
uncvrd opened this issue Mar 8, 2024 · 0 comments · Fixed by #406
Closed

Unable to use library when using "moduleResolution: 'bundler'" in tsconfig.json? #401

uncvrd opened this issue Mar 8, 2024 · 0 comments · Fixed by #406
Labels
bug Something isn't working

Comments

@uncvrd
Copy link
Contributor

uncvrd commented Mar 8, 2024

Describe the bug
Hi there! I've been slowly working through implementing this library while moving from some TRPC endpoints. The queries work great but I ran in to an edge case with mutations that I thought I would bring up that's super easy to recreate hoping that there's a fix we can work together on?

Basically, I have a NextJS app that uses moduleResolution: "Bundler" https://www.typescriptlang.org/tsconfig#moduleResolution as it is recommended for apps that use things like webpack or vite...when I try to use useDeleteMutation, I lose typesafety in the props. When inspecting the library's index.d.ts for useDeleteMutation, it marks the import * as _tanstack_react_query_build_legacy_types from '@tanstack/react-query/build/legacy/types'; as "unresolved".

If I take the example repo and modify to moduleResolution: "Bundler" and restart the TS Language Server...

I see the following:

image

If I switch back moduleResolution: node then the typesafety works!

image

I'm wondering if we can provide some compatibility for this moduleResolution?

To Reproduce

  1. Go to examples/react-query/tsconfig.json
  2. Update the tsconfig.json to
{
  "compilerOptions": {
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "incremental": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "Bundler", // <----- THIS CHANGED
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "./*"
      ]
    }
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}
  1. Restart TS Language server
  2. Write a useDeleteMutation in the use-query.tsx and try and view the properties

Here's a forked repo that recreate's the issue: https://github.com/uncvrd/supabase-cache-helpers

Here's the git diff for reference: uncvrd@06c3976

Expected behavior
I expect to have typesafety when using moduleResolution: Bundler in the tsconfig.json

Possibly more relevant information here? TanStack/query#6318

Happy to help debug, thanks so much for working on this project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant