Learning Objectives What is Typescript? What is a Variable? Data Types Arrays Enum Function Classes in Typescript Inheritance Getter & Setter Interfaces Decorators
What is Typescript? Typescript is a superset of JavaScript. TypeScript is strongly typed, whereas JavaScript is dynamically typed. TypeScript allows to specify the datatype explicitly. Typescript helps the user to write the JavaScript more easier with advanced features. TypeScript cannot be directly executed by browsers like JavaScript. Instead TypeScript code is compiled to get JavaScript code.
What is Typescript?
What is a Variable? Named storage to store a value In typescript, the variables are strongly typed
Datatypes String Use backticks ` mystring ` - used to write an expression E ven we can use variables ${var} using backticks (Template reference syntax) Number Boolean
Arrays
Enum
Function
Function
Arrow Function Arrow functions have become the standard syntax in modern JavaScript. They offer a concise way to write functions, making your code lighter and more readable
Class in Typescript
Class in Typescript
Class in Typescript
Class in Typescript
Method Overriding
Getter & Setter Getter will help the private members to be accessed outside the class. We use get keyword Setter will help us to set the value of the private member using set keyword.
Interface An interface in TypeScript defines the expected structure of an object. It provides a way to describe the shape of objects, including their properties and methods, without implementing any functionality.
Why Interface? Improved Type Checking Easier to understand and maintain the code. Interfaces can be extended and reused across different parts of the code.
Interface using Arrow functions
Multiple Inheritance
Decorators It is a powerful feature in Typescript which helps to add functionality or modify the behavior of classes, methods, properties and parameters at runtime. They are functions declared using @ symbol.