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

building client errors: ERROR in node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(2,52): error TS2370: A rest parameter must be of an array type. #4594

Closed
dutchsparks opened this issue Mar 18, 2019 · 10 comments

Comments

@dutchsparks
Copy link

dutchsparks commented Mar 18, 2019

we're trying to build our angular app in docker but apollo errors: ERROR in node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(2,52): error TS2370: A rest parameter must be of an array type.
we've already updated all our dependencies to the latest version to try and fix this but no luck.
Any ideas would be most welcome.

Intended outcome:

building the client in docker

Actual outcome:

ERROR in node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(2,52): error TS2370: A rest parameter must be of an array type.

Versions
System: OS: macOS Sierra 10.12.6 Binaries: Node: 8.11.3 - /usr/local/bin/node Yarn: 1.9.4 - /usr/local/bin/yarn npm: 6.5.0 - /usr/local/bin/npm Browsers: Chrome: 72.0.3626.121 Firefox: 65.0.1 Safari: 12.0.3

package.json:


{
  "name": "client",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --port 4200 --host 0.0.0.0 --poll 500 --proxy-config proxy.config.json",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "update:schema": "apollo schema:download --endpoint http://0.0.0.0:8000/graphql ./src/app/graphql/schema.json",
    "update:types": "apollo codegen:generate --schema ./src/app/graphql/schema.json --target=typescript"
  },
  "apollo": {
    "schemas": {
      "api": {
        "schema": "src/app/graphql/schema.graphql",
        "endpoint": "http://0.0.0.0:8000/graphql"
      }
    },
    "queries": [
      {
        "schema": "api",
        "includes": [
          "**/*.ts"
        ],
        "excludes": [ "node_modules/**"
        ]
      }
    ]
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.2.9",
    "@angular/cdk": "^7.3.4",
    "@angular/common": "^7.2.9",
    "@angular/compiler": "^7.2.9",
    "@angular/core": "^7.2.9",
    "@angular/flex-layout": "6.0.0-beta.18",
    "@angular/forms": "^7.2.9",
    "@angular/http": "^7.2.9",
    "@angular/material": "^7.3.4",
    "@angular/platform-browser": "^7.2.9",
    "@angular/platform-browser-dynamic": "^7.2.9",
    "@angular/router": "^7.2.9",
    "apollo-angular": "^1.5.0",
    "core-js": "^2.6.5",
    "rxjs": "^6.4.0",
    "zone.js": "~0.8.29",
    "apollo-angular-link-http": "^1.5.0",
    "apollo-link": "^1.2.11",
    "apollo-client": "^2.5.1",
    "apollo-cache-inmemory": "^1.5.1",
    "graphql-tag": "^2.10.1",
    "graphql": "^14.1.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.6",
    "@angular/cli": "~7.3.6",
    "@angular/compiler-cli": "^7.2.9",
    "@angular/language-service": "^7.2.9",
    "@types/jasmine": "~3.3.10",
    "@types/jasminewd2": "~2.0.6",
    "@types/node": "~11.11.3",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~3.3.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.5",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.2",
    "ts-node": "~8.0.3",
    "tsc-watch": "^2.1.2",
    "tslint": "~5.14.0",
    "typescript": "^3.3.3333"
  }
}

@qens
Copy link

qens commented Mar 18, 2019

Have the same issue.
I'm using angular 6.1.10 and typescript 2.9.0

@dutchsparks
Copy link
Author

dutchsparks commented Mar 18, 2019

I can't test it right now but downgrading apollo-utilities to 1.0.22 might work.
let me know how it goes if you give it a try.

@qens
Copy link

qens commented Mar 18, 2019

I can't test it right now but downgrading apollo-utilities to 1.0.22 might work.
let me know how it goes if you give it a try.

Yep, I added apollo-utilities@1.0.22 as a dependency and it works ( for someone who faced the same issue, don't forget to clear node_modules with previous apollo-utilities).
Thanks a lot!

@benjamn
Copy link
Member

benjamn commented Mar 18, 2019

Likely duplicate of #4506.

tl;dr If you can update the typescript package to at least 3.0, this error should go away, per #4501 (comment). Since the original poster seems to be using typescript@3.3.3333, I would ask that they double-check there are no other copies of the typescript package in use.

@benjamn
Copy link
Member

benjamn commented Mar 18, 2019

In case you think this must be an Apollo Client problem and not a TypeScript problem (or an Angular-and-TypeScript) problem, here's the only occurrence of a ...rest parameter in mergeDeep.ts:

export function mergeDeep<T extends any[]>(
  ...sources: T
): TupleToIntersection<T> {
  return mergeDeepArray(sources);
}

I would love to understand how T is not considered an array type here.

You can downgrade apollo-utilities if you like, but you might consider upgrading to a version of typescript that understands its own type system (if you're knowingly still using typescript@2), instead.

@amwill04
Copy link

amwill04 commented Mar 19, 2019

I get the warning even though the file mergeDeep.d.ts doesnt even exist in apollo-utilities.

@benjamn I assume any is far to broad for typescript to understand its an array. I had a similar issue here

@benjamn
Copy link
Member

benjamn commented Mar 20, 2019

But any[] is definitely an array, no?

@NateScarlet
Copy link

seems typescript not that smart

try use:

export function mergeDeep<T>(
  ...sources: T[]
): TupleToIntersection<T[]> {
  return mergeDeepArray(sources);
}

@awtrimpe
Copy link

@NateScarlet 's suggestion got me in the right place. I changed T to be an array for line 2.

export declare function mergeDeep<T extends any[]>(
  ...sources: T[]
): TupleToIntersection<T>;

@hwillson
Copy link
Member

As mentioned in #4594 (comment), this is not an Apollo Client issue. Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants