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

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

Closed
namcancode opened this issue Jan 18, 2019 · 5 comments · Fixed by #4331
Closed

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

namcancode opened this issue Jan 18, 2019 · 5 comments · Fixed by #4331
Assignees

Comments

@namcancode
Copy link

namcancode commented Jan 18, 2019

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
Copy link

cmckni3 commented Jan 18, 2019

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

@namcancode
Copy link
Author

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
Copy link
Member

benjamn commented Jan 18, 2019

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 benjamn self-assigned this Jan 18, 2019
benjamn added a commit that referenced this issue Jan 18, 2019
Wow, I should have done this sooner. Super simple:
benjamn/optimism@03b3f88

Follow-up to #4158.
Should fix #4327.
benjamn added a commit that referenced this issue Jan 18, 2019
Since we've been struggling to declare correct types for the `optimism`
npm package (for example: #4158, #4327), I finally decided to move the
declarations into the `optimism` package itself: benjamn/optimism@03b3f88

Pretty easy! I wish I'd done this sooner.

Should fix #4327.
@benjamn
Copy link
Member

benjamn commented Jan 18, 2019

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.

@benjamn benjamn changed the title comilation error optimism.d.ts in apollo-cache-inmemory Missing types for 'optimism' npm package in apollo-cache-inmemory. Jan 18, 2019
@cmckni3
Copy link

cmckni3 commented Jan 18, 2019

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

@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

Successfully merging a pull request may close this issue.

3 participants