lukemorales / query-key-factory

A library for creating typesafe standardized query keys, useful for cache management in @tanstack/query
https://www.npmjs.com/package/@lukemorales/query-key-factory
MIT License
1.23k stars 32 forks source link

I can't export my query keys. (I'm following the official docs). #30

Closed InNickF closed 1 year ago

InNickF commented 1 year ago

H! I'm trying to use the library (v1.0.0 and v1.0.1) but I got this error with a simple implementation: Exported variable 'userQueries' has or is using name 'QueryFunctionContext' from external module ".../node_modules/@lukemorales/query-key-factory/dist/index" but cannot be named. ts(4023)

Code:

import { createQueryKeyStore } from "@lukemorales/query-key-factory";
export const userQueries = createQueryKeyStore({ <<< error in this line.
  user: { me: null },
});

Literally that's all my code, if I do not export it, all works fine and I can use TanStack Query without problems.

What am I doing wrong?

bayou-brogrammer commented 1 year ago

I am hitting the same wall. I believe QueryFunctionContext needs to be exported with the lib

lukemorales commented 1 year ago

Interesting.... I didn't experience that with while testing before the v1.0 release. I'll investigate and provide a fix @InNickF @lecoqjacob

bayou-brogrammer commented 1 year ago

Let me know if you need help testing a fix or patch. This started happening on my end whenever I upgraded to 1.0.0+

lukemorales commented 1 year ago

@lecoqjacob can you try providing a reproduction in a codesandbox?

InNickF commented 1 year ago

Hi! @lukemorales, sure: https://codesandbox.io/s/immutable-bird-7j8lxq?file=/queries/user.ts

lukemorales commented 1 year ago

Thanks for the repro @InNickF, I'm taking a look at the issue

lukemorales commented 1 year ago

@InNickF @lecoqjacob sorry it took some time, I needed to figure some things out for the CI that was publishing the wrong build but version 1.0.3 is published with the fix for this

InNickF commented 1 year ago

@lukemorales, it looks good, but now I have another kind of error in the same line: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed. By now I just disabled in my tsconfig the declaration option to hide the error, but I think this is other error, must I create a new issue?

bayou-brogrammer commented 1 year ago

@lukemorales My vscode stopped throwing errors on the update! Thanks!

lukemorales commented 1 year ago

@InNickF could you create a new issue then and let's track that specific error. Also, I'd appreciate if you could provide an updated reproduction on that issue with what introduced the new error 🙏🏻