Skip to content

@tanstack/eslint-plugin-query missing (peer) dependency on typescript #9097

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

Open
anomiex opened this issue May 2, 2025 · 1 comment
Open

Comments

@anomiex
Copy link

anomiex commented May 2, 2025

Describe the bug

@tanstack/eslint-plugin-query tries to import typescript, but does not declare it as a dependency or peer dependency.

This happens to work with npm's hoisting due to other dependencies pulling that package in, but will fail with yarn's p'n'p or pnpm with hoisting disabled.

Your minimal, reproducible example

Reproduction steps explain how to reproduce starting with an empty directory.

Steps to reproduce

With yarn:

  1. Create a temporary directory, and cd into it.
  2. echo '{}' > package.json
  3. yarn set version stable
  4. yarn add eslint @tanstack/eslint-plugin-query
  5. echo 'import pluginQuery from "@tanstack/eslint-plugin-query"; export default [ ...pluginQuery.configs["flat/recommended"], ];' > eslint.config.mjs
  6. yarn exec eslint .

With pnpm:

  1. Create a temporary directory, and cd into it.
  2. echo 'hoist-pattern=[]' > .npmrc
  3. pnpm add eslint @tanstack/eslint-plugin-query
  4. echo 'import pluginQuery from "@tanstack/eslint-plugin-query"; export default [ ...pluginQuery.configs["flat/recommended"], ];' > eslint.config.mjs
  5. pnpm exec eslint .

Expected behavior

Eslint runs.

How often does this bug happen?

Every time

Screenshots or Videos

No video or screenshot, but the console output would seem to be helpful here.

With yarn:

Oops! Something went wrong! :(

ESLint: 9.25.1

Error: @tanstack/eslint-plugin-query tried to access typescript, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: typescript (via "typescript/package.json")
Required by: @tanstack/eslint-plugin-query@virtual:dc3fc578bfa5e06182a4d2be39ede0bc5b74940b1ffe0d70c26892ab140a4699787750fba175dc306292e80b4aa2c8c5f68c2a821e69b2c37e360c0dff36ff66#npm:5.74.7 (via /tmp/test/.yarn/__virtual__/@tanstack-eslint-plugin-query-virtual-135df79552/3/home/me/.yarn/berry/cache/@tanstack-eslint-plugin-query-npm-5.74.7-a9272f7a3e-10c0.zip/node_modules/@tanstack/eslint-plugin-query/build/modern/chunk-6ZHBB3IQ.js)

    at makeError (/tmp/test/.pnp.cjs:6959:34)
    at resolveToUnqualified (/tmp/test/.pnp.cjs:8600:21)
    at Object.resolveToUnqualified (/tmp/test/.pnp.cjs:8780:26)
    at resolve$1 (file:///tmp/test/.pnp.loader.mjs:2031:31)
    at nextResolve (node:internal/modules/esm/hooks:748:28)
    at Hooks.resolve (node:internal/modules/esm/hooks:240:30)
    at handleMessage (node:internal/modules/esm/worker:199:24)
    at Immediate.checkForMessages (node:internal/modules/esm/worker:141:28)
    at process.processImmediate (node:internal/timers:485:21)

With pnpm:

Oops! Something went wrong! :(

ESLint: 9.25.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'typescript' imported from /tmp/test/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@tanstack/eslint-plugin-query/build/modern/chunk-6ZHBB3IQ.js
    at Object.getPackageJSONURL (node:internal/modules/package_json_reader:268:9)
    at packageResolve (node:internal/modules/esm/resolve:768:81)
    at moduleResolve (node:internal/modules/esm/resolve:854:18)
    at defaultResolve (node:internal/modules/esm/resolve:984:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:780:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:704:25)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:687:38)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:305:38)
    at ModuleJob._link (node:internal/modules/esm/module_job:137:49)

Platform

  • OS: Linux
  • Browser: N/A
  • Browser version: N/A
  • node version: v22.15.0
  • pnpm version: 10.10.0
  • yarn version: 4.9.1

Tanstack Query adapter

None

TanStack Query version

@tanstack/eslint-plugin-query v5.74.7

TypeScript version

none

Additional context

The attempt to import typescript is here:

Added in #8925.

@TkDodo
Copy link
Collaborator

TkDodo commented May 3, 2025

@Newbie012 we only need the typescript import because of the flags here:

return awaited.flags & (ts.TypeFlags.Void | ts.TypeFlags.Undefined)

we could just copy those two constants for our case to not rely on typescript at runtime ?

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

No branches or pull requests

2 participants