- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 128 Articles for TypeScript
136 Views
In TypeScript, interfaces provide a powerful way to define the shape of objects and enforce type constraints. They allow us to specify the required properties and methods that an object must have. One interesting feature of interfaces is the ability to extend them, allowing us to create a combination of interfaces. In this tutorial, we will explore how to extend interfaces to create new ones that inherit properties and methods from existing interfaces. Syntax interface NewInterface extends ExistingInterface { // Additional properties and methods } interface NewInterface extends Interface1, Interface2, ... { // ... Read More
169 Views
Regular polygons, such as squares, triangles, and hexagons, are fundamental shapes used in various applications and graphics. Drawing regular polygons programmatically can be useful in TypeScript, allowing you to create geometric shapes dynamically. In this tutorial, we will explore how to draw regular polygons in TypeScript by leveraging basic mathematical principles and the HTML5 canvas element. Syntax function drawRegularPolygon(ctx: CanvasRenderingContext2D, n: number, x: number, y: number, r: number): void { const angle = (Math.PI * 2) / n; ctx.beginPath(); ctx.moveTo(x + r, y); for (let i = 1; i
199 Views
Object-oriented programming (OOP) is a popular programming paradigm that has been widely adopted in the software development industry. OOP is based on the concept of objects, which are instances of classes that encapsulate data and behaviour. TypeScript, a statically typed superset of JavaScript, is designed to support the development of large-scale applications and is also an object-oriented programming language. In this article, we will explore the object-oriented terms supported by TypeScript. Below we discuss various object-oriented terms supported by TypeScript. Class In TypeScript, a class is a blueprint for creating objects that define a set of properties and methods that ... Read More
30 Views
In TypeScript, the keyof keyword plays a significant role when working with objects and their properties. It allows us to obtain the keys of an object and use them to perform various operations. This tutorial will guide you through the usage of keyof, providing syntax explanations and code examples for different scenarios. Syntax keyof Type The above is the syntax for the keyof keyword in TypeScript. The keyof keyword is followed by the name of a type, referred to as "Type." It returns a union type consisting of all the keys (property names) of the specified type. This allows ... Read More
559 Views
Introduction TypeScript offers powerful features that enhance JavaScript development. One such feature is declaration merging, which allows developers to combine multiple declarations of the same entity into a single definition. This tutorial will introduce you to the concept of declaration merging in TypeScript and provide examples to help you understand its practical implementation. Declaration Merging Basics Declaration merging in TypeScript enables the compiler to merge multiple declarations for the same entity, such as interfaces, functions, classes, or enums. By merging declarations, you can extend existing types and add new properties, methods, or functionality. Let's explore the scenarios where declaration merging ... Read More
129 Views
TypeScript is a statically typed superset of JavaScript that adds static typing capabilities to the language. One of the key features of TypeScript is its ability to provide optional parameters in function declarations, allowing developers to define functions with parameters that may or may not be provided during function calls. This flexibility enhances code reusability and simplifies function invocations, leading to more maintainable and expressive code. In this tutorial, we will explore how TypeScript supports optional parameters in functions, covering the syntax, benefits, and some practical examples. Syntax To define optional parameters in TypeScript functions, you can use the question ... Read More
3K+ Views
In this tutorial, we will learn about calling APIs using TypeScript. TypeScript is a statically-typed superset of JavaScript that adds type checking to the language. It provides enhanced tooling and helps catch errors during development. When working with APIs, we often need to make HTTP requests to send data and retrieve information. TypeScript allows us to write clean and organized code while interacting with APIs, making it easier to handle responses and work with the returned data. Throughout this tutorial, we will explore different methods and libraries available in TypeScript for making API calls. We will focus on using the ... Read More
153 Views
In the world of programming, object-oriented principles provide a solid foundation for designing and building software systems. Object-oriented programming (OOP) languages enable developers to model real-world entities as objects, encapsulate data and behavior, and establish relationships between objects. TypeScript, a superset of JavaScript, brings static typing to the language and offers many features to support object-oriented programming. In this tutorial, we will explore various scenarios to understand how well TypeScript aligns with the core principles of object-oriented programming. Encapsulation Encapsulation refers to the bundling of data and methods into a single unit, known as a class, and hiding the internal ... Read More
2K+ Views
TypeScript is a strongly typed superset of JavaScript that compiles to plain JavaScript. TypeScript adds static type-checking, classes, and interfaces to the language, making writing and maintaining large-scale applications easier. TypeScript files are compiled into JavaScript files that can be run in any browser or server that supports JavaScript. This article will look at how to compile multiple TypeScript files into a single output js-file. We will start by looking at how to use the TypeScript compiler to compile multiple TypeScript files and then see how to use Webpack to bundle multiple TypeScript files into a single JavaScript file. Compiling ... Read More
59 Views
TypeScript, a superset of JavaScript, brings static typing to the JavaScript ecosystem. It enables developers to catch errors early and write more robust code. One of the powerful features TypeScript offers is the ability to define and enforce types for variables, functions, classes, and more. However, there are scenarios where TypeScript lacks type information for external JavaScript libraries or modules. To bridge this gap and enable proper type checking, TypeScript provides a feature called "Ambients." In this tutorial, we will explore what ambients are, how to use them, and when they are beneficial. What are Ambients? Ambients in TypeScript provide ... Read More