7

I am trying to set up my server side backend and I'm hitting this error:

node_modules/apollo-cache-control/dist/index.d.ts:24:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'cacheControl' must be of type 'ResolveInfoCacheControl', but here has type '{ setCacheHint: (hint: CacheHint) => void; cacheHint: CacheHint; }'.

24         cacheControl: {
           ~~~~~~~~~~~~

  node_modules/@nestjs/graphql/node_modules/apollo-server-types/dist/index.d.ts:140:9
    140         cacheControl: ResolveInfoCacheControl;
                ~~~~~~~~~~~~
    'cacheControl' was also declared here.
James Z
  • 12,209
  • 10
  • 24
  • 44

3 Answers3

3

I just found a fix for this, You have to add this to your tsconfig.json file:

"skipLibCheck": true

My tsconfig.json looks like:

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es2015",
    "noImplicitAny": false,
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "lib",
    "baseUrl": "./",
    "lib": ["es6", "esnext.asynciterable"],
    "types": ["node"],
    "skipLibCheck": true
  },
  "include": ["src/**/*"]
}

And also make sure to have all apollo packages to have same exact version.

Ilyas karim
  • 4,592
  • 4
  • 33
  • 47
  • 1
    It is good that there is this workaround, but I'm not sure this is a good long-term solution as this will affect all libraries. I wonder if there is anything that can be done that is a bit more targeted to the offending library? – David Nov 17 '21 at 10:03
  • @David for now I am proceeding with this hack. I totally agree ith you. – Ilyas karim Nov 18 '21 at 07:12
1

Make sure all apollo packages (apollo-server, apollo-server-express, apollo-server-core) have the exact same version

0

In my case it was a bad import. I was importing import { VariableValues } from 'apollo-server-types/src' instead of import { VariableValues } from 'apollo-server-types'

I swear it was the auto-importer....

Kyle Venn
  • 4,597
  • 27
  • 41