apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.34k stars 2.65k forks source link

Missing types for 'optimism' npm package in apollo-cache-inmemory. #4327

Closed namcancode closed 5 years ago

namcancode commented 5 years ago

i have issue run dev with apollo-cache-inmemory version: "apollo-cache-inmemory": "^1.4.0"

image Im using Vue js with typescripts file tsconfig.json

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "node"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}

file package.json

{
  "name": "test",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "dev": "vue-cli-service serve",
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "@sentry/browser": "^4.0.6",
    "apollo-cache-inmemory": "^1.4.0",
    "apollo-client": "^2.4.9",
    "apollo-link-error": "^1.1.5",
    "apollo-link-http": "^1.5.9",
    "axios": "^0.18.0",
    "bootstrap": "^4.1.3",
    "chartist": "^0.11.0",
    "chartist-plugin-zoom": "hansmaad/chartist-plugin-zoom",
    "date-fns": "^2.0.0-alpha.27",
    "element-ui": "^2.4.6",
    "es6-promise": "^4.2.4",
    "jsonwebtoken": "^8.4.0",
    "lockr": "^0.8.5",
    "lodash": "^4.17.10",
    "vue": "^2.5.17",
    "vue-apollo": "^3.0.0-beta.27",
    "vue-class-component": "^6.0.0",
    "vue-clickaway": "^2.2.2",
    "vue-i18n": "^8.1.0",
    "vue-property-decorator": "^7.0.0",
    "vue-router": "^3.0.1",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@types/axios": "^0.14.0",
    "@types/bootstrap": "^4.1.2",
    "@types/chartist": "^0.9.42",
    "@types/date-fns": "^2.6.0",
    "@types/es6-promise": "^3.3.0",
    "@types/graphql": "^14.0.3",
    "@types/jsonwebtoken": "^8.3.0",
    "@types/lodash": "^4.14.116",
    "@types/node": "^10.11.3",
    "@types/vue-i18n": "^7.0.0",
    "@vue/cli-plugin-babel": "^3.0.1",
    "@vue/cli-plugin-typescript": "^3.0.1",
    "@vue/cli-service": "^3.0.1",
    "node-sass": "^4.9.0",
    "sass-loader": "^7.0.1",
    "ts-node": "^7.0.1",
    "tsconfig-paths": "^3.7.0",
    "typescript": "^3.0.3",
    "vue-auto-routing": "^0.2.0",
    "vue-cli-plugin-apollo": "^0.18.1",
    "vue-cli-plugin-auto-routing": "^0.1.2",
    "vue-template-compiler": "^2.5.17"
  }
}
cmckni3 commented 5 years ago

Same issue here in React. I downgraded and locked apollo-boost to 0.1.23 and apollo-cache-inmemory to ~1.3.0.

namcancode commented 5 years ago

Same issue here in React. I downgraded and locked apollo-boost to 0.1.23 and apollo-cache-inmemory to ~1.3.0.

install ver 1.3.12 and i dont have any issue

benjamn commented 5 years ago

The TypeScript compiler is apparently not picking up the apollo-cache-inmemory/src/declarations.d.ts file that was introduced in PR #4158, which has the following contents:

declare module 'optimism' {
  export function wrap<T>(
    originalFunction: T,
    options?: OptimisticWrapOptions,
  ): OptimisticWrapperFunction<T>;
}

I'll look into it.

benjamn commented 5 years ago

Please try npm install apollo-cache-inmemory@1.4.1, and feel free to comment here with your results, or reopen this issue if you still have the same problem.

cmckni3 commented 5 years ago

Thanks for the quick response @benjamn! It works now.