Fundamentos de TypeScript
¿Qué es TypeScript y por qué usarlo?
Instalación de Node.js y TypeScript CLI, configuración de tsconfig.json
Tipos primitivos: string, number, boolean, null, undefined de Typescript
Tipos especiales: any, unknown, never, void de TypeScript
Arrays, Tuplas, Enums en TypeScript
Funciones e Interfaces
Declaración de funciones, tipado de parámetros y valores de retorno
Parámetros opcionales, valores por defecto y sobrecarga de funciones
Creación y uso de interfaces de TypeScript
Propiedades opcionales, readonly, extensión de interfaces en TypeScript
Clases y Programación Orientada a Objetos
Creación de clases y constructores En TypeScript
Modificadores de acceso (public, private, protected) en Typescript
Uso de extends, sobreescritura de métodos en TypeScript
Introducción a Genéricos en Typescript
Restricciones con extends, genéricos en interfaces
Módulos y Proyectos
Importación y exportación de módulos en TypeScript
Agregando mi archivo de Typescript a un sitio web
Configuración de un proyecto Web con TypeScript
Selección de elementos, eventos, tipado en querySelector en TypeScript
Crear un proyecto de React.js con Typescript
Crea un proyecto con Angular y Typescript
Crea una API con Typescript y Express.js
Conceptos Avanzados
Introducción a types en TypeScript
Implementación de Decoradores de TypeScript
Async/await en Typescript
Pruebas unitarias con Jest y TypeScript
Principios SOLID, código limpio, patrones de diseño en Typescript
TypeScript programming has become an essential tool for developers looking to add robustness to their JavaScript projects. This JavaScript superset offers static typing and other advanced features that improve code quality and facilitate the maintenance of complex applications. To start using this powerful technology, it is necessary to follow some initial configuration steps that will allow you to take full advantage of its benefits.
Before diving into the world of TypeScript, it is essential to verify that you have the necessary prerequisites. TypeScript relies entirely on Node.js and NPM for its operation, so these must be installed on your system before proceeding.
To check if you already have these tools, you can run the following commands in your terminal:
node -vnpm -v
These commands will show the installed versions of Node.js and NPM respectively. If you get a response with version numbers, it means they are already installed and you can continue. If not, you will need to install them before proceeding.
Once you have confirmed that you have Node.js and NPM, you can proceed to install TypeScript globally on your system using the following command:
npm install -g typescript
You may need administrator permissions to perform this global installation. On Unix-based systems (such as Linux or macOS), you can use:
sudo npm install -g typescript
To verify that the installation has completed successfully, run:
tsc -v
This command should show the version of TypeScript installed on your system, confirming that everything is ready to start working.
Visual Studio Code is the recommended editor for working with TypeScript, as it offers excellent support for this language. To further optimize your development experience, it is recommended to install the "JavaScript and TypeScript Nightly" extension developed by Microsoft.
This extension provides:
To install it, simply:
It is important to verify that the author is Microsoft to ensure that you are installing the official and safe extension.
Once you have TypeScript installed and your editor configured, it is time to initialize your first project. To do this, navigate to the folder where you want to create your project and run:
tsc --init
This command will create a tsconfig.json
file in your current directory. This file is critical to the configuration of TypeScript in your project, as it defines how the compiler will behave.
The generated file contains numerous commented options that you can customize to suit your needs. Basic settings, such as the target (version of JavaScript to compile to) and modules, are uncommented by default.
{ " compilerOptions": { " target": "es2016", " module": "commonjs", // Many more commented options... }}
It is recommended to explore these options to understand what you can customize in your project. Some important settings include:
With these steps completed, you now have everything you need to start developing with TypeScript. The initial setup may seem like an additional process compared to pure JavaScript, but the benefits you will get in terms of early bug detection and code maintainability make it completely worth it.
Have you used TypeScript in any of your projects? Share your experience and any questions you have about the initial setup in the comments section.
Contributions 5
Questions 1
Want to see more contributions, questions and answers from the community?