November 2019
Beginner
804 pages
20h 1m
English
The JavaScript code that TypeScript generates when it down-level emits classes is actually very interesting. Here is a bit of information that should help you to understand what the TypeScript compiler does there.
When TypeScript down-level emits a TypeScript class to ES5 or older, it creates an Immediately Invoked Function Expression (IIFE) in which the class is defined (as a simple function) and returned. The result of the execution of that IIFE is stored in a variable and used when the class is later referenced (for example, to create a new instance or to access a static field or static method). Inside the IIFE, a function is defined with the name of the class and constructor arguments ...
Read now
Unlock full access