添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Error TS2351 "This expression is not constructable" for new SchemaBuilder #597

@Nikxt

Description

We had to update our tsconfig file and this resulted in a new typescript error when creating a new SchemaBuilder.

Code:

export const builder = new SchemaBuilder<{}>(builderOptions);

Error:

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

Changes in our tsconfig:

  • Changed "module": "commonjs" to "module": "NodeNext"
  • Added line "moduleResolution": "NodeNext"
  • Full tsconfig.json:

    "compilerOptions": { "target": "ESNext", "module": "NodeNext", "allowJs": true, "declaration": false, "outDir": "built", "maxNodeModuleJsDepth": 10, "strict": true, "moduleResolution": "NodeNext", "allowSyntheticDefaultImports": true, "esModuleInterop": true, "skipLibCheck": true "include": ["src/**/*"], "exclude": ["node_modules"]

    Package versions:

    "@pothos/core": "^3.20.0"
    "typescript": "^4.8.2"
    

    Repository with error reproduction:
    Repository: builder-ts-error-reproduction