From ce7da790dc48385f8579ab484a5e231e8521dcb1 Mon Sep 17 00:00:00 2001 From: Ian Shipman Date: Tue, 5 Jan 2021 13:22:19 -0600 Subject: [PATCH 1/2] Changes approach to optional fields --- ChangeLog.md | 5 +++++ aeson-typescript.cabal | 2 +- src/Data/Aeson/TypeScript/Formatting.hs | 2 +- stack.yaml | 2 +- stack.yaml.lock | 8 ++++---- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 335a5a9..4acb20d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,8 @@ # Changelog for aeson-typescript ## Unreleased changes + +## 0.3.0.0 + +Represents optional fields (according to the Haskell model) as required fields +with type `A | null` rather than optional fields. diff --git a/aeson-typescript.cabal b/aeson-typescript.cabal index 347a5e0..98225ba 100644 --- a/aeson-typescript.cabal +++ b/aeson-typescript.cabal @@ -7,7 +7,7 @@ cabal-version: 1.12 -- hash: e1e74b37dded848299e515c32291f9f35f71998ce4f89f9a5622d634b197109d name: aeson-typescript -version: 0.2.0.0 +version: 0.3.0.0 synopsis: Generate TypeScript definition files from your ADTs description: Please see the README on Github at category: Text, Web, JSON diff --git a/src/Data/Aeson/TypeScript/Formatting.hs b/src/Data/Aeson/TypeScript/Formatting.hs index d824cd1..03a1bfe 100644 --- a/src/Data/Aeson/TypeScript/Formatting.hs +++ b/src/Data/Aeson/TypeScript/Formatting.hs @@ -28,7 +28,7 @@ formatTSDeclarations' :: FormattingOptions -> [TSDeclaration] -> String formatTSDeclarations' options declarations = T.unpack $ T.intercalate "\n\n" (fmap (T.pack . formatTSDeclaration options) declarations) formatTSField :: TSField -> String -formatTSField (TSField optional name typ) = [i|#{name}#{if optional then "?" else ""}: #{typ}|] +formatTSField (TSField optional name typ) = [i|#{name}: #{typ}#{if optional then "| null" else ""}|] getGenericBrackets :: [String] -> String getGenericBrackets [] = "" diff --git a/stack.yaml b/stack.yaml index fe66b24..10ac378 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,5 +1,5 @@ -resolver: lts-14.21 +resolver: lts-16.20 packages: - . diff --git a/stack.yaml.lock b/stack.yaml.lock index 7eef5f4..032c6e2 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -6,7 +6,7 @@ packages: [] snapshots: - completed: - size: 524162 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/21.yaml - sha256: 9a55dd75853718f2bbbe951872b36a3b7802fcd71796e0f25b8664f24e34c666 - original: lts-14.21 + size: 532177 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/20.yaml + sha256: 0e14ba5603f01e8496e8984fd84b545a012ca723f51a098c6c9d3694e404dc6d + original: lts-16.20 From 55f5cf347f60e89d987fdb343dcb019736b4f644 Mon Sep 17 00:00:00 2001 From: Matthew Wraith Date: Tue, 23 Mar 2021 20:28:29 -0500 Subject: [PATCH 2/2] Upgrade to GHC 8.10.4 --- aeson-typescript.cabal | 6 +++--- package.yaml | 4 ++-- stack.yaml | 2 +- stack.yaml.lock | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/aeson-typescript.cabal b/aeson-typescript.cabal index 98225ba..a38a152 100644 --- a/aeson-typescript.cabal +++ b/aeson-typescript.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: e1e74b37dded848299e515c32291f9f35f71998ce4f89f9a5622d634b197109d +-- hash: e778945cc6c2317863114819314907c928f41e6d6f6a7ccdb77b712d1dd356bf name: aeson-typescript version: 0.3.0.0 @@ -52,7 +52,7 @@ library , mtl , template-haskell , text - , th-abstraction <0.4 + , th-abstraction <0.5 , unordered-containers default-language: Haskell2010 @@ -99,6 +99,6 @@ test-suite aeson-typescript-test , template-haskell , temporary , text - , th-abstraction <0.4 + , th-abstraction <0.5 , unordered-containers default-language: Haskell2010 diff --git a/package.yaml b/package.yaml index 257ae88..5b2b36b 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: aeson-typescript -version: 0.2.0.0 +version: 0.3.0.0 github: "codedownio/aeson-typescript" license: BSD3 category: Text, Web, JSON @@ -33,7 +33,7 @@ dependencies: - mtl - template-haskell - text -- th-abstraction < 0.4 +- th-abstraction < 0.5 - unordered-containers library: diff --git a/stack.yaml b/stack.yaml index 10ac378..51dd2aa 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,5 +1,5 @@ -resolver: lts-16.20 +resolver: lts-17.7 packages: - . diff --git a/stack.yaml.lock b/stack.yaml.lock index 032c6e2..d4d1cc5 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -6,7 +6,7 @@ packages: [] snapshots: - completed: - size: 532177 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/20.yaml - sha256: 0e14ba5603f01e8496e8984fd84b545a012ca723f51a098c6c9d3694e404dc6d - original: lts-16.20 + size: 565715 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/17/7.yaml + sha256: 1b5e4124989399e60e7a7901f0cefd910beea546131fb07a13a7208c4cc8b7ee + original: lts-17.7