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

Duplicate identifier 'GeneratedTypes'.ts(2300) in blank project #6896

Closed
Lorentzo92 opened this issue Jun 23, 2024 · 14 comments
Closed

Duplicate identifier 'GeneratedTypes'.ts(2300) in blank project #6896

Lorentzo92 opened this issue Jun 23, 2024 · 14 comments
Assignees
Labels
status: verified If an issue has been reproduced v2

Comments

@Lorentzo92
Copy link

Link to reproduction

No response

Describe the Bug

After generating the types from the blank project template, in the payload-types.ts i get the ts error:

Duplicate identifier 'GeneratedTypes'.ts(2300)
index.d.ts(23, 32): 'GeneratedTypes' was also declared here.
interface GeneratedTypes

declare module 'payload' {
export interface GeneratedTypes extends Config {}
}

And the local api does not infer types.

I got this error these days after opening some repos i didnt touch for a couple of months, it might be an issue with the latest vs code version maybe?!? i tried to reinstall vscode, do some other cleanings but i still get the ts error, even in the blank project.

My package.json is:

{
"name": "issue-types-payloadcms",
"description": "A blank template to get started with Payload",
"version": "1.0.0",
"main": "dist/server.js",
"license": "MIT",
"scripts": {
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
"build:server": "tsc",
"build": "yarn copyfiles && yarn build:payload && yarn build:server",
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
"copyfiles": "copyfiles -u 1 "src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}" dist/",
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
"generate:graphQLSchema": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema",
"payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload"
},
"dependencies": {
"@payloadcms/bundler-webpack": "^1.0.0",
"@payloadcms/db-mongodb": "^1.0.0",
"@payloadcms/plugin-cloud": "^3.0.0",
"@payloadcms/richtext-slate": "^1.0.0",
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"express": "^4.19.2",
"payload": "^2.0.0"
},
"devDependencies": {
"@types/express": "^4.17.9",
"copyfiles": "^2.4.1",
"nodemon": "^2.0.6",
"ts-node": "^9.1.1",
"typescript": "^4.8.4"
}
}

To Reproduce

npx create-payload-app@latest

pnpm generate:types

Payload Version

^2.0.0

Adapters and Plugins

No response

@Lorentzo92 Lorentzo92 added status: needs-triage Possible bug which hasn't been reproduced yet v2 labels Jun 23, 2024
@denisprado
Copy link

I resoved this problem putting:

typescript :{ declare: false, } }
in the payload.config.ts

@Lorentzo92
Copy link
Author

Lorentzo92 commented Jun 24, 2024

yes but then using the local api of payload does not infer types

@Lorentzo92
Copy link
Author

It seems the issue comes from using the ts version in vs code:
5.6.0-dev.20240623TypeScript Version

@javierlinked
Copy link
Contributor

For the moment fix typescript version on package.json file while they work on a fix.

"typescript": "5.4.5",

as mentioned here.

@jmikrut
Copy link
Member

jmikrut commented Jun 25, 2024

@javierlinked thanks for the comment - you're right!

fix incoming shortly

@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Jun 25, 2024
@sourabpramanik
Copy link

Excluding the payload-types.ts in .eslintrc.cjs and tsconfig.json also works. But I am not sure if this is a good approach

@AlessioGr
Copy link
Member

This is an issue with TS 5.5 and has been fixed by #6385. Will be available in the upcoming 3.0.0-beta.54. If you need it right now, feel free to use 3.0.0-canary.ee0375f.

If this is still an issue in these versions, please let me know and I'll re-open

@AlessioGr AlessioGr added status: verified If an issue has been reproduced v3 labels Jun 25, 2024
@devj3ns
Copy link

devj3ns commented Jun 26, 2024

We are running into the same issue with payload 2.22.1. Will the above fix be included in the next hotfix of V2?

@cbratschi
Copy link

Also getting this issue with Payload 2.25.0.

@AlessioGr
Copy link
Member

AlessioGr commented Aug 6, 2024

For Payload v2, please pin your TypeScript version to 5.4.5. We currently have no plans supporting TypeScript 5.5+ in Payload v2

@kariyngva
Copy link
Contributor

For Payload v2, please pin your TypeScript version to 5.4.5. We currently have no plans supporting TypeScript 5.5+ in Payload v2

Would you advise against using a workaround for this?

@nachten
Copy link

nachten commented Sep 3, 2024

Please provide us an solution for V2 .... kind regards.

@Lorentzo92
Copy link
Author

select typescript version 4.9.5 or any version <= 5.4.5

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
status: verified If an issue has been reproduced v2
Projects
None yet
Development

No branches or pull requests

10 participants