Skip to content

Commit

Permalink
Use template Key in template generic params list (digital-asset#4186)
Browse files Browse the repository at this point in the history
changelog_begin
changelog_end

Co-authored-by: Shayne Fletcher <shayne.fletcher@digitalasset.com>
  • Loading branch information
2 people authored and mergify[bot] committed Jan 23, 2020
1 parent 78b2985 commit 3811b6c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions language-support/ts/codegen/src/TsCodeGenMain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,7 @@ genDefDataType curPkgId conName mod tpls def =
]
(keyTypeTs, keySer) = case tplKey tpl of
Nothing -> ("undefined", "() => jtv.constant(undefined)")
Just key ->
let (keyTypeTs, keySer) = genType (moduleName mod) (tplKeyType key)
in
(keyTypeTs, "() => " <> keySer <> ".decoder()")
Just key -> (conName <.> "Key", "() => " <> snd (genType (moduleName mod) (tplKeyType key)) <> ".decoder()")
dict =
["export const " <> conName <> ": daml.Template<" <> conName <> ", " <> keyTypeTs <> "> & {"] ++
[" " <> x <> ": daml.Choice<" <> conName <> ", " <> t <> ", " <> rtyp <> ", " <> keyTypeTs <> ">;" | (x, t, rtyp, _) <- chcs] ++
Expand Down Expand Up @@ -250,10 +247,10 @@ genDefDataType curPkgId conName mod tpls def =
] ++
["};"]
associatedTypes =
maybe [] (const $
maybe [] (\key ->
[ "// eslint-disable-next-line @typescript-eslint/no-namespace"
, "export namespace " <> conName <> " {"] ++
[" export type Key = " <> keyTypeTs <> ""] ++
[" export type Key = " <> fst (genType (moduleName mod) (tplKeyType key)) <> ""] ++
["}"]) (tplKey tpl)
registrations =
["daml.registerTemplate(" <> conName <> ");"]
Expand Down

0 comments on commit 3811b6c

Please sign in to comment.