Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Typescript --strictFunctionTypes parameter incompatibility #64

Open
stephentuso opened this issue Feb 28, 2018 · 0 comments
Open

Typescript --strictFunctionTypes parameter incompatibility #64

stephentuso opened this issue Feb 28, 2018 · 0 comments

Comments

@stephentuso
Copy link

stephentuso commented Feb 28, 2018

Edit: This only happens with strictFunctionTypes. Seems like it would be good to support that

Using binding-ts, I'm getting some errors in the generated ts file:

generated/starchive-api.ts(28,3): error TS2416: Property 'query' in type 'Binding' is not assignable to the same property in base type 'Binding<QueryMap, SubscriptionMap>'.
  Type 'Query' is not assignable to type 'QueryMap'.
    Property 'helloWorld' is incompatible with index signature.
      Type '(args: {}, context: { [key: string]: any; }, info?: string | GraphQLResolveInfo | undefined) => P...' is not assignable to type '(args?: { [key: string]: any; } | undefined, context?: { [key: string]: any; } | undefined, info?...'.
        Types of parameters 'args' and 'args' are incompatible.
          Type '{ [key: string]: any; } | undefined' is not assignable to type '{}'.
            Type 'undefined' is not assignable to type '{}'.

Am I missing something? All the parameters in QueryMap are optional so shouldn't the generated

export type Query = {
  helloWorld: (args: {}, context: { [key: string]: any }, info?: GraphQLResolveInfo | string) => Promise<String | null>
}

actually be this?

export type Query = {
  helloWorld: (args?: {}, context?: { [key: string]: any }, info?: GraphQLResolveInfo | string) => Promise<String | null>
}

However, making that change causes another issue because Binding#delegate doesn't have optional parameters either

@stephentuso stephentuso changed the title Typescript parameter incompatibility Typescript --strictFunctionTypes parameter incompatibility Mar 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant