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.
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!
Closing since it's tracked in #2188 and championed by @mike-marcacci
Most helpful comment
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!