Fundamentos de TypeScript

1

¿Qué es TypeScript y por qué usarlo?

2

Instalación de Node.js y TypeScript CLI, configuración de tsconfig.json

3

Tipos primitivos: string, number, boolean, null, undefined de Typescript

4

Tipos especiales: any, unknown, never, void de TypeScript

5

Arrays, Tuplas, Enums en TypeScript

Funciones e Interfaces

6

Declaración de funciones, tipado de parámetros y valores de retorno

7

Parámetros opcionales, valores por defecto y sobrecarga de funciones

8

Creación y uso de interfaces de TypeScript

9

Propiedades opcionales, readonly, extensión de interfaces en TypeScript

Clases y Programación Orientada a Objetos

10

Creación de clases y constructores En TypeScript

11

Modificadores de acceso (public, private, protected) en Typescript

12

Uso de extends, sobreescritura de métodos en TypeScript

13

Introducción a Genéricos en Typescript

14

Restricciones con extends, genéricos en interfaces

Módulos y Proyectos

15

Importación y exportación de módulos en TypeScript

16

Agregando mi archivo de Typescript a un sitio web

17

Configuración de un proyecto Web con TypeScript

18

Selección de elementos, eventos, tipado en querySelector en TypeScript

19

Crear un proyecto de React.js con Typescript

20

Crea un proyecto con Angular y Typescript

21

Crea una API con Typescript y Express.js

Conceptos Avanzados

22

Introducción a types en TypeScript

23

Implementación de Decoradores de TypeScript

24

Async/await en Typescript

25

Pruebas unitarias con Jest y TypeScript

26

Principios SOLID, código limpio, patrones de diseño en Typescript

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

0 Días
5 Hrs
20 Min
8 Seg
Curso de TypeScript

Curso de TypeScript

Amin Espinoza

Amin Espinoza

Instalación de Node.js y TypeScript CLI, configuración de tsconfig.json

2/26
Resources
Transcript

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.

How to install TypeScript on your system?

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.

How to improve the development experience with extensions?

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:

  • Enhanced syntax highlighting
  • Intelligent auto-completion
  • Real-time error detection
  • More accurate code suggestions

To install it, simply:

  1. Open the extensions section in VS Code (icon in the sidebar).
  2. Search for "TypeScript".
  3. Locate Microsoft's "JavaScript and TypeScript Nightly".
  4. Click install

It is important to verify that the author is Microsoft to ensure that you are installing the official and safe extension.

How to initialize a TypeScript project?

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:

  • target: Defines the version of JavaScript your code will be compiled to.
  • module: Specifies the module system to use
  • strict: Enables a set of strict type checks.
  • outDir: Directory where the compiled JavaScript files will be generated.

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

Sort by:

Want to see more contributions, questions and answers from the community?

Estaba a la mitad de la version anterior del curso, ahora continuaré en este, más vale estar actualizado. Saludos bandita
Una pregunta. Es necesario instalar typescript global?, en la version anterior del curso Typescript se instalaba en un proyecto creado con `npm install typescript` usando comandos de NPM y no de Linux. Pregunto porque siempre me ah dado problemas siempre las terminales de Linux en Windows 11
Requisitos para usar TypeScript: * Node.js \[node -v] * npm \[npm -v] * para instalar TypeScript \[npm install -g typescript] *
Para ejecutar comandos de TypeScript sin instalarlo globalmente, puedes utilizar npx, que viene incluido con npm. Simplemente, navega a tu proyecto en la terminal y ejecuta: ```bash npx typescript ``` Esto permitirá que TypeScript se ejecute sin necesidad de instalación global. Además, puedes agregarlo como dependencia en tu proyecto: ```bash npm install --save-dev typescript ``` Luego, puedes usar npx para ejecutar los comandos de TypeScript directamente desde tu proyecto.
Requisitos para usar TypeScript: \- Node.js \- npm