From 700293bc39eea8de96f0aeeadd6611a7726419f5 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Thu, 27 Jul 2023 04:37:31 -0700 Subject: [PATCH] Remove question mark in instances for Map and HashMap --- src/Data/Aeson/TypeScript/Instances.hs | 4 ++-- test/Generic.hs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Data/Aeson/TypeScript/Instances.hs b/src/Data/Aeson/TypeScript/Instances.hs index 97de51c..a7c44a5 100644 --- a/src/Data/Aeson/TypeScript/Instances.hs +++ b/src/Data/Aeson/TypeScript/Instances.hs @@ -172,11 +172,11 @@ instance TypeScript A.Value where getTypeScriptType _ = "any"; instance (TypeScript a, TypeScript b) => TypeScript (Map a b) where - getTypeScriptType _ = "{[k in " ++ getTypeScriptKeyType (Proxy :: Proxy a) ++ "]?: " ++ getTypeScriptType (Proxy :: Proxy b) ++ "}" + getTypeScriptType _ = "{[k in " ++ getTypeScriptKeyType (Proxy :: Proxy a) ++ "]: " ++ getTypeScriptType (Proxy :: Proxy b) ++ "}" getParentTypes _ = [TSType (Proxy :: Proxy a), TSType (Proxy :: Proxy b)] instance (TypeScript a, TypeScript b) => TypeScript (HashMap a b) where - getTypeScriptType _ = [i|{[k in #{getTypeScriptKeyType (Proxy :: Proxy a)}]?: #{getTypeScriptType (Proxy :: Proxy b)}}|] + getTypeScriptType _ = [i|{[k in #{getTypeScriptKeyType (Proxy :: Proxy a)}]: #{getTypeScriptType (Proxy :: Proxy b)}}|] getParentTypes _ = L.nub [TSType (Proxy :: Proxy a), TSType (Proxy :: Proxy b)] #if MIN_VERSION_aeson(2,0,0) diff --git a/test/Generic.hs b/test/Generic.hs index 68f92fb..ea6d05b 100644 --- a/test/Generic.hs +++ b/test/Generic.hs @@ -53,7 +53,7 @@ tests = describe "Generic instances" $ do it [i|Complex4 makes the declaration and types correctly|] $ do (getTypeScriptDeclarationsRecursively (Proxy :: Proxy (Complex4 String))) `shouldBe` [ - TSInterfaceDeclaration "IProduct4" ["T"] [TSField False "record4" "{[k in string]?: T}" Nothing] Nothing + TSInterfaceDeclaration "IProduct4" ["T"] [TSField False "record4" "{[k in string]: T}" Nothing] Nothing ,TSTypeAlternatives "Complex4" ["T"] ["IProduct4"] Nothing ]