We discuss two adaptations of the implementation of type guards and narrowing in the TypeScript compiler. The first is an improvement on the original syntax-directed implementation, and has now replaced the original one in the TypeScript compiler. It is specifically suited for the scenario in which an IDE requests the type of a particular variable in the program. The second implementation is defined as a whole program analysis, and is therefore able to compute more precise narrowed types, but at the price of a higher run-time cost.
|Title of host publication||Proceedings of the 2017 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation|
|Subtitle of host publication||PEPM 2017|
|Publisher||Association for Computing Machinery|
|Number of pages||12|
|Publication status||Published - 2 Jan 2017|