Skip to content

Commit cd8e46a

Browse files
committed
include immediate parents for containers...
...and exclude grandparents. The immediate parents are needed to make sure that we don't miss them when computing closures. The grandparents are not needed -- we'll get them through the immediate parents.
1 parent 8f23f6b commit cd8e46a

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

src/Data/Aeson/TypeScript/Instances.hs

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ instance TypeScript Char where
4545

4646
instance {-# OVERLAPPABLE #-} (TypeScript a) => TypeScript [a] where
4747
getTypeScriptType _ = (getTypeScriptType (Proxy :: Proxy a)) ++ "[]"
48-
getParentTypes _ = (TSType (Proxy :: Proxy a)) : (getParentTypes (Proxy :: Proxy a))
48+
getParentTypes _ = [TSType (Proxy :: Proxy a)]
4949

5050
instance {-# OVERLAPPING #-} TypeScript [Char] where
5151
getTypeScriptType _ = "string"
@@ -56,37 +56,30 @@ instance (TypeScript a, TypeScript b) => TypeScript (Either a b) where
5656
, TSInterfaceDeclaration "Left" ["T"] [TSField False "Left" "T"]
5757
, TSInterfaceDeclaration "Right" ["T"] [TSField False "Right" "T"]
5858
]
59-
getParentTypes _ = L.nub ((TSType (Proxy :: Proxy a))
60-
: (TSType (Proxy :: Proxy b))
61-
: (getParentTypes (Proxy :: Proxy a))
62-
<> (getParentTypes (Proxy :: Proxy b)))
59+
getParentTypes _ = L.nub [ (TSType (Proxy :: Proxy a))
60+
, (TSType (Proxy :: Proxy b))
61+
]
6362

6463
instance (TypeScript a, TypeScript b) => TypeScript (a, b) where
6564
getTypeScriptType _ = [i|[#{getTypeScriptType (Proxy :: Proxy a)}, #{getTypeScriptType (Proxy :: Proxy b)}]|]
66-
getParentTypes _ = L.nub ((TSType (Proxy :: Proxy a))
67-
: (TSType (Proxy :: Proxy b))
68-
: (getParentTypes (Proxy :: Proxy a))
69-
<> (getParentTypes (Proxy :: Proxy b)))
65+
getParentTypes _ = L.nub [ (TSType (Proxy :: Proxy a))
66+
, (TSType (Proxy :: Proxy b))
67+
]
7068

7169
instance (TypeScript a, TypeScript b, TypeScript c) => TypeScript (a, b, c) where
7270
getTypeScriptType _ = [i|[#{getTypeScriptType (Proxy :: Proxy a)}, #{getTypeScriptType (Proxy :: Proxy b)}, #{getTypeScriptType (Proxy :: Proxy c)}]|]
73-
getParentTypes _ = L.nub ((TSType (Proxy :: Proxy a))
74-
: (TSType (Proxy :: Proxy b))
75-
: (TSType (Proxy :: Proxy c))
76-
: (getParentTypes (Proxy :: Proxy a))
77-
<> (getParentTypes (Proxy :: Proxy b))
78-
<> (getParentTypes (Proxy :: Proxy c)))
71+
getParentTypes _ = L.nub [ (TSType (Proxy :: Proxy a))
72+
, (TSType (Proxy :: Proxy b))
73+
, (TSType (Proxy :: Proxy c))
74+
]
7975

8076
instance (TypeScript a, TypeScript b, TypeScript c, TypeScript d) => TypeScript (a, b, c, d) where
8177
getTypeScriptType _ = [i|[#{getTypeScriptType (Proxy :: Proxy a)}, #{getTypeScriptType (Proxy :: Proxy b)}, #{getTypeScriptType (Proxy :: Proxy c)}, #{getTypeScriptType (Proxy :: Proxy d)}]|]
82-
getParentTypes _ = L.nub ((TSType (Proxy :: Proxy a))
83-
: (TSType (Proxy :: Proxy b))
84-
: (TSType (Proxy :: Proxy c))
85-
: (TSType (Proxy :: Proxy d))
86-
: (getParentTypes (Proxy :: Proxy a))
87-
<> (getParentTypes (Proxy :: Proxy b))
88-
<> (getParentTypes (Proxy :: Proxy c))
89-
<> (getParentTypes (Proxy :: Proxy d)))
78+
getParentTypes _ = L.nub [ (TSType (Proxy :: Proxy a))
79+
, (TSType (Proxy :: Proxy b))
80+
, (TSType (Proxy :: Proxy c))
81+
, (TSType (Proxy :: Proxy d))
82+
]
9083

9184
instance (TypeScript a) => TypeScript (Maybe a) where
9285
getTypeScriptType _ = getTypeScriptType (Proxy :: Proxy a)
@@ -98,9 +91,8 @@ instance TypeScript A.Value where
9891

9992
instance (TypeScript a, TypeScript b) => TypeScript (HashMap a b) where
10093
getTypeScriptType _ = [i|{[k: #{getTypeScriptType (Proxy :: Proxy a)}]: #{getTypeScriptType (Proxy :: Proxy b)}}|]
101-
getParentTypes _ = L.nub ((getParentTypes (Proxy :: Proxy a))
102-
<> (getParentTypes (Proxy :: Proxy b)))
94+
getParentTypes _ = L.nub [TSType (Proxy :: Proxy a), TSType (Proxy :: Proxy b)]
10395

10496
instance (TypeScript a) => TypeScript (Set a) where
10597
getTypeScriptType _ = getTypeScriptType (Proxy :: Proxy a) <> "[]";
106-
getParentTypes _ = L.nub (getParentTypes (Proxy :: Proxy a))
98+
getParentTypes _ = L.nub [TSType (Proxy :: Proxy a)]

0 commit comments

Comments
 (0)