apollo-link-token-refresh icon indicating copy to clipboard operation
apollo-link-token-refresh copied to clipboard

Type Error with the new Apollo client

Open ImanAkrami opened this issue 3 years ago • 1 comments

Hi, thanks for your efforts. When i use the link in my client config, i get this eror:

Type 'TokenRefreshLink<string>' is not assignable to type 'ApolloLink | RequestHandler'.
  Type 'TokenRefreshLink<string>' is not assignable to type 'ApolloLink'.
    Types of property 'split' are incompatible.
      Type '(test: (op: import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/types").Operation) => boolean, left: import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | im...' is not assignable to type '(test: (op: import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/types").Operation) => boolean, left: import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core...'.
        Types of parameters 'left' and 'left' are incompatible.
          Type 'import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/types").RequestHandler' is not assignable to type 'import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/types").RequestHandler'.
            Type 'ApolloLink' is not assignable to type 'ApolloLink | RequestHandler'.
              Type 'import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink' is not assignable to type 'import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink'.
                Types of property 'split' are incompatible.
                  Type '(test: (op: import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/types").Operation) => boolean, left: import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core...' is not assignable to type '(test: (op: import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/types").Operation) => boolean, left: import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | im...'.
                    Types of parameters 'left' and 'left' are incompatible.
                      Type 'import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/types").RequestHandler' is not assignable to type 'import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/types").RequestHandler'.
                        Type 'ApolloLink' is not assignable to type 'ApolloLink | RequestHandler'.
                          Type 'import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink' is not assignable to type 'import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink'.
                            Types of property 'split' are incompatible.
                              Type '(test: (op: import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/types").Operation) => boolean, left: import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | im...' is not assignable to type '(test: (op: import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/types").Operation) => boolean, left: import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core...'.
                                Types of parameters 'right' and 'right' are incompatible.
                                  Type 'import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/home/shando/lernito-exam/frontend/node_modules/@apollo/client/link/core/types").RequestHandler | undefined' is not assignable to type 'import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/ApolloLink").ApolloLink | import("/home/shando/lernito-exam/frontend/node_modules/apollo-link-token-refresh/node_modules/@apollo/client/link/core/types").RequestHandler | undefined'.
                                    **Type 'ApolloLink' is not assignable to type 'ApolloLink | RequestHandler | undefined'.ts(2322)**

I literally copy pasted the example in in the docs

ImanAkrami avatar May 11 '21 20:05 ImanAkrami

I know this has been discussed elsewhere, but I spent time this morning while upgrading deps trying to find a solution to this too.

Instead of patching the line with an as any, I decided to stick on the version of @apollo/client that does not throw for us: "@apollo/client": "^3.3.8",

kevbost avatar May 12 '21 01:05 kevbost