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

PaginatedDocs<TypeWithID & Record<string, unknown>> #6799

Closed
szpolny opened this issue Jun 17, 2024 · 11 comments
Closed

PaginatedDocs<TypeWithID & Record<string, unknown>> #6799

szpolny opened this issue Jun 17, 2024 · 11 comments

Comments

@szpolny
Copy link

szpolny commented Jun 17, 2024

Payload Version

3.0.0-beta.47

Node Version

v22.3.0

Next.js Version

15.0.0-rc.0

Describe the Bug

// app/(app)/page.tsx

...
import { getPayload } from 'payload';
import configPromise from '@payload-config';
import { type News } from '~~/payload-types';

const getArticles = async () => {
  const payload = await getPayload({
    config: configPromise,
  });

  const newsCollection = await payload.find<'news'>({
    collection: 'news',
    sort: '-createdAt',
    pagination: false,
    where: {
      _status: {
        equals: 'published',
      },
    },
  });


  return newsCollection;
};

...

In this code im quering 'news' collection from local api. Property docs, inside response object should be Type from generated:types but it is not.

Adapters and Plugins

db-postgres, storage-uploadthing, richtext-lexical

@szpolny szpolny added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Jun 17, 2024
@szpolny
Copy link
Author

szpolny commented Jun 17, 2024

Ok, it turns out that this is problem with vscode. I opened project in webstorm and it returns correct type.

@szpolny szpolny closed this as not planned Won't fix, can't repro, duplicate, stale Jun 17, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Jun 17, 2024
@ydemetriades
Copy link
Contributor

I am experiencing the same issue (VS Code).

Tried it on beta.40 and beta.53

@Girbi
Copy link

Girbi commented Jul 10, 2024

Same issue, payload version: 2.0.0, VS Code. Typescript version 5.5.3 is not working.

@RyanScarbrough
Copy link

Same issue, woke up today and suddenly had it.

Payload version 2.22.0
VS Code version 1.91.1

const { docs: orders } = await payload.find({
     collection: "orders",
     where: {
          id: {
               equals: orderId,
          },
     },
});

orders is now of type: (TypeWithID & Record<string, unknown>)[]

@RyanScarbrough
Copy link

RyanScarbrough commented Jul 12, 2024

I believe this is due to a Duplicate identifier 'GeneratedTypes' in payload-types.ts

Issues:
#6958
#6896

This appears to be a VS Code problem, as WebStorm doesn't have this problem.

Using TypeScript version 5.4.5 did not fix the issue for me.

@AlessioGr
Copy link
Member

AlessioGr commented Jul 12, 2024

I believe this is due to a Duplicate identifier 'GeneratedTypes' in payload-types.ts

Issues: #6958 #6896

This appears to be a VS Code problem, as WebStorm doesn't have this problem.

Using TypeScript version 5.4.5 did not fix the issue for me.

VC Code by default often uses an incorrect typescript version. You will have to set it to the workspace typescript version (5.4.5): https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript

@RyanScarbrough
Copy link

I believe this is due to a Duplicate identifier 'GeneratedTypes' in payload-types.ts
Issues: #6958 #6896
This appears to be a VS Code problem, as WebStorm doesn't have this problem.
Using TypeScript version 5.4.5 did not fix the issue for me.

VC Code by default often uses an incorrect typescript version. You will have to set it to the workspace typescript version (5.4.5): https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript

Yup this fixed the issue for me, thank you! For whatever reason VS Code decided to switch to an incompatible version of TypeScript. Switching back to the workspace version fixed it just as you said.

ts-fix

@toximate
Copy link

Same issue and yet no solutions , [email protected] & [email protected]

@AlessioGr
Copy link
Member

Same issue and yet no solutions , [email protected] & [email protected]

Payload v2 does not and will never support TypeScript 5.5+. Please switch to TypeScript 5.4.5

@toximate
Copy link

Same issue and yet no solutions , [email protected] & [email protected]

Payload v2 does not and will never support TypeScript 5.5+. Please switch to TypeScript 5.4.5

Thank you

Copy link
Contributor

github-actions bot commented Sep 6, 2024

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants