Closed Lorentzo92 closed 3 days ago
I resoved this problem putting:
typescript :{ declare: false, } }
in the payload.config.ts
yes but then using the local api of payload does not infer types
It seems the issue comes from using the ts version in vs code: 5.6.0-dev.20240623TypeScript Version
For the moment fix typescript version on package.json
file while they work on a fix.
"typescript": "5.4.5",
as mentioned here.
@javierlinked thanks for the comment - you're right!
fix incoming shortly
Excluding the payload-types.ts
in .eslintrc.cjs
and tsconfig.json
also works. But I am not sure if this is a good approach
This is an issue with TS 5.5 and has been fixed by https://github.com/payloadcms/payload/pull/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
We are running into the same issue with payload 2.22.1. Will the above fix be included in the next hotfix of V2?
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