Commit Graph

11 Commits

Author SHA1 Message Date
Robin Krom
ed4397b2eb language: add registerTemplate for daml2ts (#3737) 2019-12-05 09:07:16 +01:00
Martin Huschenbett
5c02b1a1c3 Make the daml2ts tests fail on generated unused imports/definitions (#3714)
* Make the daml2ts tests fail on generated unused imports/definitions

* Shut up buildifier
2019-12-04 14:08:50 +00:00
nickchapman-da
d15b0c7538
Add support for type-synonyms in DAML-LF .proto and Haskell AST (#3703)
* Add support for type-synonyms in DAML-LF .proto and Haskell AST

* address review comments
2019-12-03 14:51:02 +00:00
Martin Huschenbett
7d1068b69d
daml2ts: Avoid 'unused definition' warning for modules without templates (#3698)
We only use the `templateId` function in a module only when the module
contains at least one template definition. Thus, we don't generate it if
there are no modules. That's the only functional change. The other changes
are due to the fact that we want better readability of the code.
2019-12-02 18:21:22 +01:00
Martin Huschenbett
6e6614ae56 daml2ts: Use monoTraverse to collect modules refs in types (#3690)
This was suggested by @corcreature on a previous PR.
2019-12-02 14:56:22 +00:00
Martin Huschenbett
712231c963 daml2ts: Don't produce unused imports (#3689)
Instead of importing _all_ other modules referenced from a module, only
import those that are actually referenced from the generated code. First,
this produces less noise within each generated file. Second and probably
more important, this allows for not generating files without any actual
definition at all.

https://github.com/digital-asset/davl/pull/81 demonstrates the effect of
this change on DAVL.
2019-12-01 11:38:56 +00:00
nickchapman-da
d3d6891021
Rename daml lf tuples (#3658)
* Rename DAML-LF tuples as structs (structural records)
2019-11-28 07:58:30 +00:00
Martin Huschenbett
677b30687f Improve wording of daml2ts readme (#3652) 2019-11-27 16:16:10 +00:00
Martin Huschenbett
09a681d4f3 Add a readme for daml2ts (#3638) 2019-11-26 17:49:40 +00:00
Remy
d152c7cbfd daml-lf: rename Map to TextMap in archive proto (#3589)
* daml-lf: rename Map to TextMap in archive proto
+ in Scala/haskell AST

* a bit more renamming

* Update compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/Serializability.hs

Co-Authored-By: associahedron <231829+associahedron@users.noreply.github.com>

* fix test

* Apply suggestions from code review

Co-Authored-By: associahedron <231829+associahedron@users.noreply.github.com>

* Update compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs

Co-Authored-By: associahedron <231829+associahedron@users.noreply.github.com>
2019-11-25 12:14:57 +00:00
Martin Huschenbett
c33517cf9f MVP for a daml2ts codegen (#3441)
* MVP for a daml2ts codegen

This PR adds an MVP for a codegen for TypeScript.

Given a DAR, daml2ts replicates the structure of the serializable type
definitions in it as TypeScript type definitions following our JSON
representation of DAML-LF types. It also adds decoders for all these types,
which can be used to check where an arbitray JSON value has the given type.
Finally, daml2ts also produces one JavaScript object for each template, which
reflects the type information of that template.

All produces objects implement some interfaces defined in a TypeScript
library currently called `@digitalasset/daml-json-types`. This libary is not
yet uploaded to NPM but rather included in the `tests/ts/daml-json-types`
directory. This libary also contains the JSON decoders for all of DAML-LF's
builtin types.

There are quite a few limitations right now. Most notably, variant and enum
types are not properly typed right now but rather gradually "typed" as
`unknown`. We also don't support nested `Optional`s, the `Numeric` type or
sum-of-product types in DAML. These issues are tracked in #3518.

There is currently one test. It takes a very simple DAML model, generates
the TypeScript for it and checks that it compiles and contains no linter
warnings/errors. Proper integration tests against the JSON API will follow.

* Address @cocreature's comments

* Make test work on Windows
2019-11-19 15:51:17 +00:00