Refining types using type guards in TypeScript

Ivo Gabe de Wolff, J. Hage

Research output: Chapter in Book/Report/Conference proceedingConference contribution


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.
Original languageEnglish
Title of host publicationProceedings of the 2017 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation
Subtitle of host publicationPEPM 2017
PublisherAssociation for Computing Machinery
Number of pages12
ISBN (Print)9781450347211
Publication statusPublished - 2 Jan 2017


Dive into the research topics of 'Refining types using type guards in TypeScript'. Together they form a unique fingerprint.

Cite this