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

fix: resolve config without @payload-config in tsconfig #6956

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from

Conversation

RiftLurker
Copy link

Description

Prior to this change the payload generate:types command crashes if @payload-config isn't set as paths in tsconfig.json.

Error parsing tsconfig.json: TypeError [ERR_INVALID_ARG_TYPE]: The "paths[1]" argument must be of type string. Received undefined
node:path:841
    validateString(path, 'path');
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at Object.extname (node:path:841:5)
    at findConfig (file:///D:/Development/gwtools/node_modules/payload/dist/config/find.js:50:14)
    at bin (file:///D:/Development/gwtools/node_modules/payload/dist/bin/index.js:8:24)
    at start (file:///D:/Development/gwtools/node_modules/payload/bin.js:18:3) {
  code: 'ERR_INVALID_ARG_TYPE'
}

According to code and comments the function catches errors and tries resolving the config by other means. Since it doesn't return the configPath on error the fallback method instantly crashes though.
This change prevents throwing the error in the first place so the fallback method gets enough data to find the config.

  • I have read and understand the CONTRIBUTING.md document in this repository.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have added tests that prove my fix is effective or that my feature works
  • Existing test suite passes locally with my changes
  • I have made corresponding changes to the documentation

Prior to this change the `payload generate:types` command crashes if `@payload-config` isn't set as `paths` in tsconfig.json.

```
Error parsing tsconfig.json: TypeError [ERR_INVALID_ARG_TYPE]: The "paths[1]" argument must be of type string. Received undefined
node:path:841
    validateString(path, 'path');
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at Object.extname (node:path:841:5)
    at findConfig (file:///D:/Development/gwtools/node_modules/payload/dist/config/find.js:50:14)
    at bin (file:///D:/Development/gwtools/node_modules/payload/dist/bin/index.js:8:24)
    at start (file:///D:/Development/gwtools/node_modules/payload/bin.js:18:3) {
  code: 'ERR_INVALID_ARG_TYPE'
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant