TypeScript complains about subscriptionForwarder type
See original GitHub issueWhen 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:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for the example, it helped identify the issue which also lead to finding a bug.
Will tag a release shortly.
Update : this seems to be caused by
typed-document-node
as the error doesn’t show up when using vanilla queries.