Skip to content

Instantly share code, notes, and snippets.

@ltciro
Created July 25, 2019 03:14
Show Gist options
  • Save ltciro/85ac02918c52a52a6320492d33bf8c5a to your computer and use it in GitHub Desktop.
Save ltciro/85ac02918c52a52a6320492d33bf8c5a to your computer and use it in GitHub Desktop.
//Basic Types: boolean, string, arrays, number,
// null, undefined, void, object, never, Symbol
var grettings: string = "Hola esto es un string";
grettings = {attendets: "gracias por venir"}; //error
//capturar comportamientos inesperados
const sumWeird = {attendets: "Hola"} + ["como estan"]; //error
//Type inference
let gretting = {attendets: "gracias por venir"};
gretting = "Hola esto es un string"; //error
//Type assertion, Type Literal, Union types
interface communities{
medellin: string[]
cali: string[]
}
const communities : communities = {medellin: ["medjs", "pioneras"], cali: ["calijs", "pioneras"]}
Object.keys(communities).forEach((value)=>{
const city: "medellin" | "cali" = value as keyof communities ;
console.log(city)
})
//Spaces declaration
//Variable declaration
class CatClass{
isCute(){ return 1}
isDangerous(){return 2}
}
enum CatEnum {
cute = 1,
dangerous= 2
}
const a = CatEnum;
//Type declaration
type CatType = {}
interface catInterface{}
const b = catInterface; /error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment