@@ -579,23 +579,27 @@ export interface GraphQLScalarTypeExtensions {
579579 * });
580580 * ```
581581 */
582- export class GraphQLScalarType {
582+ export class GraphQLScalarType < TInternal = unknown , TExternal = TInternal > {
583583 name : string ;
584584 description : Maybe < string > ;
585585 specifiedByURL : Maybe < string > ;
586- serialize : GraphQLScalarSerializer < unknown > ;
587- parseValue : GraphQLScalarValueParser < unknown > ;
588- parseLiteral : GraphQLScalarLiteralParser < unknown > ;
586+ serialize : GraphQLScalarSerializer < TExternal > ;
587+ parseValue : GraphQLScalarValueParser < TInternal > ;
588+ parseLiteral : GraphQLScalarLiteralParser < TInternal > ;
589589 extensions : Maybe < Readonly < GraphQLScalarTypeExtensions > > ;
590590 astNode : Maybe < ScalarTypeDefinitionNode > ;
591591 extensionASTNodes : ReadonlyArray < ScalarTypeExtensionNode > ;
592592
593- constructor ( config : Readonly < GraphQLScalarTypeConfig < unknown , unknown > > ) {
594- const parseValue = config . parseValue ?? identityFunc ;
593+ constructor ( config : Readonly < GraphQLScalarTypeConfig < TInternal , TExternal > > ) {
594+ const parseValue =
595+ config . parseValue ??
596+ ( identityFunc as GraphQLScalarValueParser < TInternal > ) ;
597+
595598 this . name = config . name ;
596599 this . description = config . description ;
597600 this . specifiedByURL = config . specifiedByURL ;
598- this . serialize = config . serialize ?? identityFunc ;
601+ this . serialize =
602+ config . serialize ?? ( identityFunc as GraphQLScalarSerializer < TExternal > ) ;
599603 this . parseValue = parseValue ;
600604 this . parseLiteral =
601605 config . parseLiteral ??
@@ -627,7 +631,7 @@ export class GraphQLScalarType {
627631 }
628632 }
629633
630- toConfig ( ) : GraphQLScalarTypeNormalizedConfig {
634+ toConfig ( ) : GraphQLScalarTypeNormalizedConfig < TInternal , TExternal > {
631635 return {
632636 name : this . name ,
633637 description : this . description ,
@@ -656,16 +660,16 @@ export class GraphQLScalarType {
656660
657661export type GraphQLScalarSerializer < TExternal > = (
658662 outputValue : unknown ,
659- ) => Maybe < TExternal > ;
663+ ) => TExternal ;
660664
661665export type GraphQLScalarValueParser < TInternal > = (
662666 inputValue : unknown ,
663- ) => Maybe < TInternal > ;
667+ ) => TInternal ;
664668
665669export type GraphQLScalarLiteralParser < TInternal > = (
666670 valueNode : ValueNode ,
667671 variables ?: Maybe < ObjMap < unknown > > ,
668- ) => Maybe < TInternal > ;
672+ ) => TInternal ;
669673
670674export interface GraphQLScalarTypeConfig < TInternal , TExternal > {
671675 name : string ;
@@ -682,11 +686,11 @@ export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
682686 extensionASTNodes ?: Maybe < ReadonlyArray < ScalarTypeExtensionNode > > ;
683687}
684688
685- interface GraphQLScalarTypeNormalizedConfig
686- extends GraphQLScalarTypeConfig < unknown , unknown > {
687- serialize : GraphQLScalarSerializer < unknown > ;
688- parseValue : GraphQLScalarValueParser < unknown > ;
689- parseLiteral : GraphQLScalarLiteralParser < unknown > ;
689+ interface GraphQLScalarTypeNormalizedConfig < TInternal , TExternal >
690+ extends GraphQLScalarTypeConfig < TInternal , TExternal > {
691+ serialize : GraphQLScalarSerializer < TExternal > ;
692+ parseValue : GraphQLScalarValueParser < TInternal > ;
693+ parseLiteral : GraphQLScalarLiteralParser < TInternal > ;
690694 extensions : Maybe < Readonly < GraphQLScalarTypeExtensions > > ;
691695 extensionASTNodes : ReadonlyArray < ScalarTypeExtensionNode > ;
692696}
0 commit comments