1

New to ts and not sure how to resolve this. When running tsc I am getting compilation errors from type-graphql and apollo-server-core. This doesn't make sense to me as they come with types and type-graphql is literally meant to be used with typescript. Please help me figure this one out, added everything I could find online to my tsconfig to no avail.

{
   "compilerOptions": {
     "target": "es6",
     "module": "commonjs",
     "lib": ["es5", "es6", "es2017", "dom", "esnext.asynciterable"],
     "skipLibCheck": true,
     "sourceMap": true,
     "outDir": "./dist",
     "moduleResolution": "node",
     "removeComments": true,
     "noImplicitAny": true,
     "strictNullChecks": true,
     "strictFunctionTypes": true,
     "noImplicitThis": true,
     "noUnusedLocals": true,
     "noUnusedParameters": true,
     "noImplicitReturns": true,
     "noFallthroughCasesInSwitch": true,
     "allowSyntheticDefaultImports": true,
     "esModuleInterop": true,
     "emitDecoratorMetadata": true,
     "experimentalDecorators": true,
     "resolveJsonModule": true
   },
   "exclude": ["./node_modules", "./node_modules/**/*"],
   "include": ["./src/**/*.tsx", "./src/**/*.ts"]
 }

and the package.json

{
   "name": "kp-api",
   "version": "1.0.0",
   "description": "ketopal api app",
   "main": "index.js",
   "license": "NONE",
   "private": true,
   "devDependencies": {
      "@types/express": "^4.17.11",
      "@types/node": "^8.0.29",
      "nodemon": "^2.0.7",
      "typescript": "3.3.3333"
   },
   "dependencies": {
      "apollo-server-express": "^2.23.0",
      "express": "^4.17.1",
      "graphql": "^15.5.0",
      "pg": "^8.4.0",
      "reflect-metadata": "^0.1.10",
      "type-graphql": "^1.1.1",
      "typeorm": "0.2.32"
   },
   "scripts": {
      "build": "tsc",
      "dev": "nodemon dist/index.js",
      "start": "rm -rf dist; yarn tsc; node dist/index.js",
      "watch": "tsc -w"
   }
}

Edit: To answer the first comment, the errors all look like

yarn run v1.22.10
$ tsc
node_modules/type-graphql/dist/decorators/unions.d.ts:4:63 - error TS1005: ',' expected.

4 export interface UnionTypeConfig<TClassTypes extends readonly ClassType[]> extends ResolveTypeOptions<UnionFromClasses<TClassTypes>> {
                                                                ~~~~~~~~~

node_modules/type-graphql/dist/decorators/unions.d.ts:4:72 - error TS1005: ',' expected.

4 export interface UnionTypeConfig<TClassTypes extends readonly ClassType[]> extends ResolveTypeOptions<UnionFromClasses<TClassTypes>> {
...
7
  • What are the errors thrown? Commented Apr 23, 2021 at 4:53
  • updated the question with examples, there are 42 total errors so didn't want to paste them all Commented Apr 23, 2021 at 4:56
  • Also, I don't know if this helps, but I saw a post about ts-node so I decided to try it and npx ts-node src/index.ts doesn't throw any errors. I am so confused. Commented Apr 23, 2021 at 4:58
  • 1
    This sometimes happens when your TS is outdated - try bumping it up - the current version is 4.2.4. Your type-graphql is pretty old too and is set not to update. Commented Apr 23, 2021 at 4:59
  • you're not excluding node_modules -typescriptlang.org/docs/handbook/tsconfig-json.html#examples - try "exclude": ["node_modules"], Commented Apr 23, 2021 at 5:06

0

Your Answer

By clicking β€œPost Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.