Professional Documents
Culture Documents
● It is a precompiler.
● It does not require any
plugin.
Origin TypeScript
It was created by Microsoft in 2012 and, since then, its adoption has
only grown.
For projects that will remain simple and small, or if they are known to
be scrapped over time, I'd be less inclined to recommend TypeScript as
a requirement. Lack of unit tests:
• Startup
• Teamwork
• Communicate patterns and implement design principles
frameworks
Installing TypeScript
> tsc -v
Start with TypeScript
{
"compilerOptions" :
{ "module" :
"commonjs","target" :
"es5","noImplicitAny" :
false,"sourceMap" :
false.
}
}
Definition of variable.
Example of var.
if (true) {
var foo = 456;
}
console.log(foo);
le
t
Example of use of
let.
let foo = 123;
if (true) {
let foo = 456;
}
console.log(foo);
Types of data
Boolean
true or false
access = false;
Primitive data: Number
Number
Numerical data.
String
Character strings and/or texts.
Template
They are templates for concatenating
strings.
let name: string = 'Juan Perez';
let age: number = 37;
let message: string = `Hello, my name is ${ name }.
and my age is ${ age}`;
Primitive data: Any
Any
It can be any type of javascript object.
Array
Arrays, if no type is specified, they are ANY.
Parameter methods.
class Person {
public name: string;
constructor(name: string) {
this.name = name;
Classes }
greet(): string{
return "Hello, I am " + this.name;
}
}
Example for instantiating a class
modifiers ● private
● protected
Example of inheritance in
TypeScript
class Person {
public name: string;
constructor(name: string) {
this.name = name;
Heritage }
https://codigofacilito.com/articulos/typescript
https://www.typescriptlang.org/
Conclusions