daml/language-support/ts/codegen
Gary Verhaegen 878429e3bf
update copyright notices to 2020 (#3939)
copyright update 2020

* update template
* run script: `dade-copyright-headers update .`
* update script
* manual adjustments
* exclude frozen proto files from further header checks (by adding NO_AUTO_COPYRIGHT files)
2020-01-02 21:21:13 +01:00
..
src update copyright notices to 2020 (#3939) 2020-01-02 21:21:13 +01:00
tests update copyright notices to 2020 (#3939) 2020-01-02 21:21:13 +01:00
BUILD.bazel update copyright notices to 2020 (#3939) 2020-01-02 21:21:13 +01:00
README.md Fix typos in daml2ts readme (#3927) 2019-12-27 11:10:32 -05:00

daml2ts

This is a very early version of a code generator for a TypeScript interface to a DAML package. Its shortcomings are documented in this Github issue. It is not yet shipped with the SDK. To run it, you must execute

$ bazel run //:daml2ts
Usage: daml2ts DAR-FILE -o DIR
  Generate TypeScript bindings from a DAR

somewhere in this repository. The DAR-FILE is the DAR for which you want to generate the TypeScript interface. daml2ts will generate interfaces for all DALFs in that DAR. The output will be written into the directory DIR you specify via the -o option.

The @digitalasset/daml-json-types package referenced by the generated code has not yet been published. You can find it in the tests/ts/daml-json-types directory.

Currently, the generated interfaces are tailored towards the ledger.ts module of DAVL.

How to develop daml2ts

The full test suite is started via

bazel test //language-support/ts/codegen/tests/...

Unfortunately, this is a bit slow and not suitable for repeated running during development. To make things more responsive, you can run the following trinity of shell scripts, all in parallel and each in its own terminal:

  • ./tests/watch-damlc.sh: Build a DAR out of the .daml files in ./tests/daml whenever they change.
  • ./tests/watch-daml2ts.sh: Re-interpret daml2ts and run it on the DAR produced by ./tests/watch-damlc.sh.
  • ./tests/watch-yarn: Build all the TypeScript libraries in dependency order and run the TypeScript compiler in watch mode on the TypeScript generated by ./tests/watch-daml2ts.sh. This script does not recompile any changes made to the TypeScript libraries daml-json-types or damnl-ledger-fetch. Changes to these libraries must be manually recompiled using yarn build in the respective directoties. (You can also use yarn build:watch to run the TypeScript compiler in watch mode.)

All these steps only check that everything compiles. They do not run any tests. To run the tests suite, you need to issue the command above.