Skip to content
Volker Sorge edited this page Aug 19, 2016 · 9 revisions

Post Mortem

Some lessons learnt from the Typescript project.

General Language Observations

In general, very good experience writing Typescript. Building class hierarchies, defining interfaces, abstract classes, etc. is very convenient. In particular, all necessary typing for HTML elements etc is already built into the language. This is a certainly an advantage over other approaches like closure, where these types (and in particular the associated API functions) have to be explicitly defined in extern files.

Pros

  • All necessary typing for HTML elements etc is already built into the language. This is a certainly an advantage over other approaches like closure, where these types (and in particular the associated API functions) have to be explicitly defined in extern files.
  • Generics (e.g., in the Variable class are available.
  • Types can be very fine grained (see example of JSON types), maybe sometimes too specific.

Cons for (of v1.8.10)

  • Enum structures are only definable on numbers
  • String subtyping can be a bit awkward (see html class and attribute types), in particular when strings are generated.
  • Some modern functionality is not yet integrated. In particular, promises are still missing. This at least should change in

We have some tools to compile UML style class diagrams.

Minimisation

Typescript's compiler tsc does not provide a minimisation option. I tried two minifiers:

UglifyJS: Minified code was 44KB. Code sample in [samples/scripts]

(https://github.com/zorkow/context-menu/blob/v0.1/samples/scripts)

Closure: Minified code was 33KB, mainly because closure is better at compressing constructors and prototype assignments. Command used:

 java -jar ~/node_modules/closurecompiler/compiler/closure-compiler-v20160713.jar --js context_menu.js --create_source_map tt.map --js_output_file tt.min.js

However, it has drawbacks with respect to code maps. See next.

Code Maps

Documentations

Code commenting follows JSDoc standards. This can be used for documentation extraction using a corresponding generator.

This is generated with typedoc generator.

For some reason it does not work on the actual github pages. E.g., go to the github.io version and then try to go to one of the module pages (e.g., for abstract_entry.

This is created with regular JSDoc generator from a typescript transpiled into ES2015 keeping comments, plus some tricks to get the "pseudo-enum" structures out, given in the tools directory. Unfortunately, JSDoc does not work out of the box on Typescript Interfaces and fails when constructors are implicit (i.e., not explicitly included in the JS class with JSDoc comments).

Other remarks:

Clone this wiki locally