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

@apollo/client^3.5.0 transpilation produces error TS2688: Cannot find type definition file for 'zen-observable'.` #9040

Closed
KeithGillette opened this issue Nov 10, 2021 · 6 comments

Comments

@KeithGillette
Copy link
Contributor

KeithGillette commented Nov 10, 2021

Intended outcome:
Updating from 3.4.17 to ^3.5.0 should work without error.

Actual outcome:
Building a project depending on @apollo/client@3.5.2 generates transpilation error TS2688: Cannot find type definition file for 'zen-observable'. when tsc is run with default skipLibCheck: false:

node_modules/@apollo/client/core/ApolloClient.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/core/ObservableQuery.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/core/QueryInfo.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/core/QueryInfo.d.ts:22:24 - error TS2503: Cannot find namespace 'ZenObservable'.

22     subscriptions: Set<ZenObservable.Subscription>;
                          ~~~~~~~~~~~~~

node_modules/@apollo/client/core/QueryManager.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/link/core/ApolloLink.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/link/core/types.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/link/error/index.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/link/retry/retryLink.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/link/utils/fromError.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/link/utils/fromPromise.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/link/utils/toPromise.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/link/ws/index.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/utilities/observables/asyncMap.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/utilities/observables/Concast.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

node_modules/@apollo/client/utilities/observables/subclassing.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />
                        ~~~~~~~~~~~~~~

How to reproduce the issue:
Run tsc on project including @apollo/client@3.5.2 with tsconfig.json leaving default skipLibCheck: false.

Versions

System:
  OS: macOS 12.0.1
Binaries:
  Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
  npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
Browsers:
  Chrome: 95.0.4638.69
  Firefox: 92.0.1
  Safari: 15.1
npmPackages:
  @apollo/client: 3.5.2 => 3.5.2 
  apollo-angular: 2.6.0 => 2.6.0 
  apollo-server-core: 3.5.0 => 3.5.0 
  apollo-server-express: 3.5.0 => 3.5.0 
@KeithGillette KeithGillette changed the title @apollo/client@3.5.2 transpilation produces error TS2688: Cannot find type definition file for 'zen-observable'.` @apollo/client^3.5.0 transpilation produces error TS2688: Cannot find type definition file for 'zen-observable'.` Nov 10, 2021
@brainkim brainkim self-assigned this Nov 11, 2021
@benjamn
Copy link
Member

benjamn commented Nov 16, 2021

@KeithGillette What version do you see in node_modules/@apollo/client/package.json? If @apollo/client was successfully updated to v3.5, there should no longer be any

/// <reference types="zen-observable" />

lines in the generated .d.ts files.

More background on why we decided to remove zen-observable and @types/zen-observable as dependencies: apollographql/zen-observable-ts#152

You might also need to run npm install by itself, to sort out the new dependencies?

@KeithGillette
Copy link
Contributor Author

Hi, @benjamnnode_modules/@apollo/client/package.json shows version 3.5.2 after an individual package upgrade npm install --save-exact @apollo/client@3.5.2, after a further npm install per your suggestion, and after another npm install following an rm -rf node_modules just to be safe. In all cases, I still receive the same output on project transpilation as originally reported.

{
  "_from": "@apollo/client@3.5.2",
  "_id": "@apollo/client@3.5.2",
  "_inBundle": false,
  "_integrity": "sha512-STC7ZQthcOGU+MXRIzcb3s1ULW9QQFEhXFEIUaK3Jdwy0RxncxYkg2LpwxXV0FqlYUjKEW92f+NUIZ2FhpKGug==",
  "_location": "/@apollo/client",
  "_phantomChildren": {},
  "_requested": {
    "type": "version",
    "registry": true,
    "raw": "@apollo/client@3.5.2",
    "name": "@apollo/client",
    "escapedName": "@apollo%2fclient",
    "scope": "@apollo",
    "rawSpec": "3.5.2",
    "saveSpec": null,
    "fetchSpec": "3.5.2"
  },
  "_requiredBy": [
    "#USER",
    "/"
  ],
  "_resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.5.2.tgz",
  "_shasum": "f0a4d8cb42f045e0527f081da9bb21c4fb53aeaf",
  "_spec": "@apollo/client@3.5.2",
  "_where": "/Users/keith.gillette/Code/TaskTrain",
  "author": {
    "name": "packages@apollographql.com"
  },
  "bugs": {
    "url": "https://github.com/apollographql/apollo-client/issues"
  },
  "bundleDependencies": false,
  "dependencies": {
    "@graphql-typed-document-node/core": "^3.0.0",
    "@wry/context": "^0.6.0",
    "@wry/equality": "^0.5.0",
    "@wry/trie": "^0.3.0",
    "graphql-tag": "^2.12.3",
    "hoist-non-react-statics": "^3.3.2",
    "optimism": "^0.16.1",
    "prop-types": "^15.7.2",
    "symbol-observable": "^4.0.0",
    "ts-invariant": "^0.9.0",
    "tslib": "^2.3.0",
    "zen-observable-ts": "^1.2.0"
  },
  "deprecated": false,
  "description": "A fully-featured caching GraphQL client.",
  "devDependencies": {
    "@babel/parser": "7.16.2",
    "@graphql-tools/schema": "8.3.1",
    "@rollup/plugin-node-resolve": "11.2.1",
    "@testing-library/react": "9.5.0",
    "@testing-library/react-hooks": "7.0.2",
    "@types/fast-json-stable-stringify": "2.0.0",
    "@types/fetch-mock": "7.3.5",
    "@types/glob": "7.2.0",
    "@types/hoist-non-react-statics": "3.3.1",
    "@types/jest": "27.0.2",
    "@types/lodash": "4.14.176",
    "@types/node": "16.11.6",
    "@types/react": "17.0.34",
    "@types/react-dom": "17.0.2",
    "bundlesize": "0.18.1",
    "cross-fetch": "3.1.4",
    "crypto-hash": "1.3.0",
    "fetch-mock": "9.11.0",
    "glob": "7.2.0",
    "graphql": "^16.0.0",
    "jest": "27.3.1",
    "jest-fetch-mock": "3.0.3",
    "jest-junit": "13.0.0",
    "lodash": "4.17.21",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "recast": "0.20.5",
    "resolve": "1.20.0",
    "rimraf": "3.0.2",
    "rollup": "2.50.5",
    "rollup-plugin-terser": "7.0.2",
    "rxjs": "6.6.7",
    "subscriptions-transport-ws": "0.11.0",
    "terser": "5.9.0",
    "ts-jest": "27.0.7",
    "ts-node": "10.4.0",
    "typescript": "4.4.4",
    "wait-for-observables": "1.0.3",
    "whatwg-fetch": "3.6.2"
  },
  "homepage": "https://www.apollographql.com/docs/react/",
  "keywords": [
    "apollo",
    "graphql",
    "react",
    "hooks",
    "client",
    "cache"
  ],
  "license": "MIT",
  "main": "./main.cjs",
  "module": "./index.js",
  "name": "@apollo/client",
  "peerDependencies": {
    "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
    "react": "^16.8.0 || ^17.0.0",
    "subscriptions-transport-ws": "^0.9.0 || ^0.11.0"
  },
  "peerDependenciesMeta": {
    "react": {
      "optional": true
    },
    "subscriptions-transport-ws": {
      "optional": true
    }
  },
  "private": false,
  "publishConfig": {
    "access": "public"
  },
  "react-native": {
    "./dist/cache/inmemory/fixPolyfills.js": "./cache/inmemory/fixPolyfills.native.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/apollographql/apollo-client.git"
  },
  "sideEffects": false,
  "type": "module",
  "types": "./index.d.ts",
  "version": "3.5.2"
}

@brainkim brainkim assigned benjamn and unassigned brainkim Nov 16, 2021
@benjamn
Copy link
Member

benjamn commented Nov 17, 2021

@KeithGillette Thanks for double checking!

While I'm confident @apollo/client@3.5.3 (just published by me) will resolve this issue, I'm less sure about the explanation. I tried reverting the changes in #9073 and rebuilding (and then also rebuilding from v3.5.2), and neither rebuild brought back the <reference types="zen-observable" /> declarations (good, but strange they got published).

Since different people published v3.5.2 and v3.5.0-v3.5.2, it's possible we (@hwillson @brainkim and I) need to align our publishing workflows better. Good to know.

@benjamn benjamn added this to the v3.5.x patch releases milestone Nov 17, 2021
@KeithGillette
Copy link
Contributor Author

Thanks, @benjamn. I confirm that release 3.5.3 resolves this typings issue.

You know that none of the 3.5 releases are published on NPMJS, right? 3.4.17 is still listed as the latest version in the registry.

@brainkim
Copy link
Contributor

@KeithGillette Yep, we’re doing some additional checks live because no one would download the beta 😢 should be set to latest soon.

@MaRuifeng
Copy link

Has this issue been resolved indeed? I am getting below error message. I know it's reflected in a different library package
apollo-link-timeout, but downgrading "@apollo/client" from 3.6.1 to 3.3.6 fixed the issue. After downgrading I was able to see package @types/zen-observable being installed properly.

node_modules/apollo-link-timeout/lib/timeoutLink.d.ts:1:23 - error TS2688: Cannot find type definition file for 'zen-observable'.

1 /// <reference types="zen-observable" />

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

No branches or pull requests

5 participants