본문 바로가기

반응형

Frontend/TypeScript

(4)
Generic TypeScript is a strongly type language and it significantly reduces the type errors while in development which would not be possible with mare JS. At the same time it also reduces the reusability of codes. If you want both the feature, The generic is a way to go. Without further ado, let's see how we can use the Generic Without Type Checking Below is an example of JavaScript code. JavaScript is ..
Decorator The decorator in TypeScript is a feature that enables us to add meta data or business logic without having to change the orginal code format. For example, when we have multiple classes with the same attribute name, type, with the same value, we can use the decorator to reduce redundancy How to Use It? This feature is in test at the moment, so we need a set up to use this. Open the console and ru..
Interface Interface is a class that defines attributes without initial values. It makes our life so much easier when we work with TypeScript as we can define a type once and use it across out application. How to Use It? Let's see how we can make the code below simpler using the interface. let object: { name: string; age: number; married?: boolean } = { name: 'tom', age: 20, } Create a interface of the obj..
TypeScript JavaScript, as you know, is a weakly typed language. While this feature allows you to write a code easily and freely, it also make the language prone to logic error whick is very hard to find. TypeScript is a superset of JavaScript. It includes all the features from JavaScript and has an additional feature, yep! you guessed right: type checking which makes it easier to find logic errors early in..

728x90