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

have to alway import ApolloQueryResult on every return this.apollo.query to make typescript happy #1667

Closed
hiepxanh opened this issue May 8, 2021 · 2 comments

Comments

@hiepxanh
Copy link

hiepxanh commented May 8, 2021

Describe the bug
i have warning on message: "The inferred type of 'getAllBooks' cannot be named without a reference to '.pnpm/@apollo+client@3.3.12_graphql@15.5.0/node_modules/@apollo/client/core'. This is likely not portable. A type annotation is necessary."

image

If I import the 'ApolloQueryResult' the typescript stop yelling. Can you take a look how to stop it?

image

To Reproduce
Steps to reproduce the behavior:
using pnpm install on windows, with nx workspace projecct.

Expected behavior
not error

Environment:

  • windows 10
  • pnpm 6.2.5
  • nodejs 16
+-- @angular/cli@11.2.5  -> G:\small-cosmos\awread\node_modules\.pnpm\@angular+cli@11.2.5\node_modules\@angular\cli
+-- @apollo/client@3.3.12  -> G:\small-cosmos\awread\node_modules\.pnpm\@apollo+client@3.3.12_graphql@15.5.0\node_modules\@apollo\client
+-- apollo-angular@2.4.0  -> G:\small-cosmos\awread\node_modules\.pnpm\apollo-angular@2.4.0_aa935e57683d4111bf0534c3304f0f43\node_modules\apollo-angular
+-- graphile-utils@4.11.2 -> G:\small-cosmos\awread\node_modules\.pnpm\graphile-utils@4.11.2\node_modules\graphile-utils
+-- graphql@15.5.0  -> G:\small-cosmos\awread\node_modules\.pnpm\graphql@15.5.0\node_modules\graphql
+-- postgraphile@4.11.0 -> G:\small-cosmos\awread\node_modules\.pnpm\postgraphile@4.11.0\node_modules\postgraphile
`-- typescript@4.1.5  -> G:\small-cosmos\awread\node_modules\.pnpm\typescript@4.1.5\node_modules\typescript

Additional context

p/s: have the workaround, #1667 (comment)

import this to tsconfig.json solve the problem

compilerOptions: {
  "baseUrl": ".",
    "paths": {
      "apollo-angular": [
        "node_modules/apollo-angular/"
      ],
      ....
      }
  }
@hiepxanh
Copy link
Author

hiepxanh commented May 8, 2021

@kamilkisiela I know you are very busy, but can you take a look?

@hiepxanh
Copy link
Author

hiepxanh commented May 8, 2021

pnpm/pnpm#3396 (comment)
microsoft/TypeScript#29808 (comment)

find the solution, look like I need to import path to make sure typescript understand this library. I hope that can help other people have the same solution

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants