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

GraphQLScalarType TypeScript typings #2489

Closed
twavv opened this issue Mar 12, 2020 · 2 comments
Closed

GraphQLScalarType TypeScript typings #2489

twavv opened this issue Mar 12, 2020 · 2 comments

Comments

@twavv
Copy link

twavv commented Mar 12, 2020

export class GraphQLScalarType {

Can I use the word type enough in a single issue?

I might be missing something, but it seems to me this should be typed using generics instead of littering the definition with any.

export class GraphQLScalarType<TInternal = any, TExternal = any> {
  name: string;
  description: Maybe<string>;
  serialize: GraphQLScalarSerializer<TExternal>;
  parseValue: GraphQLScalarValueParser<TInternal>;
  parseLiteral: GraphQLScalarLiteralParser<TInternal>;
  extensions: Maybe<Readonly<Record<string, any>>>;
  astNode: Maybe<ScalarTypeDefinitionNode>;
  extensionASTNodes: Maybe<ReadonlyArray<ScalarTypeExtensionNode>>;
  constructor(config: GraphQLScalarTypeConfig<TInternal, TExternal>);

  toConfig(): GraphQLScalarTypeConfig<TInternal, TExternal> & {
    serialize: GraphQLScalarSerializer<TExternal>;
    parseValue: GraphQLScalarValueParser<TInternal>;
    parseLiteral: GraphQLScalarLiteralParser<TInternal>;
    extensions: Maybe<Readonly<Record<string, any>>>;
    extensionASTNodes: ReadonlyArray<ScalarTypeExtensionNode>;
  };

  toString(): string;
  toJSON(): string;
  inspect(): string;
}

This does have the capacity to break things in a backward-incompatible way, but it would only really break things in a way that would reveal type un-soundness.

@mike-marcacci
Copy link
Contributor

mike-marcacci commented Mar 12, 2020

Hi @travigd, I have a whole initiative to bring strict types to this library. Check out #2188 which tracks this and a whole host of more robust type changes. The current goal was to release v15, and then start on this major work for v16. The timelines have shifted considerably, but this is still my plan: once 15 is out I'll begin work on this!

@IvanGoncharov
Copy link
Member

IvanGoncharov commented Mar 13, 2020

Closing since it's tracked in #2188 and championed by @mike-marcacci

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

3 participants