aeson-typescript 0.4.0.0 → 0.4.1.0
raw patch · 3 files changed
+29/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- aeson-typescript.cabal +2/−2
- src/Data/Aeson/TypeScript/Instances.hs +22/−1
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Change log +## 0.4.1.0++* Add TypeScript Int16+* Add TypeScript (A.KeyMap a) instance for aeson 2+ ## 0.4.0.0 * Add new built-in instances (Word8, Int32, Int64, Map, HashSet)
aeson-typescript.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.35.0. -- -- see: https://github.com/sol/hpack name: aeson-typescript-version: 0.4.0.0+version: 0.4.1.0 synopsis: Generate TypeScript definition files from your ADTs description: Please see the README on Github at <https://github.com/codedownio/aeson-typescript#readme> category: Text, Web, JSON
src/Data/Aeson/TypeScript/Instances.hs view
@@ -1,4 +1,12 @@-{-# LANGUAGE QuasiQuotes, OverloadedStrings, TemplateHaskell, RecordWildCards, ScopedTypeVariables, ExistentialQuantification, FlexibleInstances, OverlappingInstances, CPP #-}+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE OverlappingInstances #-}+{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- Note: the OverlappingInstances pragma is only here so the overlapping instances in this file@@ -25,7 +33,11 @@ import Data.Monoid #endif +#if MIN_VERSION_aeson(2,0,0)+import qualified Data.Aeson.KeyMap as A+#endif + instance TypeScript () where getTypeScriptType _ = "void" @@ -53,6 +65,9 @@ instance TypeScript Int where getTypeScriptType _ = "number" +instance TypeScript Int16 where+ getTypeScriptType _ = "number"+ instance TypeScript Int32 where getTypeScriptType _ = "number" @@ -118,6 +133,12 @@ instance (TypeScript a, TypeScript b) => TypeScript (HashMap a b) where 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)+instance (TypeScript a) => TypeScript (A.KeyMap a) where+ getTypeScriptType _ = [i|{[k]?: #{getTypeScriptType (Proxy :: Proxy a)}}|]+ getParentTypes _ = L.nub [TSType (Proxy :: Proxy a)]+#endif instance (TypeScript a) => TypeScript (Set a) where getTypeScriptType _ = getTypeScriptType (Proxy :: Proxy a) <> "[]";