Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

Explain how TypeScript fits into Angular?

Explain how TypeScript fits into Angular?

I coded Angular 4 and am pretty sure I used TypeScript. But, I can not recall exactly where.

Please refresh my memory.

Thanks
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

If you are coding in Angular 2 or higher you are using TypeScript.

TypeScript is basically a typed superset of JavaScript. Anything you can do in JavaScript you can do in TypeScript. The nice thing about TypeScript is
a) It allows you to type your variables, function returns etc - so the compiler does some key checking
b) It enables you to use the latest JavaScript functions and features without having to worry about backward compatibility

When you compile your Angular App - the TypeScript code is Transpiled into JavaScript, minified and tree shaken - ready to be published. It is not much more involved than that.
Avatar of curiouswebster

ASKER

Can you give me an example of TypeScript to Javascript? I am still a bit unsure how this works under the covers.

For example, what variable and function name types are available?
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So, let is a newer type which allows the transpiler select the type to use as it generates the javascript?
thanks
You are welcome

So, let is a newer type which allows the transpiler select the type to use as it generates the javascript?
Not sure what the question is?
let is used for local declarations (local to the block they are in) as opposed to var which declares a variable that is global to the entire function
Sorry, that was an old thought I should have deleted...