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

Error TS2351 for new SchemaBuilder when testing with ts-jest #1107

Closed
lpc921 opened this issue Dec 15, 2023 · 2 comments
Closed

Error TS2351 for new SchemaBuilder when testing with ts-jest #1107

lpc921 opened this issue Dec 15, 2023 · 2 comments

Comments

@lpc921
Copy link

lpc921 commented Dec 15, 2023

Code:

export const builder = new SchemaBuilder({});

Error when running test:

error TS2351: This expression is not constructable.
Type 'typeof import("C:/Users/[...]/node_modules/@pothos/core/dts/index")' has no construct signatures.

Package versions:

"@pothos/core": "3.40.1"
"typescript": "5.2.2"
"jest": "29.7.0",
"ts-jest": "29.1.1",

Repository with error reproduction

Related: #597

@hayes
Copy link
Owner

hayes commented Dec 15, 2023

I think this is a bug in ts-jest. If you follow the esm documentation it says:

Ensure that tsconfig has module with value for ESM, e.g. ES2015 or ES2020 etc...

If change your tsconfig to use those settings:

  "module": "ES2022",
  "moduleResolution": "Node",

Everything works fine. The error you are seeing comes from typescript using settings different than those in the tsconfig in the repo (running the build command/tsc works fine).

I'd recommend opening an issue with ts-jest, since this seems related to them changing or not respecting some options in the repos tsconfig. I personally don't use ts-jest, so not sure about next steps for debugging this further

@lpc921
Copy link
Author

lpc921 commented Dec 15, 2023

Thanks so much for your help. It is working for me now.

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

No branches or pull requests

2 participants