TypeScript
-
Advanced Object TypesTypeScript 2023. 8. 9. 16:58
타입스크립트의 Advanced Object Types에 대해 정리하였습니다. One of the challenges of writing TypeScript is knowing how to apply types in every situation we’ll encounter within our code. This lesson is about how we can deal with a variety of situations to make sure that our code is typed with object-oriented programming patterns, no matter what our program does or how it's structured. Types shoul..
-
Type NarrowingTypeScript 2023. 7. 24. 18:35
타입스크립트의 Type Narrowing에 대해 정리하였습니다. Type narrowing is when TypeScript can infer more specific types based on the variable's surrounding code. Example) function formatDate(date: string | number) { // date can be a number or string here if (typeof date === 'string') { // date must be a string here } } One way that TypeScript can narrow a type is with a conditional ..
-
Union TypesTypeScript 2023. 7. 7. 23:54
타입스크립트의 Union Types에 대해 정리하였습니다. Unions allow us to define multiple allowed type members by separating each type member with a vertical line character | Example) let ID: string | number; // number ID = 1; // or string ID = '001'; console.log(`The ID is ${ID}.`); : Union Types is more flexible than a single primitive type, but much more specific than the any type. < Type Narro..
-
Custom TypesTypeScript 2023. 6. 19. 18:08
타입스크립트의 Custom Types에 대해 정리하였습니다. TypeScript can also be used to create custom types, rather than being limited to pre-defined types. Pre-defined types are like ingredients: they can be used on their own. Sometimes you just need a simple string and sometimes you just want to eat a pickle! However, pre-defined types can also be combined into custom types. Custom types are like fu..
-
ArrayTypeScript 2023. 6. 6. 20:40
타입스크립트에서 Array의 개념 및 문법에 대해 정리하였습니다. To put type annotation for array types method 1: put [ ] after the element type let names: string[] = ['Danny', 'Samantha']; method 2: use Array syntax; T stands for the type. let names: Array = ['Danny', 'Samantha']; Example) let names: string[] = [1,2,3]; // Type Error! let names: string[] = ['Damien']; names.push(666) // Type Err..
-
FunctionsTypeScript 2023. 5. 25. 18:53
타입스크립트의 Functions에 대해 작성하였습니다. When we declare a function in JavaScript, we often expect it to be invoked with arguments of a certain type. JavaScript does not share our expectations: its type flexibility often allows functions to be invoked with unexpected argument types. Example) function printLengthOfText(text) { console.log(text.length); } printLengthOfText(3); // Prints: un..
-
TypesTypeScript 2023. 5. 4. 13:57
TypeScript에 대한 기본 개념 및 문법에 대해 정리하였습니다. JavaScript was designed to be very flexible and easy to use for small applications. These features make JavaScript a great first language to learn, but they also make it less-than-ideal for building larger-scale applications with hundreds or even thousands of files. To address these shortcomings, Microsoft developed TypeScr..