I just read an article on official blog angular 5 (https://blog.angular.io/version-5-0-0-of-angular-now-available-37e414935ced). There is talk of typescript transform. In detail:
"TypeScript Transforms Under the hood, the Angular compiler now operates as a TypeScript transform, making incremental rebuilds dramatically faster. TypeScript transforms were a new feature introduced as part of TypeScript 2.3 that allows us to hook into the standard TypeScript compilation pipeline."
I would like to understand better it. Tranforms or compilation pipeline, what are? tnx!
Tsc stands for `TypeScript compiler` and is a simple tool included in Typescript itself, allowing you to compile any ts files into js.
TypeScript Code is converted into Plain JavaScript Code: TypeScript code can't be natively interpreted by browsers. So if the code was written in TypeScript, it gets compiled and converted into JavaScript. This process is known as Trans-piled.
The TypeScript compiler supports a mix of JavaScript and TypeScript files if we use the compiler option --allowJs : TypeScript files are compiled. JavaScript files are simply copied over to the output directory (after a few simple type checks).
Types for ToolingTypeScript can catch bugs when we make mistakes in our code. That's great, but TypeScript can also prevent us from making those mistakes in the first place. The type-checker has information to check things like whether we're accessing the right properties on variables and other properties.
This referes to the internals of how the typescript compiler generates Javascript code. Since 2.3 the compiler takes the Typescript AST (abstract syntax tree) and applies a series of transformations (the transformation pipeline). At the end of the pipeline you get a new AST that is a Javascript AST.
From the source code, these are the current transformers:
So for example when compiling for a es5
target with jsx
enabled and system
modules the following transforms will be included:
transformTypeScript - Will remove typescript specific annotations
transformJsx - Will remove jsx
syntax and transform it to Javascript
transformESNext - Will transform esnext
to es2017
transformES2017 - Will transform es2017
to es2016
transformES2016 - Will transform es2016
to es2015
transformES2015 - Will transform es2015
to es5
(minus generators)
transformGenerators - Will transform es2015
generators to es5
transformSystemModule - Will add module specific js code.
After all the transformations are applied, writing the AST to a file is a trivial operation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With