@@ -579,23 +579,27 @@ export interface GraphQLScalarTypeExtensions {
579
579
* });
580
580
* ```
581
581
*/
582
- export class GraphQLScalarType {
582
+ export class GraphQLScalarType < TInternal = unknown , TExternal = TInternal > {
583
583
name : string ;
584
584
description : Maybe < string > ;
585
585
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 > ;
589
589
extensions : Maybe < Readonly < GraphQLScalarTypeExtensions > > ;
590
590
astNode : Maybe < ScalarTypeDefinitionNode > ;
591
591
extensionASTNodes : ReadonlyArray < ScalarTypeExtensionNode > ;
592
592
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
+
595
598
this . name = config . name ;
596
599
this . description = config . description ;
597
600
this . specifiedByURL = config . specifiedByURL ;
598
- this . serialize = config . serialize ?? identityFunc ;
601
+ this . serialize =
602
+ config . serialize ?? ( identityFunc as GraphQLScalarSerializer < TExternal > ) ;
599
603
this . parseValue = parseValue ;
600
604
this . parseLiteral =
601
605
config . parseLiteral ??
@@ -627,7 +631,7 @@ export class GraphQLScalarType {
627
631
}
628
632
}
629
633
630
- toConfig ( ) : GraphQLScalarTypeNormalizedConfig {
634
+ toConfig ( ) : GraphQLScalarTypeNormalizedConfig < TInternal , TExternal > {
631
635
return {
632
636
name : this . name ,
633
637
description : this . description ,
@@ -656,16 +660,16 @@ export class GraphQLScalarType {
656
660
657
661
export type GraphQLScalarSerializer < TExternal > = (
658
662
outputValue : unknown ,
659
- ) => Maybe < TExternal > ;
663
+ ) => TExternal ;
660
664
661
665
export type GraphQLScalarValueParser < TInternal > = (
662
666
inputValue : unknown ,
663
- ) => Maybe < TInternal > ;
667
+ ) => TInternal ;
664
668
665
669
export type GraphQLScalarLiteralParser < TInternal > = (
666
670
valueNode : ValueNode ,
667
671
variables ?: Maybe < ObjMap < unknown > > ,
668
- ) => Maybe < TInternal > ;
672
+ ) => TInternal ;
669
673
670
674
export interface GraphQLScalarTypeConfig < TInternal , TExternal > {
671
675
name : string ;
@@ -682,11 +686,11 @@ export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
682
686
extensionASTNodes ?: Maybe < ReadonlyArray < ScalarTypeExtensionNode > > ;
683
687
}
684
688
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 > ;
690
694
extensions : Maybe < Readonly < GraphQLScalarTypeExtensions > > ;
691
695
extensionASTNodes : ReadonlyArray < ScalarTypeExtensionNode > ;
692
696
}
0 commit comments