question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript complains about subscriptionForwarder type

See original GitHub issue

When configuring subscriptions like the documentation suggests, TS complains with the following error:

Type 'Observable<ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>>' is not assignable to type 'ObservableLike<OperationResult<any>>'.
  Types of property 'subscribe' are incompatible.
    Type '(observer: Observer<ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>>) => { unsubscribe: () => void; }' is not assignable to type '(observer: ObserverLike<OperationResult<any>>) => Unsub'.
      Types of parameters 'observer' and 'observer' are incompatible.
        Type 'ObserverLike<OperationResult<any>>' is not assignable to type 'Observer<ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>>'.
          Types of property 'next' are incompatible.
            Type '(value: OperationResult<any>) => void' is not assignable to type '(value: ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>) => void'.
              Types of parameters 'value' and 'value' are incompatible.
                Property 'error' is missing in type 'ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>' but required in type 'OperationResult<any>'.

What I’m doing is the following:

import { createClient, handleSubscriptions, defaultPlugins } from "villus";
import { SubscriptionClient } from "subscriptions-transport-ws";

const subscriptionClient = new SubscriptionClient("ws://localhost:4000/api/graphql", { reconnect: true });

export const villus = createClient({
  url: "/api/graphql",
  use: [handleSubscriptions((operation) => subscriptionClient.request(operation)), ...defaultPlugins()],
});

Any idea what I’m doing wrong ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
logaretmcommented, Jan 20, 2021

Thank you for the example, it helped identify the issue which also lead to finding a bug.

Will tag a release shortly.

0reactions
lewebsimplecommented, Feb 14, 2021

Update : this seems to be caused by typed-document-node as the error doesn’t show up when using vanilla queries.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript 4.5
TypeScript 4.5 introduces a way to override a specific built-in lib in a manner similar to how @types/ support works. When deciding which...
Read more >
Distinguish missing and undefined · Issue #13195 - GitHub
Another example where TypeScript's inability to distinguish missing from undefined leads to inconsistencies between the types and JavaScript's ...
Read more >
Using Moment with Angular and TypeScript - Stack Overflow
My sample app runs in the browser, but the TypeScript compiler complains that it can't find Moment: app/controller.ts(3,20): error TS2503: Cannot find namespace ......
Read more >
Content Types - ESBuild
There are some broken implementations of ECMAScript modules out there (e.g. the TypeScript compiler) that don't follow the JavaScript specification in this ...
Read more >
The Definitive TypeScript Handbook - freeCodeCamp
The compiler might help you providing autocomplete for properties of Person but it will not complain if you miss any properties. Type Inference....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found