apollo-client: Bug on build with mergeDeep

Intended outcome:

Here are version of packages that I’m using:

    "apollo-angular": "1.0.1",
    "apollo-angular-link-http": "1.0.1",
    "apollo-cache-inmemory": "1.3.9",
    "apollo-client": "2.4.5",
    "apollo-link": "1.2.3",
    "apollo-link-context": "1.0.9",
    "apollo-link-http": "1.5.5",

Actual outcome:

Running ng build produces

node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(1,214): error TS1005: ',' expected.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 7
  • Comments: 20 (6 by maintainers)

Most upvoted comments

+1

Wanted to share my observations in case it assists others. A little back story: we have a large enterprise application codebase that was working, but seemingly breaks following running an ‘npm install’ - error is the reported deepMerge. We can’t currently migrate to Angular 7, and Angular 6 of course doesn’t support TypeScript 3… So we find ourselves having to find a workaround until we can tackle migration - which is unfortunate. I am sharing this in case it assists others to avoid wasting 2 days.

Our project’s relevant dependencies from package.json:

    "@angular/animations": "6.1.0",
    "@angular/cdk": "6.4.2",
    "@angular/common": "6.1.0",
    "@angular/compiler": "6.1.0",
    "@angular/core": "6.1.0",
    "@angular/elements": "6.1.7",
    "@angular/forms": "6.1.0",
    "@angular/http": "6.1.0",
    "@angular/platform-browser": "6.1.0",
    "@angular/platform-browser-dynamic": "6.1.0",
    "@angular/pwa": "0.8.0",
    "@angular/router": "6.1.0",
    "@angular/service-worker": "6.1.7",
    "apollo-angular": "1.5.0",
    "apollo-angular-link-http": "1.4.0",
    "apollo-cache-inmemory": "1.4.2",
    "apollo-client": "2.4.12",
    "apollo-link-error": "1.1.5",
    "apollo-link-retry": "2.2.8",
    "graphql": "14.1.1",
    "graphql-tag": "2.10.1"

Our project’s relevant dev dependencies from package.json:

    "@angular-devkit/build-angular": "0.6.8",
    "@angular-devkit/build-ng-packagr": "0.6.8",
    "@angular/cli": "7.3.0",
    "@angular/compiler-cli": "6.1.0"

Node/NPM:

node: v10.15.0
npm: 6.4.1

I’ve found two workarounds that get us building, though we have yet to do the testing that will be needed to vet if this is actually a workable solution (e.g. everything behaving at runtime)… In any case, either of the following will get us building again:

  • Remove all of the nested ‘\apollo-*\node_modules’ (many of the apollo libs have nested node_modules, mostly for the 3 apollo-utilities versions currently in play).
  • Replace the nested '\apollo-*\node_modules\apollo-utilities' with an older version (I’ve tested 1.0.22)

As mentioned, performing either of the above in our codebase results in a working build.

As mentioned, I’ve tracked down 3 versions of apollo-utilities at play within the various nested node_modules: 1.2.1, 1.0.22, 1.1.2.

For the interested, here is what I am seeing when I inspect the package-lock.json following npm install:

Packge: apollo-cache@1.2.1
Requires: apollo-utilities@^1.2.1
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-cache-inmemory@1.4.2
Requires: apollo-utilities@^1.1.2
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-client@2.4.12
Requires: apollo-utilities@^1.1.2
Resolved: apollo-utilities@1.1.2
------------
Packge: apollo-link@1.2.3
Requires: apollo-utilities@^1.0.0
Resolved: <No Dependencies Obj Present>
------------
Packge: apollo-link-dedup@1.0.16
Requires: apollo-link@^1.2.9 > apollo-utilities@^1.2.1
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-link-error@1.1.5
Requires: apollo-link@^1.2.9 > apollo-utilities@^1.2.1
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-link-http-common@0.2.11
Requires: apollo-link@^1.2.9 > apollo-utilities@^1.2.1
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-link-retry@2.2.8
Requires: apollo-link@^1.2.6 (resolves 1.2.9) > apollo-utilities@^1.2.1
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-utilities@1.0.22
Requires: <NA - This is top node_modules install>
Resolved: apollo-utilities@1.0.22
------------

@benjamn I’m seeing this error with typescript v3.3.3333.

Edit: Actually, I’m using Typescript v3.3.3333, but a package has a dependency instead of a peer dependency, pinning the version at 2.2. So it’s not actually running Typescript 3 for me:

https://github.com/prisma/serverless-plugin-typescript/blob/master/package.json

So, ignore this, it’s not actually happening in v3.

@soniachan You’re using a fairly old version of typescript (2.5.3). Another user reported that the problem went away after updating Angular CLI and typescript: #4501 (comment)

Upgrading Angular and typescript worked for me!! 😃

@angular/core”: “6.1.10”, “@angular/cli”: “6.2.5”, “apollo-utilities”: “1.0.21”, “typescript”: “2.8.4”

Folks, please read the existing comments before posting the same information again. Updating typescript to version 3.0.0 or higher has fixed this problem for others. If that’s not an option, I’d like to understand what’s holding you back, so that we can weigh our options. Commenting that you have the same problem is not helpful at this point. Thanks.

If you’re not able to update typescript, you might be able to disable type checking for apollo-utilities specifically, or node_modules in general. I’m not sure exactly how that would work in an Angular project, but it seems like it should be feasible.