blitz-js / legacy-framework

MIT License
3 stars 2 forks source link

Missing typescript for paginate function #372

Closed IRediTOTO closed 2 years ago

IRediTOTO commented 2 years ago

What is the problem?

Hi, I just want report missing ts of paginate , that made useQuery in client lost ts too image image image

Paste all your error logs here:

You dont need this

Paste all relevant code snippets here:

const {
      items: tags,
      hasMore,
      nextPage,
      count,
    } = await paginate({
      skip,
      take,
      count: () => db.tag.count({ where }),
      query: (paginateArgs) => db.tag.findMany({ ...paginateArgs, where, orderBy }),
    });

const [tagsQueryData, { isLoading: isLoadingTagsQuery }] = useQuery(
    getTags,
    { take: 250 },
    { staleTime: Infinity, suspense: false }
  );

What are detailed steps to reproduce this?

  1. This is default code when call useQuery on client

Run blitz -v and paste the output here:

Windows 10 | win32-x64 | Node: v14.18.1

blitz: 0.44.3 (local)

  Package manager: yarn
  System:
    OS: Windows 10 10.0.22000
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    Memory: 4.76 GB / 15.92 GB
  Binaries:
    Node: 14.18.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.1.3 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  npmPackages:
    @prisma/client: 3.6.0 => 3.6.0
    blitz: 0.44.3 => 0.44.3
    prisma: 3.6.0 => 3.6.0
    react: 18.0.0-alpha-5ca4b0433-20211020 => 18.0.0-alpha-5ca4b0433-20211020  
    react-dom: 18.0.0-alpha-5ca4b0433-20211020 => 18.0.0-alpha-5ca4b0433-20211020
    typescript: 4.5.2 => 4.5.2

Please include below any other applicable logs and screenshots that show your problem:

No response

beerose commented 2 years ago

Hi! So the generated types for paginate function include Awaited type. It was added in the new typescript 4.5, and it looks like you have it, but most likely you have an older version in VS Code. The any issue will disappear once you set the 4.5.x TS version in your editor. In VS Code you'll have to find Select TypeScript version in the command palette, and then pick the one from node_modules:

Screenshot 2021-12-08 at 15 39 50 Screenshot 2021-12-08 at 15 39 57

I'm closing this issue then. But feel free to reopen if that doesn't solve the problem.