@@ -29,7 +29,9 @@ data TwoField = TwoField { doubleInt :: Int, doubleString :: String }
2929data Hybrid = HybridSimple Int | HybridRecord { hybridString :: String }
3030data TwoConstructor = Con1 { con1String :: String } | Con2 { con2String :: String , con2Int :: Int }
3131data Complex a = Nullary | Unary Int | Product String Char a | Record { testOne :: Int , testTwo :: Bool , testThree :: Complex a } deriving Eq
32- data Optional = Optional { optionalInt :: Maybe Int }
32+ data OptionalRecord = OptionalRecord { optionalInt :: Maybe Int }
33+ data OptionalTuple1 = OptionalTuple1 (Maybe Int )
34+ data OptionalTuple2 = OptionalTuple2 String (Maybe Int )
3335data AesonTypes = AesonTypes { aesonValue :: A. Value , aesonObject :: A. Object }
3436data Numbers = Numbers {
3537 natural :: Natural
@@ -87,7 +89,9 @@ testDeclarations testName aesonOptions = do
8789 deriveInstances ''Hybrid
8890 deriveInstances ''TwoConstructor
8991 deriveInstances ''Complex
90- deriveInstances ''Optional
92+ deriveInstances ''OptionalRecord
93+ deriveInstances ''OptionalTuple1
94+ deriveInstances ''OptionalTuple2
9195 deriveInstances ''AesonTypes
9296 deriveInstances ''Numbers
9397 deriveInstances ''FancyFunctors
@@ -113,8 +117,14 @@ testDeclarations testName aesonOptions = do
113117 , (getTypeScriptType (Proxy :: Proxy (Complex Int)), A.encode (Product "asdf" 'g' 42 :: Complex Int))
114118 , (getTypeScriptType (Proxy :: Proxy (Complex Int)), A.encode ((Record { testOne = 3, testTwo = True, testThree = Product "test" 'A' 123}) :: Complex Int))
115119
116- , (getTypeScriptType (Proxy :: Proxy Optional), A.encode (Optional { optionalInt = Nothing }))
117- , (getTypeScriptType (Proxy :: Proxy Optional), A.encode (Optional { optionalInt = Just 1 }))
120+ , (getTypeScriptType (Proxy :: Proxy OptionalRecord), A.encode (OptionalRecord { optionalInt = Nothing }))
121+ , (getTypeScriptType (Proxy :: Proxy OptionalRecord), A.encode (OptionalRecord { optionalInt = Just 1 }))
122+
123+ , (getTypeScriptType (Proxy :: Proxy OptionalTuple1), A.encode (OptionalTuple1 Nothing))
124+ , (getTypeScriptType (Proxy :: Proxy OptionalTuple1), A.encode (OptionalTuple1 (Just 1)))
125+
126+ , (getTypeScriptType (Proxy :: Proxy OptionalTuple2), A.encode (OptionalTuple2 "asdf" Nothing))
127+ , (getTypeScriptType (Proxy :: Proxy OptionalTuple2), A.encode (OptionalTuple2 "asdf" (Just 1)))
118128
119129 , (getTypeScriptType (Proxy :: Proxy AesonTypes), A.encode (AesonTypes {
120130 aesonValue = A.object [("foo" :: AesonKey, A.Number 42)]
@@ -133,7 +143,9 @@ testDeclarations testName aesonOptions = do
133143 <> getTypeScriptDeclarations (Proxy :: Proxy Hybrid)
134144 <> getTypeScriptDeclarations (Proxy :: Proxy TwoConstructor)
135145 <> getTypeScriptDeclarations (Proxy :: Proxy (Complex T))
136- <> getTypeScriptDeclarations (Proxy :: Proxy Optional)
146+ <> getTypeScriptDeclarations (Proxy :: Proxy OptionalRecord)
147+ <> getTypeScriptDeclarations (Proxy :: Proxy OptionalTuple1)
148+ <> getTypeScriptDeclarations (Proxy :: Proxy OptionalTuple2)
137149 <> getTypeScriptDeclarations (Proxy :: Proxy AesonTypes)
138150 <> getTypeScriptDeclarations (Proxy :: Proxy Numbers)
139151 <> getTypeScriptDeclarations (Proxy :: Proxy FancyFunctors)
0 commit comments